From e5e2364b48433a6d0b2a7f93dc995f094c34d2e6 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 21 Jan 2020 12:57:05 -0800 Subject: [PATCH] added smoke tests workflow --- .github/workflows/smoke-tests.yml | 104 ++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 .github/workflows/smoke-tests.yml diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml new file mode 100644 index 0000000..9c97a48 --- /dev/null +++ b/.github/workflows/smoke-tests.yml @@ -0,0 +1,104 @@ +name: "System Smoke Tests" +on: + push: + # run on pushes to master or release/* + branches: + - master + - release/* + pull_request: + # run on pull requests targeting master + branches: + - master +jobs: + setup: + runs-on: self-hosted + steps: + - name: Check Test Cluster + run: | + if kubectl get nodes; then + kubectl get nodes + else + echo "test cluster not active. Attempting to create through kind..." + kind create cluster + kubectl get nodes + fi + test-source: + runs-on: self-hosted + needs: setup + steps: + - uses: actions/checkout@v2 + - name: Clean Cluster + run: | + kubectl delete all --all --wait=true --force --grace-period=0 + sleep 5 + - name: Deploy From Source + run: | + skaffold run + - name: Wait For Pods + run: | + sleep 60 + kubectl get pods + echo waiting for ready state... + kubectl wait --for=condition=ready pod -l app=adservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=cartservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=checkoutservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=currencyservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=emailservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=frontend --timeout=500s + kubectl wait --for=condition=ready pod -l app=loadgenerator --timeout=500s + kubectl wait --for=condition=ready pod -l app=paymentservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=productcatalogservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=recommendationservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=shippingservice --timeout=500s + - name: Test HTTP + timeout-minutes: 5 + run: | + RESULT=" " + while [[ "$RESULT" != " HTTP/1.1 200 OK" ]]; do + sleep 1 + RESULT=$(kubectl exec deployments/frontend -- sh -c "wget --spider -S "http://frontend" 2>&1 | grep 'HTTP/'") + echo "front end response: $RESULT" + done + if [[ "$RESULT" != " HTTP/1.1 200 OK" ]]; then + exit 1 + fi + test-release: + runs-on: self-hosted + needs: [setup, test-source] + steps: + - uses: actions/checkout@v2 + - name: Clean Cluster + run: | + kubectl delete all --all --wait=true --force --grace-period=0 + sleep 5 + - name: Deploy Release Manifests + run: | + kubectl apply -f ./release/kubernetes-manifests.yaml + - name: Wait For Pods + run: | + sleep 60 + kubectl get pods + echo waiting for ready state... + kubectl wait --for=condition=ready pod -l app=adservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=cartservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=checkoutservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=currencyservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=emailservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=frontend --timeout=500s + kubectl wait --for=condition=ready pod -l app=loadgenerator --timeout=500s + kubectl wait --for=condition=ready pod -l app=paymentservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=productcatalogservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=recommendationservice --timeout=500s + kubectl wait --for=condition=ready pod -l app=shippingservice --timeout=500s + - name: Test HTTP + timeout-minutes: 5 + run: | + RESULT=" " + while [[ "$RESULT" != " HTTP/1.1 200 OK" ]]; do + sleep 1 + RESULT=$(kubectl exec deployments/frontend -- sh -c "wget --spider -S "http://frontend" 2>&1 | grep 'HTTP/'") + echo "front end response: $RESULT" + done + if [[ "$RESULT" != " HTTP/1.1 200 OK" ]]; then + exit 1 + fi