Skip to content

Commit 067e7e4

Browse files
committed
ci(build): add oha zero-downtime rolling update test
1 parent 5d351e9 commit 067e7e4

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

.github/workflows/docker.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
run: |
3737
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml > /dev/null
3838
kubectl wait -n ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=120s > /dev/null
39+
kubectl patch configmap -n ingress-nginx ingress-nginx-controller --type merge -p '{"data":{"upstream-keepalive-timeout":"5"}}' > /dev/null
3940
4041
- name: Load image into kind
4142
run: kind load docker-image k8s-httpcache:test --name test -q
@@ -48,10 +49,12 @@ jobs:
4849
kubectl rollout status deployment/nodejs --timeout=120s > /dev/null
4950
kubectl rollout status deployment/k8s-httpcache --timeout=120s > /dev/null
5051
51-
- name: Install hurl
52+
- name: Install tools
5253
run: |
5354
curl -sfL -O https://github.com/Orange-OpenSource/hurl/releases/download/7.1.0/hurl_7.1.0_amd64.deb
5455
sudo apt-get install -yqq ./hurl_7.1.0_amd64.deb > /dev/null
56+
curl -sfL -o /usr/local/bin/oha https://github.com/hatoo/oha/releases/download/v1.13.0/oha-linux-amd64
57+
chmod +x /usr/local/bin/oha
5558
5659
- name: Smoke test
5760
run: |
@@ -61,6 +64,28 @@ jobs:
6164
done
6265
hurl --test .github/test/smoke.hurl
6366
67+
- name: Zero-downtime rollout restart
68+
run: |
69+
oha -c 5 -q 10 -z 180s --no-tui --output-format json http://localhost:8080/nodejs/ > /tmp/oha.json 2>/dev/null &
70+
OHA_PID=$!
71+
sleep 3
72+
kubectl rollout restart deployment/k8s-httpcache
73+
kubectl rollout status deployment/k8s-httpcache --timeout=120s > /dev/null
74+
while kubectl get pods -l app=k8s-httpcache | grep -q Terminating; do sleep 1; done
75+
kill -INT $OHA_PID
76+
wait $OHA_PID || true
77+
echo "Status code distribution:"
78+
jq '.statusCodeDistribution' /tmp/oha.json
79+
echo "Error distribution:"
80+
jq '.errorDistribution' /tmp/oha.json
81+
non200=$(jq '[.statusCodeDistribution | to_entries[] | select(.key != "200") | .value] | add // 0' /tmp/oha.json)
82+
errors=$(jq '[.errorDistribution | to_entries[] | .value] | add // 0' /tmp/oha.json)
83+
if [ "$non200" -gt 0 ] || [ "$errors" -gt 0 ]; then
84+
echo "FAIL: $non200 non-200 responses, $errors connection errors"
85+
exit 1
86+
fi
87+
echo "PASS: all requests returned 200 with no errors"
88+
6489
- name: Show pod status on failure
6590
if: failure()
6691
run: |

0 commit comments

Comments
 (0)