From 19e1a600fc7d5c598268756c4260320150aa3e04 Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Thu, 23 Jan 2025 15:05:14 -0800 Subject: [PATCH] Add check that initcontainer is attached by operator --- tests/Makefile | 2 ++ tests/dotnet/test-specs.yml | 1 + tests/java/test-specs.yml | 1 + tests/nodejs/test-specs.yml | 1 + tests/php/test-specs.yml | 1 + tests/python/test-specs.yml | 1 + tests/ruby/test-specs.yml | 1 + 7 files changed, 8 insertions(+) diff --git a/tests/Makefile b/tests/Makefile index ce85885a..6674d763 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -76,6 +76,8 @@ test: build-initcontainer build-testapp check-language-arg helm install test-deployment ${REPO_ROOT}/tests/${INITCONTAINER_LANGUAGE}/chart/ sleep 3 kubectl wait --for=condition=Ready -n default --all pods +# If jq is installed, check for the initcontainer to be visible on the pod spec + command -v jq && kubectl get pods --output json | jq '.items[].spec.initContainers | select( . != null )[].name' | grep -q "newrelic-instrumentation-" || $$(echo "Operator failed to attach initcontainer." >&2; exit 1) minikube service test-app-${INITCONTAINER_LANGUAGE}-service -n default # View test app container logs diff --git a/tests/dotnet/test-specs.yml b/tests/dotnet/test-specs.yml index b87f46f3..e3080324 100644 --- a/tests/dotnet/test-specs.yml +++ b/tests/dotnet/test-specs.yml @@ -6,6 +6,7 @@ scenarios: - helm install test-dotnet ./chart/ --set=scenarioTag="${SCENARIO_TAG}" -n default - sleep 5 - kubectl wait --for=condition=Ready -n default --all pods + - kubectl get pods --output json | jq '.items[].spec.initContainers | select( . != null )[].name' | grep -q "newrelic-instrumentation-" || $(echo "Operator failed to attach initcontainer." >&2; exit 1) - sleep 15 # give the agent time to connect - curl --fail-with-body $(minikube service test-app-dotnet-service --url -n default)/WeatherForecast tests: diff --git a/tests/java/test-specs.yml b/tests/java/test-specs.yml index 0911d801..a00e301f 100644 --- a/tests/java/test-specs.yml +++ b/tests/java/test-specs.yml @@ -6,6 +6,7 @@ scenarios: - helm install test-java ./chart/ --set=scenarioTag="${SCENARIO_TAG}" -n default - sleep 120 - kubectl wait --for=condition=Ready -n default --all pods + - kubectl get pods --output json | jq '.items[].spec.initContainers | select( . != null )[].name' | grep -q "newrelic-instrumentation-" || $(echo "Operator failed to attach initcontainer." >&2; exit 1) - curl --fail-with-body $(minikube service test-app-java-service --url -n default) tests: nrqls: diff --git a/tests/nodejs/test-specs.yml b/tests/nodejs/test-specs.yml index 146cf413..b9da39ef 100644 --- a/tests/nodejs/test-specs.yml +++ b/tests/nodejs/test-specs.yml @@ -6,6 +6,7 @@ scenarios: - helm install test-nodejs ./chart/ --set=scenarioTag="${SCENARIO_TAG}" -n default - sleep 5 - kubectl wait --for=condition=Ready -n default --all pods + - kubectl get pods --output json | jq '.items[].spec.initContainers | select( . != null )[].name' | grep -q "newrelic-instrumentation-" || $(echo "Operator failed to attach initcontainer." >&2; exit 1) - curl --fail-with-body $(minikube service test-app-nodejs-service --url -n default) tests: nrqls: diff --git a/tests/php/test-specs.yml b/tests/php/test-specs.yml index 697dcd4b..24bcd7cf 100644 --- a/tests/php/test-specs.yml +++ b/tests/php/test-specs.yml @@ -6,6 +6,7 @@ scenarios: - helm install test-php ./chart/ --set=scenarioTag="${SCENARIO_TAG}" ${TEST_APP_HELM_CHART_ARGS} -n default - sleep 5 - kubectl wait --for=condition=Ready -n default --all pods --timeout=2m + - kubectl get pods --output json | jq '.items[].spec.initContainers | select( . != null )[].name' | grep -q "newrelic-instrumentation-" || $(echo "Operator failed to attach initcontainer." >&2; exit 1) - curl --fail-with-body $(minikube service test-app-php-service --url -n default) - sleep 5 - curl --fail-with-body $(minikube service test-app-php-service --url -n default) diff --git a/tests/python/test-specs.yml b/tests/python/test-specs.yml index 25720cc5..f31c5646 100644 --- a/tests/python/test-specs.yml +++ b/tests/python/test-specs.yml @@ -6,6 +6,7 @@ scenarios: - helm install test-python ./chart/ --set=scenarioTag="${SCENARIO_TAG}" -n default - sleep 5 - kubectl wait --for=condition=Ready -n default --all pods --timeout=2m + - kubectl get pods --output json | jq '.items[].spec.initContainers | select( . != null )[].name' | grep -q "newrelic-instrumentation-" || $(echo "Operator failed to attach initcontainer." >&2; exit 1) - curl --fail-with-body $(minikube service test-app-python-service --url -n default) tests: nrqls: diff --git a/tests/ruby/test-specs.yml b/tests/ruby/test-specs.yml index d373e4a2..1e877c03 100644 --- a/tests/ruby/test-specs.yml +++ b/tests/ruby/test-specs.yml @@ -6,6 +6,7 @@ scenarios: - helm install test-ruby ./chart/ --set=scenarioTag="${SCENARIO_TAG}" -n default - sleep 5 - kubectl wait --for=condition=Ready -n default --all pods + - kubectl get pods --output json | jq '.items[].spec.initContainers | select( . != null )[].name' | grep -q "newrelic-instrumentation-" || $(echo "Operator failed to attach initcontainer." >&2; exit 1) - curl --fail-with-body $(minikube service test-app-ruby-service --url -n default)/ tests: nrqls: