diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index a6457cc61..9e743da31 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -40,32 +40,22 @@ jobs: version: v3.11.3 - name: Package helm chart - run: | + run: | helm dependency build ./chart helm package ./chart --version 1.0.0 - name: Install helm chart - run: 'helm install canary-checker canary-checker-1.0.0.tgz -n canary-checker --create-namespace' + run: "helm install canary-checker canary-checker-1.0.0.tgz -n canary-checker --create-namespace" - name: Wait for 30 seconds - run: 'kubectl rollout status deploy/canary-checker -n canary-checker --timeout 5m' + run: "kubectl rollout status deploy/canary-checker -n canary-checker --timeout 5m" - name: Check canary-checker pods - run: 'kubectl describe pods -n canary-checker' - - - name: Apply exec fixture - run: 'kubectl apply -f fixtures/minimal/exec_pass.yaml' + run: "kubectl describe pods -n canary-checker" - - name: Wait for 60 seconds - run: 'sleep 60' + - name: Run tests + run: ./chart/test.sh canary-checker - - name: Check status - run: | - kubectl logs deploy/canary-checker -n canary-checker - status=$(kubectl get canaries.canaries.flanksource.com exec-pass -o yaml | yq .status.status) - echo $status - if [[ $status == "Passed" ]]; then - exit 0 - else - exit 1 - fi + - name: Check logs + run: kubectl logs deploy/canary-checker -n canary-checker + if: always() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc2f42d93..743285d34 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: if [[ ${{ github.event_name == 'workflow_dispatch' }} == true ]]; then if [[ "${{ inputs.channel }}" == "stable" ]]; then BRANCHES="['master']" - else if [[ "${{ inputs.channel }}" == "rc" ]]; then + elif [[ "${{ inputs.channel }}" == "rc" ]]; then BRANCHES="[{name: 'master', channel: 'rc', prerelease: 'rc'}, {name: 'dummy-release'}]" fi else diff --git a/chart/test.sh b/chart/test.sh new file mode 100755 index 000000000..ab84469a7 --- /dev/null +++ b/chart/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +ns="-n $1" + +kubectl apply -f fixtures/minimal/exec_pass.yaml $ns + +function get_unused_port() { + for port in $(seq 4444 65000); + do + echo -ne "\035" | telnet 127.0.0.1 $port > /dev/null 2>&1; + [ $? -eq 1 ] && echo "$port" && break; + done +} + + +PORT=$(get_unused_port) +kubectl port-forward $ns svc/canary-checker $PORT:8080 & +PID=$! +function cleanup { + echo "Cleaning up..." + kill $PID +} + +trap cleanup EXIT + +sleep 60 + +status=$(kubectl get $ns canaries.canaries.flanksource.com exec-pass -o yaml | yq .status.status) +echo $status +if [[ $status != "Passed" ]]; then + exit 1 +fi + +if ! curl -vv --fail "http://localhost:$PORT/db/checks"; then + # "we don't really care about the results as long as it is sucessful" + echo "Call to postgrest failed" + exit 1 +fi + +