Skip to content

Commit 9dde9f8

Browse files
committed
[test][fix] add retry logic for flaky e2e test
Replace fixed 5s sleep in UDP Stickiness test with retry loop that checks stickiness update up to 12 times with 10s intervals, exiting early on success or timing out with error message
1 parent 902883d commit 9dde9f8

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

e2e/test/lb-with-udp-ports-stickiness/chainsaw-test.yaml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,28 @@ spec:
4747
echo "Nodebalancer config found, updating config stickiness"
4848
4949
kubectl annotate --overwrite svc svc-test -n $NAMESPACE service.beta.kubernetes.io/linode-loadbalancer-default-stickiness=source_ip
50-
sleep 5s
51-
52-
echo "Verifying that stickiness is set to source_ip"
53-
nbconfig=$(LINODE_TOKEN=$LINODE_TOKEN NBID=$nbid ../scripts/get-nb-config.sh)
54-
stickiness=$(echo $nbconfig | jq -r '.stickiness')
55-
echo "stickiness is $stickiness"
50+
51+
echo "Waiting for stickiness to be updated to source_ip..."
52+
max_attempts=12
53+
for i in $(seq 1 $max_attempts); do
54+
echo "Attempt $i/$max_attempts: Checking stickiness..."
55+
nbconfig=$(LINODE_TOKEN=$LINODE_TOKEN NBID=$nbid ../scripts/get-nb-config.sh)
56+
stickiness=$(echo $nbconfig | jq -r '.stickiness')
57+
echo "Current stickiness: $stickiness"
58+
59+
if [[ "$stickiness" == "source_ip" ]]; then
60+
echo "Stickiness successfully updated to source_ip"
61+
break
62+
fi
63+
64+
if [[ $i -eq $max_attempts ]]; then
65+
echo "Timeout: Stickiness was not updated to source_ip after $max_attempts attempts"
66+
exit 1
67+
fi
68+
69+
echo "Waiting 10 seconds before next check..."
70+
sleep 10
71+
done
5672
check:
5773
($error == null): true
58-
(contains($stdout, 'stickiness is source_ip')): true
74+
(contains($stdout, 'Stickiness successfully updated to source_ip')): true

0 commit comments

Comments
 (0)