= 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:

[source]
----
//go:build integration
// +build integration
----

Look into the https://github.com/apache/camel-k/tree/main/e2e[/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 into your cluster, you can run the following command to execute **all** integration tests:

[source]
----
make test-integration
----

The test script will 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 it manually.

[[testing-operator]]
== Testing Operator under development

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 which 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

[source]
----
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:

[source]
----
make images
----

The script will build the operator docker image and push it 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 `camel-k-runtime`. You can optionally point to your local Camel K runtime project directory if you need to install any SNAPSHOT dependency:

[source]
----
make images-dev [CAMEL_K_RUNTIME_DIR=/path/to/camel-k-runtime-project]
----

[[using-nexus]]
== Using Nexus repository mirror with E2E testing

To speed up integration testing locally, you may use a https://github.com/sonatype/docker-nexus3[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 a 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.

[source]
----
TEST_ENABLE_NEXUS=true make test-integration
----

To set up a Nexus instance in your cluster, run the following command:
[source]
----
kubectl apply -f e2e/support/files/nexus.yaml
----
