Skip to content

Commit da2a0de

Browse files
maxime-leroychristophefontaine
authored andcommitted
smoke: make nexthop ageing test more robust on slow machines
The nexthop ageing smoke test could fail intermittently on slow or heavily loaded machines, where state transitions (like nexthop reachability or ageing) take slightly longer than expected. This patch introduces a check_nexthop() helper that polls grcli show ip nexthop for up to 5 seconds, instead of assuming an immediate state change. This ensures that the test is tolerant to minor delays without compromising on correctness. Signed-off-by: Maxime Leroy <[email protected]>
1 parent 0087baa commit da2a0de

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

smoke/nexthop_ageing_test.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@
44

55
. $(dirname $0)/_init.sh
66

7+
check_nexthop() {
8+
local ip="$1"
9+
local expect_reacheable="$2"
10+
local timeout=5
11+
for i in $(seq 1 $timeout); do
12+
grcli show ip nexthop | grep -qE "$ip.+reachable";
13+
local result=$?
14+
15+
if [ "$expect_reacheable" = "true" ] && [ "$result" -eq 0 ]; then
16+
return 0
17+
fi
18+
if [ "$expect_reacheable" = "false" ] && [ "$result" -ne 0 ]; then
19+
return 0
20+
fi
21+
22+
sleep 1
23+
done
24+
25+
return 1
26+
}
27+
728
p0=${run_id}0
829
p1=${run_id}1
930

@@ -38,8 +59,9 @@ show ip address
3859
EOF
3960

4061
# ensure that nexthops are still reachable
41-
grcli show ip nexthop | grep -E '172\.16\.0\.2.+reachable' || fail "nexthop should be reachable"
42-
grcli show ip nexthop | grep -E '172\.16\.1\.2.+reachable' || fail "nexthop should be reachable"
62+
check_nexthop '172\.16\.0\.2' true || fail "nexthop 172.16.0.2 should be reachable"
63+
check_nexthop '172\.16\.1\.2' true || fail "nexthop 172.16.1.2 should be reachable"
64+
4365
# ensure addresses were not destroyed
4466
grcli show ip address | grep -E "^$p0[[:space:]]+172\\.16\\.0\\.1/24$" || fail "addresses were destroyed"
4567
grcli show ip address | grep -E "^$p1[[:space:]]+172\\.16\\.1\\.1/24$" || fail "addresses were destroyed"
@@ -52,8 +74,9 @@ ip -n $p1 link set $p1 down
5274
sleep 3
5375

5476
# ensure that nexthops have been aged out and destroyed
55-
! grcli show ip nexthop | grep -q '172\.16\.0\.2.*reachable' || fail "nexthop should be destroyed"
56-
! grcli show ip nexthop | grep -q '172\.16\.1\.2.*reachable' || fail "nexthop should be destroyed"
77+
check_nexthop '172\.16\.0\.2' false || fail "nexthop 172.16.0.2 should be destroyed"
78+
check_nexthop '172\.16\.1\.2' false || fail "nexthop 172.16.1.2 should be destroyed"
79+
5780
# ensure addresses were not destroyed
5881
grcli show ip address | grep -E "^$p0[[:space:]]+172\\.16\\.0\\.1/24$" || fail "addresses were destroyed"
5982
grcli show ip address | grep -E "^$p1[[:space:]]+172\\.16\\.1\\.1/24$" || fail "addresses were destroyed"

0 commit comments

Comments
 (0)