Skip to content

Commit

Permalink
Clean up testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPansino committed May 14, 2024
1 parent 1c2459d commit fd37506
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions tests/python/main.py
Original file line number Diff line number Diff line change
@@ -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 "<p>Hello, World!</p>"
5 changes: 2 additions & 3 deletions tests/python/test-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit fd37506

Please sign in to comment.