diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index bb4b559..255920d 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -52,40 +52,36 @@ jobs: - name: Deploy cert-manager to minikube run: | - kubectl create namespace cert-manager - kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.5/cert-manager.yaml + helm repo add jetstack https://charts.jetstack.io --force-update + helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --version v1.14.5 --set installCRDs=true sleep 5 - kubectl wait --for=condition=Ready --namespace cert-manager --all pods + kubectl wait --for=condition=Ready -n cert-manager --all pods - name: Deploy New Relic k8s-agents-operator to minikube run: | helm repo add k8s-agents-operator https://newrelic.github.io/k8s-agents-operator - helm upgrade --install k8s-agents-operator k8s-agents-operator/k8s-agents-operator --namespace k8s-agents-operator --create-namespace + helm upgrade --install k8s-agents-operator k8s-agents-operator/k8s-agents-operator --namespace=default --set=licenseKey=$NEW_RELIC_LICENSE_KEY sleep 5 - kubectl wait --for=condition=Ready --namespace k8s-agents-operator --all pods + kubectl wait --for=condition=Ready -n default --all pods - name: Build init container run: | - docker build -t e2e/initcontainer-${{ env.INITCONTAINER_LANGUAGE }}:e2e ${{ env.INITCONTAINER_LANGUAGE }}/ - minikube image load e2e/initcontainer-${{ env.INITCONTAINER_LANGUAGE }}:e2e + minikube image build -t e2e/initcontainer-${{ env.INITCONTAINER_LANGUAGE }}:e2e ${{ env.INITCONTAINER_LANGUAGE }}/ - name: Build test app container run: | - docker build -t e2e/test-app-${{ env.INITCONTAINER_LANGUAGE }}:e2e tests/${{ env.INITCONTAINER_LANGUAGE }}/ - minikube image load e2e/test-app-${{ env.INITCONTAINER_LANGUAGE }}:e2e + minikube image build -t e2e/test-app-${{ env.INITCONTAINER_LANGUAGE }}:e2e tests/${{ env.INITCONTAINER_LANGUAGE }}/ - name: Deploy test app to minikube run: | - kubectl create namespace test-${{ env.INITCONTAINER_LANGUAGE }} - kubectl create secret generic newrelic-key-secret -n test-python --from-literal=new_relic_license_key=$NEW_RELIC_LICENSE_KEY - kubectl apply -f tests/${{ env.INITCONTAINER_LANGUAGE }}/customresource.yaml -n test-${{ env.INITCONTAINER_LANGUAGE }} - kubectl apply -f tests/${{ env.INITCONTAINER_LANGUAGE }}/test_app_deployment.yaml -n test-${{ env.INITCONTAINER_LANGUAGE }} + 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 --namespace test-${{ env.INITCONTAINER_LANGUAGE }} --all pods - name: Test run: | - curl --fail-with-body $(minikube service test-app-${{ env.INITCONTAINER_LANGUAGE }}-service --url -n test-${{ env.INITCONTAINER_LANGUAGE }}) + 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 diff --git a/tests/python/main.py b/tests/python/main.py index bbfcc93..ed08900 100644 --- a/tests/python/main.py +++ b/tests/python/main.py @@ -1,10 +1,17 @@ +import sys +import traceback + from flask import Flask app = Flask(__name__) + @app.route("/") def hello_world(): - from newrelic.agent import current_transaction - assert current_transaction(), "No active transaction." - + try: + from newrelic.agent import current_transaction + assert current_transaction(), "No active transaction." + except Exception: + return traceback.format_exception(*sys.exc_info()), 417 + return "

Hello, World!

" diff --git a/tests/python/test-specs.yml b/tests/python/test-specs.yml index c0a10bd..9787790 100644 --- a/tests/python/test-specs.yml +++ b/tests/python/test-specs.yml @@ -2,10 +2,9 @@ description: | End-to-end tests for python initcontainer scenarios: - - description: | - This scenario will verify that transactions are reported by the + - description: This scenario will verify that a transaction is reported by the test app after a curl request before: - - curl --fail-with-body $(minikube service test-app-python-service --url -n test-python) + - curl --fail-with-body $(minikube service test-app-python-service --url -n default) tests: nrqls: - query: FROM Transaction SELECT latest(something) AS 'start_time' WHERE appName = 'k8s-e2e-test-app-python'