End To End local integration test
Camel K has a suite of integration test that will run on every Pull Request. You can contribute by adding an integration test to cover any new feature introduced (or increment the coverage with features still untested).
Since both unit test and integration test names end with
_test.go, both would be executed by go during the build, so you need to put a special build tag to mark integration tests. An integration test should start with the following line:
// +build integration
Look into the /e2e directory for examples of integration tests.
Before running an integration test, you need to be connected to a Kubernetes/OpenShift namespace. After you log in into your cluster, you can run the following command to execute all integration tests:
The test script will take care to install the operators needed in a random namespace, execute all expected tests and clean themselves. Cleaning may not be performed if the execution of tests fails or the test process is interrupted. In that case you can look for any namespace similar to
test-29ed8147-c9fc-4c04-9c29-744eaf4750c6 and remove manually.
You probably want to test your changes on camel-k
operator locally after some development. You will need to make the operator docker image available to your cluster registry before launching the tests. We have a script that will take care of that.
First, you must connect and point to the
docker daemon. If you’re on a local environment such as
minikube, it will be as simple as executing
eval $(minikube -p minikube docker-env)
For other cluster types you may check the specific documentation. As soon as you’re connected to the
docker daemon you can build images via:
The script will take care to build the operator docker image and push to the underlying docker daemon registry. At this stage, the cluster will be able to pickup this latest image when it executes the tests.
You can also execute the following script, if by any chance you have some change applied to the
To speed up integration testing locally, you may use a Nexus Repository Manager for Maven repository mirror.
You can set the environment variable
TEST_ENABLE_NEXUS=true to enable the usage of Nexus mirror in e2e testing. If
TEST_ENABLE_NEXUS is set, e2e tests will try to discover an Nexus instance as
nexus service in
nexus namespace and if it is found they will use it as the Maven repository mirror for the
camel-k platform under test.
TEST_ENABLE_NEXUS=true make test-integration
To set up a Nexus instance in your cluster, run the following command:
kubectl apply -f e2e/support/files/nexus.yaml