From aa5a3d6c506290c94ffef0ced02937dea3b9e895 Mon Sep 17 00:00:00 2001 From: Dumitru Ceara Date: Wed, 11 Oct 2023 15:22:31 +0200 Subject: [PATCH] tests: Wait for new ovn-controllers to connect to Southbound. Simulated chassis are added with ovn_attach(), ovn_az_attach() and start_virtual_controller(). Wait for ovn-controllers to register in the Southbound (create their Encap record) before continuing. That's required because 'ovn-nbctl --wait=hv sync' (used throughout the test suite) has different semantics if no chassis is registered in the Southbound. In those cases the command is equivalent to 'ovn-nbctl --wait=sb sync'. This was causing a race condition due to which CI would occasionally fail because of missing OpenFlows, e.g.: https://github.com/ovsrobot/ovn/actions/runs/6471719045/job/17570941948#step:8:4849 Co-authored-by: Xavier Simonart Signed-off-by: Xavier Simonart Signed-off-by: Dumitru Ceara Acked-by: Mark Michelson (cherry picked from commit 49d001cb27395f71a548b4333c04d4c225000bfb) --- tests/ovn-macros.at | 41 ++++++++++++++++++++++++++++++++++++++++- tests/ovn.at | 12 +++++++----- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at index 99b09248fc..2bf952ae51 100644 --- a/tests/ovn-macros.at +++ b/tests/ovn-macros.at @@ -288,11 +288,44 @@ net_attach () { || return 1 } +ovn_wait_for_encaps() { + local systemid=$1 + + if [[ -f "${OVN_SYSCONFDIR}/system-id-override" ]]; then + systemid=$(cat ${OVN_SYSCONFDIR}/system-id-override) + fi + + local encap=$(ovs-vsctl get Open_vSwitch . external_ids:ovn-encap-type-$systemid) + if [[ -z "$encap" ]]; then + encap=$(ovs-vsctl get Open_vSwitch . external_ids:ovn-encap-type) + fi + encap=$(tr -d '"' <<< $encap) + + local ip=$(ovs-vsctl get Open_vSwitch . external_ids:ovn-encap-ip-$systemid) + if [[ -z "$ip" ]]; then + ip=$(ovs-vsctl get Open_vSwitch . external_ids:ovn-encap-ip) + fi + ip=$(tr -d '"' <<< $ip) + + IFS="," read -r -a encap_types <<< "$encap" + for e in "${encap_types[[@]]}"; do + wait_column "$ip" sb:Encap ip chassis_name="$systemid" type="$e" + done +} + # ovn_az_attach AZ NETWORK BRIDGE IP [MASKLEN] [ENCAP] ovn_az_attach() { - local az=$1 net=$2 bridge=$3 ip=$4 masklen=${5-24} encap=${6-geneve,vxlan} systemid=${7-$sandbox} cli_args=${@:8} + local az=$1 net=$2 bridge=$3 ip=$4 masklen=${5-24} encap=${6-geneve,vxlan} + local systemid=${7-$sandbox} systemid_override=$8 net_attach $net $bridge || return 1 + local expected_encap_id=$systemid + local cli_args="" + if [[ -n "$systemid_override" ]]; then + cli_args="-n $systemid_override" + expected_encap_id=$systemid_override + fi + mac=`ovs-vsctl get Interface $bridge mac_in_use | sed s/\"//g` arp_table="$arp_table $sandbox,$bridge,$ip,$mac" if test -z $(echo $ip | sed '/:/d'); then @@ -332,6 +365,11 @@ ovn_az_attach() { fi start_daemon ovn-controller --enable-dummy-vif-plug ${cli_args} || return 1 + if test X"$az" = XNONE; then + ovn_wait_for_encaps $expected_encap_id + else + ovn_as $az ovn_wait_for_encaps $expected_encap_id + fi } # ovn_attach NETWORK BRIDGE IP [MASKLEN] [ENCAP] @@ -372,6 +410,7 @@ start_virtual_controller() { || return 1 ovn-controller --enable-dummy-vif-plug ${cli_args} -vconsole:off --detach --no-chdir + ovn_wait_for_encaps $systemid } # ovn_setenv AZ diff --git a/tests/ovn.at b/tests/ovn.at index 5eaeeb312e..a0ac285ad4 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -27628,8 +27628,9 @@ ovn-nbctl ls-add ls1 ovn-nbctl --wait=sb lsp-add ls1 lsp1 # Simulate the fact that lsp1 had been previously bound on hv1. -ovn-sbctl --id=@e create encap chassis_name=hv1 ip="192.168.0.1" type="geneve" \ - -- --id=@c create chassis name=hv1 encaps=@e \ +ovn-sbctl --id=@e1 create encap chassis_name=hv1 ip="192.168.0.1" type="geneve" \ + --id=@e2 create encap chassis_name=hv1 ip="192.168.0.1" type="vxlan" \ + -- --id=@c create chassis name=hv1 encaps=@e1,@e2 \ -- set Port_Binding lsp1 chassis=@c as hv1 @@ -27655,8 +27656,9 @@ ovn-nbctl ls-add ls1 ovn-nbctl --wait=sb lsp-add ls1 lsp1 # Simulate the fact that lsp1 had been previously bound on hv1. -ovn-sbctl --id=@e create encap chassis_name=hv1 ip="192.168.0.1" type="geneve" \ - -- --id=@c create chassis hostname=hv1 name=hv1 encaps=@e \ +ovn-sbctl --id=@e1 create encap chassis_name=hv1 ip="192.168.0.1" type="geneve" \ + --id=@e2 create encap chassis_name=hv1 ip="192.168.0.1" type="vxlan" \ + -- --id=@c create chassis name=hv1 encaps=@e1,@e2 \ -- set Port_Binding lsp1 chassis=@c as hv1 @@ -35268,7 +35270,7 @@ as hv1 ovs-vsctl set-ssl \ echo hv3 > ${OVN_SYSCONFDIR}/test_hv # the last argument is passed to ovn-controller through cli -ovn_attach n1 br-phys 192.168.0.1 24 vxlan hv1 -n hv3 +ovn_attach n1 br-phys 192.168.0.1 24 vxlan hv1 hv3 sim_add hv2 as hv2