-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for keploy test bench for native environment #1776
Conversation
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address comments and provide steps on how developers can run this on local machines and fix the pipeline
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
@gouravkrosx lets just call this pilot - https://github.com/keploy/Ktest-Pilot |
I tried this, and its awesome! |
Related Issue
Closes: #1739, #1740, #1792, #1793, #1801
Linked PR: keploy/pilot#1, https://github.com/keploy/ebpf/pull/41
Describe the changes you've made
--enableTesting
flag, you can turn on the testing env of keploy.Approach
Keploy's test bench is built on the principle that Keploy can test itself, operating in two distinct modes:
RECORD
andTEST
. Each mode activates different sections of the codebase, with some overlap between the two. These modes can be executed concurrently to enhance testing efficiency.keployR
&keployT
are built from the same binary just the name is different for readability.For example, if you have recorded test cases and mocks for a Go + MongoDB application, the test bench allows you to run Keploy in test mode (keployT) from within Keploy in record mode (keployR) using the following pseudo command:
keployR record -c "keployT test -c ./gin-mongo-app"
. This command initiates Keploy in record mode, which in turn launches Keploy in test mode to run the application. As keployT executes the test sets, it simulates API calls for each test case. These simulated API calls are then recorded as test cases by keployR, along with any external calls from the application being captured as mocks. Meanwhile, keployT generates a final report of the test runs. This approach allows for the simultaneous execution of both Keploy's record and test flows.One significant benefit of this method is that it eliminates the need to set up external dependencies in the CI pipeline for testing. KeployT acts as a virtual database, with its calls being recorded by keployR, streamlining the testing process.
Caveats:
Steps to run:
Get this branch locally and build keploy using
go build -tags=viper_bind_struct -o keploy . && sudo mv keploy /usr/local/bin/keploy
Take any application, I've tested for the gin-mongo sample app so you can take that one as of now. And record test some cases, make at least two sessions of recording. Use cmd:
sudo -E env PATH=$PATH keploy record -c "./ginApp"
Recording of test cases via test-bench
sudo cp /usr/local/bin/keploy /usr/local/bin/keployr && sudo cp /usr/local/bin/keploy /usr/local/bin/keployt
sudo -E env PATH=$PATH keployr record -c "sudo -E env PATH=$PATH keployt test -c ./ginApp --proxyPort 56789 --dnsPort 46789 --delay=10 --testsets test-set-0 --enableTesting" --path "./test-bench/" --proxyPort=36789 --dnsPort 26789 --enableTesting
Tests and Mocks Assertion
sudo -E env PATH=$PATH keploy test -c "./ginApp" --path "./test-bench/"
go build -o pilot . && sudo mv pilot /usr/local/bin
pilot -test-assert -preRecPath ./ -testBenchPath ./test-bench
( you can also provide a config path to consider noisy parameters using-configPath ./
)pilot -mock-assert -preRecPath ./ -testBenchPath ./test-bench
Type of change
Please let us know if any test cases are added
Please describe the tests(if any). Provide instructions how its affecting the coverage.
Describe if there is any unusual behaviour of your code(Write
NA
if there isn't)NA
Checklist:
Screenshots (if any)