Skip to contentSkip to conversation

tests: shell: Fix packetpath/meta_time on slow systems

PATCH In review Phil Sutter 1 participant 3 messages Oct 29 – Oct 30 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/2 tests: shell: Fix packetpath/meta_time on slow systems

A system so slow that the whole shell test suite run takes 20min fails this test, probably because the last non-matching rule's range starting 10s ahead is not sufficient. Move that time range into the past, so the test may take up to 2min to complete and still pass.

Fixes b5145809b1bb8 ("tests: shell: add packetpath test for meta time expression.")
---
 tests/shell/testcases/packetpath/meta_time | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/shell/testcases/packetpath/meta_time +1 -1
index 67b37f4e1073c..9bddccbd80cee 100755
@@ -40,7 +40,7 @@ gen_in_range_time()
 
 gen_out_of_range_time()
 {
-	echo \"$(date -d "+10 seconds" +%G-%m-%d" "%H:%M:%S)\"-\"$(date -d "+20 seconds" +%G-%m-%d" "%H:%M:%S)\"
+	echo \"$(date -d "-20 seconds" +%G-%m-%d" "%H:%M:%S)\"-\"$(date -d "-10 seconds" +%G-%m-%d" "%H:%M:%S)\"
 }
 
 $NFT -f - <<-EOF
Signature · 1 line
2.54.0
author reviewer
#1 lore raw

PATCH 2/2 tests: shell: Really stabilize packetpath/payload

The test occasionally fails here with zero packets in output counters when testing bridge family. While it's not entirely clear why it happens, racing with bridge forward delay and IPv6 duplicate address detection seem to be a good guess.

With both deactivated, the test passes reliably even with the 3s sleep removed and TCP connect timeout minimized (all we need for the test is one ping^Wsyn only).

Fixes a1365628eaa73 ("tests: shell: stabilize packetpath/payload")
---
 tests/shell/testcases/packetpath/payload | 38 +++++++++++-------------
 1 file changed, 18 insertions(+), 20 deletions(-)
tests/shell/testcases/packetpath/payload +18 -20
index 1e6b5a51969bb..7c1fd43b1a486 100755
@@ -47,9 +47,11 @@ run_test()
 	if [ $1 -eq 6 ]; then
 		nsx1_addr="["$ns1_addr"]"
 		nsx2_addr="["$ns2_addr"]"
+		addropt="nodad"
 	else
 		nsx1_addr="$ns1_addr"
 		nsx2_addr="$ns2_addr"
+		addropt=
 	fi
 
 	ip netns add "$ns1" || exit 111
@@ -62,10 +64,8 @@ run_test()
 
 	ip -net "$ns1" link set veth0 up
 	ip -net "$ns2" link set veth0 up
-	ip -net "$ns1" addr add $ns1_addr/$cidr dev veth0
-	ip -net "$ns2" addr add $ns2_addr/$cidr dev veth0
-
-	sleep 3
+	ip -net "$ns1" addr add $ns1_addr/$cidr $addropt dev veth0
+	ip -net "$ns2" addr add $ns2_addr/$cidr $addropt dev veth0
 
 RULESET="table netdev payload_netdev {
        counter ingress {}
@@ -121,17 +121,17 @@ table inet payload_inet {
 
 	case $l4proto in
 	"tcp")
-		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8887,connect-timeout=4 < /dev/null > /dev/null
-		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8888,connect-timeout=4 < /dev/null > /dev/null
+		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8887,connect-timeout=0.1 < /dev/null > /dev/null
+		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8888,connect-timeout=0.1 < /dev/null > /dev/null
 
-		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8880,connect-timeout=4 < /dev/null > /dev/null
-		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8881,connect-timeout=4 < /dev/null > /dev/null
+		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8880,connect-timeout=0.1 < /dev/null > /dev/null
+		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8881,connect-timeout=0.1 < /dev/null > /dev/null
 
-		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7777,connect-timeout=4 < /dev/null > /dev/null
-		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7778,connect-timeout=4 < /dev/null > /dev/null
+		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7777,connect-timeout=0.1 < /dev/null > /dev/null
+		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7778,connect-timeout=0.1 < /dev/null > /dev/null
 
-		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7770,connect-timeout=4 < /dev/null > /dev/null
-		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7771,connect-timeout=4 < /dev/null > /dev/null
+		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7770,connect-timeout=0.1 < /dev/null > /dev/null
+		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7771,connect-timeout=0.1 < /dev/null > /dev/null
 		;;
 	"udp")
 		ip netns exec "$ns1" bash -c "echo 'AA' | socat -u STDIN UDP:$nsx2_addr:8887 > /dev/null"
@@ -176,13 +176,11 @@ table inet payload_inet {
 
 	ip -net "$ns1" addr del $ns1_addr/$cidr dev veth0
 
-	ip -net "$ns1" link add name br0 type bridge
+	ip -net "$ns1" link add name br0 type bridge forward_delay 0 stp_state 0
 	ip -net "$ns1" link set veth0 master br0
-	ip -net "$ns1" addr add $ns1_addr/$cidr dev br0
+	ip -net "$ns1" addr add $ns1_addr/$cidr $addropt dev br0
 	ip -net "$ns1" link set up dev br0
 
-	sleep 3
-
 RULESET="table bridge payload_bridge {
        counter input {}
        counter output {}
@@ -212,11 +210,11 @@ RULESET="table bridge payload_bridge {
 
 	case $l4proto in
 	"tcp")
-		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8880,connect-timeout=4 < /dev/null > /dev/null
-		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8881,connect-timeout=4 < /dev/null > /dev/null
+		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8880,connect-timeout=0.1 < /dev/null > /dev/null
+		ip netns exec "$ns1" socat -u STDIN TCP:$nsx2_addr:8881,connect-timeout=0.1 < /dev/null > /dev/null
 
-		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7770,connect-timeout=4 < /dev/null > /dev/null
-		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7771,connect-timeout=4 < /dev/null > /dev/null
+		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7770,connect-timeout=0.1 < /dev/null > /dev/null
+		ip netns exec "$ns2" socat -u STDIN TCP:$nsx1_addr:7771,connect-timeout=0.1 < /dev/null > /dev/null
 		;;
 	"udp")
 		ip netns exec "$ns1" bash -c "echo 'AA' | socat -u STDIN UDP:$nsx2_addr:8880 > /dev/null"
Signature · 1 line
2.54.0
author reviewer
#2 lore raw
In reply to Phil Sutter
Quoted 7 lines · Phil Sutter

A system so slow that the whole shell test suite run takes 20min fails this test, probably because the last non-matching rule's range starting 10s ahead is not sufficient. Move that time range into the past, so the test may take up to 2min to complete and still pass.

Fixes b5145809b1bb8 ("tests: shell: add packetpath test for meta time expression.")

Series applied.