From 1335a8d578b03e276294b32df9702c2562705f22 Mon Sep 17 00:00:00 2001 From: Joe Stringer Date: Mon, 28 Apr 2014 11:51:28 +1200 Subject: [PATCH] tests: Fix race condition waiting for monitor thread. Occasionally, test #770 "ofproto-dpif - ofproto-dpif-monitor 1" would fail, because the testsuite looked in the logs for evidence of a thread being created, but it checked before vswitchd was able to spawn the thread. This patch fixes the race by modifying the commands that check for creation/termination of threads to wait until they see the messages instead. Signed-off-by: Joe Stringer Reviewed-by: YAMAMOTO Takashi --- tests/ofproto-dpif.at | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 89c8ad764..a1442f9d0 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -4492,37 +4492,27 @@ OVS_VSWITCHD_START([add-port br0 p0 -- set interface p0 type=gre options:remote_ # enable bfd on p0. AT_CHECK([ovs-vsctl set interface p0 bfd:enable=true]) # check log. -AT_CHECK([sed -n "s/^.*|ofproto_dpif_monitor(monitor)|INFO|\(.* created\)$/\1/p" ovs-vswitchd.log], [0], [dnl -monitor thread created -]) +OVS_WAIT_UNTIL([grep "monitor thread created" ovs-vswitchd.log]) # disable bfd on p0. AT_CHECK([ovs-vsctl set interface p0 bfd:enable=false]) # check log. -AT_CHECK([sed -n "s/^.*|ofproto_dpif_monitor(monitor)|INFO|\(.* terminated\)$/\1/p" ovs-vswitchd.log], [0], [dnl -monitor thread terminated -]) +OVS_WAIT_UNTIL([grep "monitor thread terminated" ovs-vswitchd.log]) AT_CHECK([cat ovs-vswitchd.log | sed -e '/^.*ofproto_dpif_monitor.*$/d' > ovs-vswitchd.log]) # enable cfm on p0. AT_CHECK([ovs-vsctl set interface p0 cfm_mpid=10]) # check log. -AT_CHECK([sed -n "s/^.*|ofproto_dpif_monitor(monitor)|INFO|\(.* created\)$/\1/p" ovs-vswitchd.log], [0], [dnl -monitor thread created -]) +OVS_WAIT_UNTIL([grep "monitor thread created" ovs-vswitchd.log]) # disable cfm on p0. AT_CHECK([ovs-vsctl remove interface p0 cfm_mpid 10]) # check log. -AT_CHECK([sed -n "s/^.*|ofproto_dpif_monitor(monitor)|INFO|\(.* terminated\)$/\1/p" ovs-vswitchd.log], [0], [dnl -monitor thread terminated -]) +OVS_WAIT_UNTIL([grep "monitor thread terminated" ovs-vswitchd.log]) AT_CHECK([cat ovs-vswitchd.log | sed -e '/^.*ofproto_dpif_monitor.*$/d' > ovs-vswitchd.log]) # enable both bfd and cfm on p0. AT_CHECK([ovs-vsctl set interface p0 bfd:enable=true cfm_mpid=10]) # check log. -AT_CHECK([sed -n "s/^.*|ofproto_dpif_monitor(monitor)|INFO|\(.* created\)$/\1/p" ovs-vswitchd.log], [0], [dnl -monitor thread created -]) +OVS_WAIT_UNTIL([grep "monitor thread created" ovs-vswitchd.log]) # disable bfd on p0. AT_CHECK([ovs-vsctl set interface p0 bfd:enable=false]) # check log, there should not be the log of thread terminated. @@ -4537,9 +4527,7 @@ monitor thread created # disable bfd and cfm together. AT_CHECK([ovs-vsctl set interface p0 bfd:enable=false -- remove interface p0 cfm_mpid 10]) # check log. -AT_CHECK([sed -n "s/^.*|ofproto_dpif_monitor(monitor)|INFO|\(.* terminated\)$/\1/p" ovs-vswitchd.log], [0], [dnl -monitor thread terminated -]) +OVS_WAIT_UNTIL([grep "monitor thread terminated" ovs-vswitchd.log]) OVS_VSWITCHD_STOP AT_CLEANUP -- 2.43.0