As of now there is only one ways to use Keploy eBPF in MacOS, i.e. Natively using Colima.
There are two ways to install Keploy eBPF in MacOS, you can use either use:
One click install Keploy.
curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
You need to have the latest version of
brew installed on your system and then run this command from a terminal:
brew install colima
Start Colima with defaults
We need to create a custom network for Keploy since we are using the Docker, therefore application container would require
docker network to act as the bridge between them.
If you're using a docker-compose network, replace
keploy-network with your app's
docker network create keploy-network
Then, create an alias for Keploy:
alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --network keploy-network --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/keploy/keploy'
Recording Testcases and Data Mocks
Here are few points to consider before recording!
If you're running via docker compose, ensure to include the
<CONTAINER_NAME>under your application service in the docker-compose.yaml file like this.
Change the network name (
keploy-networkto your custom network if you changed it above.
Docker_CMD_to_run_user_containerrefers to the Docker command for launching the application.
Utilize the keploy alias we created to capture testcases. Execute the following command within your application's root directory.
keploy record -c "docker run -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <applicationImage>" --containerName "<containerName>" --delay 10
Keploy will capture the API calls you've conducted, generating test suites comprising testcases (KTests) and data mocks (KMocks) in
Now, use the keployV2 Alias we created to execute the testcases. Follow these steps in the root directory of your application.
When using docker-compose to start the application, it's important to ensure that the
--containerName parameter matches the container name in your
keploy test -c "docker run -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <applicationImage>" --containerName "<containerName>" --delay 20
Voilà! 🧑🏻💻 We have the tests with data mocks running! 🐰🎉
You'll be able to see the test-cases that ran with the results report on the console as well locally in the
delayis required while using Test Mode.
- containerName is optional if you are using
Docker runcommand, as the Container name would be present within the command itself.