[ovs-dev] [PATCH] tests: Really fix requested-chassis localport test

Frode Nordahl frode.nordahl at canonical.com
Fri Nov 5 16:05:53 UTC 2021


Use OVS_WAIT_UNTIL instead of AT_CHECK, which should avoid race
conditions where the check is ran before the tables are populated.

Fixes: ad77db239d9a ("controller: Make use of Port_Binding:requested_chassis.")
Signed-off-by: Frode Nordahl <frode.nordahl at canonical.com>
---
 tests/ovn.at | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/tests/ovn.at b/tests/ovn.at
index 6f6f5c2da..828fbf68e 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -28748,18 +28748,36 @@ check ovn-nbctl lsp-set-type sw0-lport localport
 # First confirm operation without requested-chassis
 check_row_count Port_Binding 1 logical_port=sw0-lport 'up=true'
 
-AT_CHECK([as hv1 ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13], [0], [])
-AT_CHECK([as hv2 ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13], [0], [])
+OVS_WAIT_UNTIL([
+    as hv1 \
+    ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13
+])
+OVS_WAIT_UNTIL([
+    as hv2 \
+    ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13
+])
 
 # Set requested-chassis to one of the HVs
 check ovn-nbctl --wait=hv lsp-set-options sw0-lport requested-chassis="hv1"
-AT_CHECK([as hv1 ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13], [0], [])
-AT_CHECK([as hv2 ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13], [1], [])
+OVS_WAIT_UNTIL([
+    as hv1 \
+    ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13
+])
+OVS_WAIT_UNTIL([
+   ! as hv2 \
+   ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13
+])
 
 # Set requested-chassis to empty string
 check ovn-nbctl --wait=hv lsp-set-options sw0-lport requested-chassis=""
-AT_CHECK([as hv1 ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13], [0], [])
-AT_CHECK([as hv2 ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13], [0], [])
+OVS_WAIT_UNTIL([
+    as hv1 \
+    ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13
+])
+OVS_WAIT_UNTIL([
+    as hv2 \
+    ovs-ofctl -O OpenFlow15 dump-flows br-int table=0 | grep -q in_port=13
+])
 
 OVN_CLEANUP([hv1],[hv2])
 AT_CLEANUP
-- 
2.32.0



More information about the dev mailing list