Skip to content

Commit

Permalink
tests: Eliminate most "sleep" calls.
Browse files Browse the repository at this point in the history
Many of these could be replaced by "ovn-nbctl sync".  Some weren't
really needed at all because they were adjacent to something that itself
called sync or otherwise used --wait.  Some were more appropriately
done with explicit waits for what was really needed.

I left some "sleep"s.  Some were because they were "negative" sleeps:
they were giving time for something to happen that should *not* happen
(in other words, if you wait for it to happen, you'll wait forever,
unless there's a bug).  Some were because I didn't know how to properly
wait for what they were waiting for, or because I didn't understand
the circumstances deeply enough.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Dumitru Ceara <dceara@redhat.com>
  • Loading branch information
blp committed Feb 2, 2021
1 parent 5dba541 commit 0c0a7a9
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 131 deletions.
16 changes: 16 additions & 0 deletions tests/ovn-macros.at
Expand Up @@ -417,6 +417,22 @@ wait_column() {
echo "$column in $db table $table has value $found, from the following rows:"
ovn-${db}ctl list $table])
}

# wait_for_ports_up [PORT...]
#
# With arguments, waits for specified Logical_Switch_Ports to come up.
# Without arguments, waits for all "plain" and router
# Logical_Switch_Ports to come up.
wait_for_ports_up() {
if test $# = 0; then
wait_row_count nb:Logical_Switch_Port 0 up!=true type='""'
wait_row_count nb:Logical_Switch_Port 0 up!=true type=router
else
for port; do
wait_row_count nb:Logical_Switch_Port 1 up=true name=$port
done
fi
}
OVS_END_SHELL_HELPERS

m4_define([OVN_POPULATE_ARP], [AT_CHECK(ovn_populate_arp__, [0], [ignore])])
11 changes: 9 additions & 2 deletions tests/ovn-northd.at
Expand Up @@ -849,7 +849,7 @@ uuid=$(fetch_column Port_Binding _uuid logical_port=cr-DR-S1)
echo "CR-LRP UUID is: " $uuid

check ovn-nbctl set Logical_Router $cr_uuid options:chassis=gw1
check ovn-nbctl --wait=hv sync
check ovn-nbctl --wait=sb sync

ovn-nbctl create Address_Set name=allowed_range addresses=\"1.1.1.1\"
ovn-nbctl create Address_Set name=disallowed_range addresses=\"2.2.2.2\"
Expand Down Expand Up @@ -1090,6 +1090,7 @@ ovn-nbctl --wait=sb -- --id=@hc create \
Load_Balancer_Health_Check vip="10.0.0.10\:80" -- add Load_Balancer . \
health_check @hc
wait_row_count Service_Monitor 2
check ovn-nbctl --wait=sb sync

ovn-sbctl dump-flows sw0 | grep ct_lb | grep priority=120 > lflows.txt
AT_CHECK([cat lflows.txt | sed 's/table=..//'], [0], [dnl
Expand All @@ -1109,6 +1110,7 @@ OVS_WAIT_FOR_OUTPUT(
# Set the service monitor for sw1-p1 to offline
check ovn-sbctl set service_monitor sw1-p1 status=offline
wait_row_count Service_Monitor 1 logical_port=sw1-p1 status=offline
check ovn-nbctl --wait=sb sync

AT_CAPTURE_FILE([sbflows4])
OVS_WAIT_FOR_OUTPUT(
Expand All @@ -1120,6 +1122,7 @@ OVS_WAIT_FOR_OUTPUT(
ovn-sbctl set service_monitor $sm_sw0_p1 status=offline

wait_row_count Service_Monitor 1 logical_port=sw0-p1 status=offline
check ovn-nbctl --wait=sb sync

AT_CAPTURE_FILE([sbflows5])
OVS_WAIT_FOR_OUTPUT(
Expand All @@ -1136,6 +1139,7 @@ ovn-sbctl set service_monitor $sm_sw0_p1 status=online
ovn-sbctl set service_monitor $sm_sw1_p1 status=online

wait_row_count Service_Monitor 1 logical_port=sw1-p1 status=online
check ovn-nbctl --wait=sb sync

AT_CAPTURE_FILE([sbflows7])
OVS_WAIT_FOR_OUTPUT(
Expand All @@ -1146,6 +1150,7 @@ OVS_WAIT_FOR_OUTPUT(
# Set the service monitor for sw1-p1 to error
ovn-sbctl set service_monitor $sm_sw1_p1 status=error
wait_row_count Service_Monitor 1 logical_port=sw1-p1 status=error
check ovn-nbctl --wait=sb sync

ovn-sbctl dump-flows sw0 | grep "ip4.dst == 10.0.0.10 && tcp.dst == 80" \
| grep priority=120 > lflows.txt
Expand Down Expand Up @@ -1184,6 +1189,7 @@ OVS_WAIT_FOR_OUTPUT(
check ovn-sbctl set service_monitor sw1-p1 status=online

wait_row_count Service_Monitor 1 logical_port=sw1-p1 status=online
check ovn-nbctl --wait=sb sync

AT_CAPTURE_FILE([sbflows10])
OVS_WAIT_FOR_OUTPUT(
Expand Down Expand Up @@ -1214,6 +1220,7 @@ AT_CHECK([ovn-nbctl -- --id=@hc create Load_Balancer_Health_Check vip="10.0.0.10

check ovn-nbctl ls-lb-add sw0 lb2
check ovn-nbctl ls-lb-add sw1 lb2
check ovn-nbctl --wait=sb sync

wait_row_count Service_Monitor 5

Expand Down Expand Up @@ -1729,7 +1736,7 @@ check ovn-nbctl pg-add pg0 sw0-p1 sw1-p1
check ovn-nbctl acl-add pg0 from-lport 1002 "inport == @pg0 && ip4 && tcp && tcp.dst == 80" reject
check ovn-nbctl acl-add pg0 to-lport 1003 "outport == @pg0 && ip6 && udp" reject

check ovn-nbctl --wait=hv sync
check ovn-nbctl --wait=sb sync

AS_BOX([1])

Expand Down

0 comments on commit 0c0a7a9

Please sign in to comment.