You can run E2E tests on any cluster, please notice that scraping the control plane could be not possible or needing specific values depending on the flavour.
In order to run E2E tests locally, you can use e2e-tests.sh. To get help on usage, call the script with the --help flag:
./e2e-tests.sh --helpPlease note that the script expects a New Relic account in the production environment.
Sometimes you may need extra flexibility on how to run tests. While the following description uses Minikube as an example, you can personalize the example as needed to use the cluster of your choosing, or to run tests in the staging environment.
Initialize a test cluster.
minikube start --container-runtime=containerd --kubernetes-version=v1.XX.X
minikube addons enable metrics-serverNote that the control plane flags in e2e-values.yml have been set meeting the minikube specifications.
Then you need to build and load the image:
docker buildx build --load . --tag e2e/nri-kube-events:e2e
minikube image load e2e/nri-kube-events:e2eThen, include helm needed repositories.
helm repo add nri-kube-events https://newrelic.github.io/nri-kube-events
helm repo updateYou need to install the binary https://github.com/newrelic/newrelic-integration-e2e-action/tree/main/newrelic-integration-e2e used in the e2e test
go install github.com/newrelic/newrelic-integration-e2e-action@latestYou need New Relic's LICENSE_KEY (Ingest - License), API_KEY (User key) and ACCOUNT_ID before running the tests. More information on how to find these keys, please see this.
Set the following environment variables:
export EXCEPTIONS_SOURCE_FILE="*-exceptions.yml"
export LICENSE_KEY=xxx
export API_KEY=xxx
export ACCOUNT_ID=xxxSince some metrics are removed and added depending on the k8s version, the EXCEPTIONS_SOURCE_FILE should point, depending on the k8s version you are testing on, to one of the *-exceptions.yml files.
Run the following command to execute the test and make sure that it is ran at the root of the repo:
EXCEPTIONS_SOURCE_FILE=${EXCEPTIONS_SOURCE_FILE} LICENSE_KEY=${LICENSE_KEY} go run github.com/newrelic/newrelic-integration-e2e-action@latest \
--commit_sha=test-string --retry_attempts=5 --retry_seconds=60 \
--account_id=${ACCOUNT_ID} --api_key=${API_KEY} --license_key=${LICENSE_KEY} \
--spec_path=test-specs.yml --verbose_mode=true --agent_enabled="false"In order to enable testing against staging environment, the following modifications need to be made:
- Open the the
./test-specs.ymland add--set global.nrStaging=trueto the end of all occurrences of this line- helm upgrade --install ${SCENARIO_TAG} --namespace nr-${SCENARIO_TAG} --create-namespace ../charts/newrelic-infrastructure .... - Add and set
--region="Staging"the command that executes the tests. For example:
EXCEPTIONS_SOURCE_FILE=${EXCEPTIONS_SOURCE_FILE} LICENSE_KEY=${LICENSE_KEY} go run github.com/newrelic/newrelic-integration-e2e-action@latest \
--commit_sha=test-string --retry_attempts=5 --retry_seconds=60 \
--account_id=${ACCOUNT_ID} --api_key=${API_KEY} --license_key=${LICENSE_KEY} \
--spec_path=test-specs.yml --verbose_mode=true --agent_enabled="false" --region="Staging"You may check e2e workflow to have more details about how this is used in development workflow.