diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 1a53c3f..f9c40df 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -72,17 +72,6 @@ jobs: run: | minikube image build -t e2e/test-app-${{ env.INITCONTAINER_LANGUAGE }}:e2e tests/${{ env.INITCONTAINER_LANGUAGE }}/ - - name: Deploy test app to minikube - run: | - kubectl apply -f tests/${{ env.INITCONTAINER_LANGUAGE }}/customresource.yaml -n default - kubectl apply -f tests/${{ env.INITCONTAINER_LANGUAGE }}/test_app_deployment.yaml -n default - sleep 5 - kubectl wait --for=condition=Ready -n default --all pods - - - name: Test - run: | - curl --fail-with-body $(minikube service test-app-${{ env.INITCONTAINER_LANGUAGE }}-service --url -n default) - - name: Run e2e-test uses: newrelic/newrelic-integration-e2e-action@a97ced80a4841c8c6261d1f9dca6706b1d89acb1 # 1.11.0 with: diff --git a/tests/python/chart/.helmignore b/tests/python/chart/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/tests/python/chart/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tests/python/chart/Chart.yaml b/tests/python/chart/Chart.yaml new file mode 100644 index 0000000..fd79f52 --- /dev/null +++ b/tests/python/chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: test-app-python +description: A Helm chart for Kubernetes +type: application +version: 1.0.0 +appVersion: "1.0.0" diff --git a/tests/python/test_app_deployment.yaml b/tests/python/chart/templates/deployment.yaml similarity index 90% rename from tests/python/test_app_deployment.yaml rename to tests/python/chart/templates/deployment.yaml index 4292b70..de62247 100644 --- a/tests/python/test_app_deployment.yaml +++ b/tests/python/chart/templates/deployment.yaml @@ -24,6 +24,8 @@ spec: env: - name: NEW_RELIC_APP_NAME value: k8s-e2e-test-app-python + - name: SCENARIO_TAG + value: {{ quote .Values.scenarioTag }} --- apiVersion: v1 kind: Service diff --git a/tests/python/customresource.yaml b/tests/python/chart/templates/instrumentation.yaml similarity index 100% rename from tests/python/customresource.yaml rename to tests/python/chart/templates/instrumentation.yaml diff --git a/tests/python/chart/values.yaml b/tests/python/chart/values.yaml new file mode 100644 index 0000000..44eb261 --- /dev/null +++ b/tests/python/chart/values.yaml @@ -0,0 +1 @@ +scenarioTag: "" \ No newline at end of file diff --git a/tests/python/main.py b/tests/python/main.py index b1def4a..9576fb4 100644 --- a/tests/python/main.py +++ b/tests/python/main.py @@ -1,3 +1,4 @@ +import os import sys import traceback @@ -9,9 +10,11 @@ @app.route("/") def hello_world(): try: - from newrelic.agent import current_transaction + from newrelic.agent import current_transaction, add_custom_attribute + assert current_transaction(), "No active transaction." + add_custom_attribute("testKey", os.getenv("NEW_RELIC_SCENARIO_TAG", "NOTSET")) except Exception: return "".join(traceback.format_exception(*sys.exc_info())), 417 - return "

Hello, World!

" + return f"Hello, World!" diff --git a/tests/python/test-specs.yml b/tests/python/test-specs.yml index c309a51..7bee2fc 100644 --- a/tests/python/test-specs.yml +++ b/tests/python/test-specs.yml @@ -4,6 +4,9 @@ description: | scenarios: - description: This scenario will verify that a transaction is reported by the test app after a curl request before: + - helm install test-python ./tests/python/chart/ --set=scenarioTag="${SCENARIO_TAG}" -n default + - sleep 5 + - kubectl wait --for=condition=Ready -n default --all pods - curl --fail-with-body $(minikube service test-app-python-service --url -n default) tests: nrqls: