Replace direct ovs-vsctl ofport queries with ovs-vsctl wait-until (when
name is available) or OVS_WAIT_UNTIL which retry until a valid ofport is
assigned.
Also add "ovn-nbctl --wait=hv sync" to ensure ovn-controller has
installed the output flows referencing that ofport before running
any trace.

Fixes: 79302556d472 ("controller: Add experimental flow-based tunnel support.")
Signed-off-by: Xavier Simonart <[email protected]>

---
v2: Updated after removal of wait_and_get_ofport.
---
 tests/ovn.at | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/tests/ovn.at b/tests/ovn.at
index 555222222..68bebca1f 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -32109,10 +32109,17 @@ check_packet_tunnel() {
     as $hv
     echo "vif$src -> vif$dst should go through tunnel $local_encap_ip -> 
$remote_encap_ip"
     if test x$flow_based_tunnel == xtrue; then
-        tunnel_ofport=$(ovs-vsctl --bare --column=ofport list interface 
ovn-geneve)
+        AT_CHECK([ovs-vsctl wait-until interface ovn-geneve 'ofport>0'])
+        tunnel_ofport=$(ovs-vsctl get interface ovn-geneve ofport)
     else
-        tunnel_ofport=$(ovs-vsctl --bare --column=ofport find interface 
options:local_ip=$local_encap_ip options:remote_ip=$remote_encap_ip)
+        OVS_WAIT_UNTIL([
+            tunnel_ofport=$(ovs-vsctl --bare --columns ofport find Interface 
options:local_ip=$local_encap_ip options:remote_ip=$remote_encap_ip)
+            echo "ofport=$tunnel_ofport" >&2
+            test -n "$tunnel_ofport" && test "$tunnel_ofport" -ge 0])
     fi
+    # Once ofport is in ovs db, ensure ovn-controller handles it.
+    check ovn-nbctl --wait=hv sync
+
     AT_CHECK([test $(ovs-appctl ofproto/trace br-int in_port=vif$src $packet | 
grep "output:" | awk -F ':' '{ print $2 }') == $tunnel_ofport])
     if test x$flow_based_tunnel == xtrue; then
         trace_output=$(ovs-appctl ofproto/trace br-int in_port=vif$src $packet)
@@ -32215,10 +32222,16 @@ check_packet_tunnel() {
     echo "vif$src -> vif$dst should go through tunnel $local_encap_ip -> 
$remote_encap_ip"
 
     if test x$flow_based_tunnel == xtrue; then
-        tunnel_ofport=$(ovs-vsctl --bare --column=ofport list interface 
ovn-geneve)
+        AT_CHECK([ovs-vsctl wait-until interface ovn-geneve 'ofport>0'])
+        tunnel_ofport=$(ovs-vsctl get interface ovn-geneve ofport)
     else
-        tunnel_ofport=$(ovs-vsctl --bare --column=ofport find interface 
options:local_ip=$local_encap_ip options:remote_ip=$remote_encap_ip)
+        OVS_WAIT_UNTIL([
+            tunnel_ofport=$(ovs-vsctl --bare --columns ofport find Interface 
options:local_ip=$local_encap_ip options:remote_ip=$remote_encap_ip)
+            echo "ofport=$tunnel_ofport" >&2
+            test -n "$tunnel_ofport" && test "$tunnel_ofport" -ge 0])
     fi
+    check ovn-nbctl --wait=hv sync
+
     AT_CHECK([test $(ovs-appctl ofproto/trace br-int in_port=vif$src $packet | 
grep "output:" | awk -F ':' '{ print $2 }') == $tunnel_ofport])
     if test x$flow_based_tunnel == xtrue; then
         trace_output=$(ovs-appctl ofproto/trace br-int in_port=vif$src $packet)
@@ -32365,9 +32378,13 @@ check_packet_tunnel() {
     as $hv
     echo "vif$src -> vif$dst should go through tunnel $local_encap_ip -> 
$remote_encap_ip"
     if test x$flow_based_tunnel == xtrue; then
-        tunnel_ofport=$(ovs-vsctl --bare --column=ofport list interface 
ovn-geneve)
+        AT_CHECK([ovs-vsctl wait-until interface ovn-geneve 'ofport>0'])
+        tunnel_ofport=$(ovs-vsctl get interface ovn-geneve ofport)
     else
-        tunnel_ofport=$(ovs-vsctl --bare --column=ofport find interface 
options:local_ip=$local_encap_ip options:remote_ip=$remote_encap_ip)
+        OVS_WAIT_UNTIL([
+            tunnel_ofport=$(ovs-vsctl --bare --columns ofport find Interface 
options:local_ip=$local_encap_ip options:remote_ip=$remote_encap_ip)
+            echo "ofport=$tunnel_ofport" >&2
+            test -n "$tunnel_ofport" && test "$tunnel_ofport" -ge 0])
     fi
     ovs-appctl ofproto/trace br-ext in_port=vif$src $packet
     AT_CHECK([test $(ovs-appctl ofproto/trace br-ext in_port=vif$src $packet | 
grep "output:" | awk -F ':' '{ print $2 }') == $tunnel_ofport])
-- 
2.47.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to