Skip to content

Commit

Permalink
tests: Wait for new ovn-controllers to connect to Southbound.
Browse files Browse the repository at this point in the history
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 <xsimonar@redhat.com>
Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Reviewed-By: Ihar Hrachyshka <ihar@redhat.com>
  • Loading branch information
dceara and simonartxavier committed Oct 12, 2023
1 parent 5efdf01 commit 0b512d7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
41 changes: 40 additions & 1 deletion tests/ovn-macros.at
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions tests/ovn.at
Original file line number Diff line number Diff line change
Expand Up @@ -27936,8 +27936,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
Expand All @@ -27963,8 +27964,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
Expand Down Expand Up @@ -35745,7 +35747,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
Expand Down

0 comments on commit 0b512d7

Please sign in to comment.