Skip to content

Commit

Permalink
chore: add postgrest test
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Sep 15, 2024
1 parent 07ddb95 commit 6a65d4b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
28 changes: 9 additions & 19 deletions .github/workflows/helm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions chart/test.sh
Original file line number Diff line number Diff line change
@@ -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


0 comments on commit 6a65d4b

Please sign in to comment.