Skip to content

Commit e8f5397

Browse files
committed
fix e2e test, separate script
1 parent 52d8585 commit e8f5397

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

.github/workflows/e2e.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ jobs:
7272
run: kind load docker-image test/k8s-pause:latest
7373
- name: Deploy controller
7474
run: make deploy IMG=test/k8s-pause:latest
75-
- uses: azure/setup-kubectl@v2.0
76-
id: install
7775
- name: Setup podinfo
7876
env:
7977
PODINFO_VER: ${{ '6.0.3' }}
@@ -85,13 +83,7 @@ jobs:
8583
--namespace podinfo \
8684
--set replicaCount=2
8785
- name: Run k8s-pause tests
88-
run: |
89-
kubectl version
90-
kubectl annotate ns podinfo k8s-pause/suspend=true --overwrite
91-
kubectl wait -n podinfo --timeout=2m --for=jsonpath='{.status.phase}'=Suspended pods --all
92-
93-
kubectl annotate ns podinfo k8s-pause/suspend=false --overwrite
94-
kubectl wait -n podinfo --timeout=2m --for=jsonpath='{.status.phase}'=Running pods --all
86+
run: bash scripts/e2e-tests.sh
9587
- name: Logs
9688
run: |
9789
kubectl -n k8s-pause-system logs deploy/k8s-pause

scripts/e2e-test.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
timeout=60
3+
4+
kubectl annotate ns podinfo k8s-pause/suspend=true --overwrite
5+
used=0
6+
7+
while true; do
8+
countTotal=$(kubectl -n podinfo get pods | grep podinfo | wc -l)
9+
countSuspended=$(kubectl -n podinfo get pods | grep Suspended | wc -l)
10+
11+
if [[ "$countTotal" == "$countSuspended" ]]; then
12+
break;
13+
fi
14+
15+
if [[ $used -gt $timeout ]]; then
16+
echo "Unable to suspend pods"
17+
exit 1
18+
fi
19+
20+
used=$((used + 2))
21+
sleep 2
22+
done
23+
24+
kubectl annotate ns podinfo k8s-pause/suspend=false --overwrite
25+
used=0
26+
27+
while true; do
28+
countTotal=$(kubectl -n podinfo get pods | grep podinfo | wc -l)
29+
countRunning=$(kubectl -n podinfo get pods | grep Running | wc -l)
30+
31+
if [[ "$countTotal" == "$countRunning" ]]; then
32+
break;
33+
fi
34+
35+
if [[ $used -gt $timeout ]]; then
36+
echo "Unable to resume pods"
37+
exit 1
38+
fi
39+
40+
used=$((used + 2))
41+
sleep 2
42+
done

0 commit comments

Comments
 (0)