Skip to content

Latest commit

 

History

History
71 lines (57 loc) · 3.56 KB

README.md

File metadata and controls

71 lines (57 loc) · 3.56 KB

E2E tests

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.

Automated local tests in Minikube cluster

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

Please note that the script expects a New Relic account in the production environment.

Personalized tests

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

Note 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:e2e

Then, include helm needed repositories.

helm repo add nri-kube-events https://newrelic.github.io/nri-kube-events
helm repo update

You 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@latest

You 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=xxx

Since 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"

Notes specific to staging environment

In order to enable testing against staging environment, the following modifications need to be made:

  • Open the the ./test-specs.yml and add --set global.nrStaging=true to 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.