OVS_WAIT_UNTIL() macro has only 2 arguments and doesn't check the output of the command, but bonding tests are trying to use it as if it was AT_CHECK macro. That makes checks in bonding tests mostly useless, since they are not actually checking anything except for command returning zero.
Introducing a new macro OVS_WAIT_UNTIL_EQUAL that will actually perform the comparison with the desired output. Using it for the bonding tests and fixing all the caught incorrect expected outputs along the way. Fixes: b4e50218a0f8 ("bond: Add 'primary' interface concept for active-backup mode.") Signed-off-by: Ilya Maximets <i.maxim...@ovn.org> --- tests/ofproto-dpif.at | 24 ++++++++++++------------ tests/ovs-macros.at | 9 +++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 912f3a1da..58f08dff9 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -81,11 +81,12 @@ recirc_id(0),in_port(4),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=ff: ovs-appctl netdev-dummy/set-admin-state p1 up ovs-appctl time/warp 100 -OVS_WAIT_UNTIL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [0], [dnl +OVS_WAIT_UNTIL_EQUAL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [dnl ---- bond0 ---- bond_mode: active-backup bond may use recirculation: no, <del> bond-hash-basis: 0 +lb_output action: disabled, bond-id: -1 updelay: 0 ms downdelay: 0 ms lacp_status: off @@ -99,7 +100,6 @@ member p1: enabled member p2: enabled may_enable: true - ]) OVS_VSWITCHD_STOP @@ -129,11 +129,12 @@ ovs-appctl time/warp 100 OVS_WAIT_UNTIL([test -n "`ovs-appctl bond/show | fgrep 'member p1: disabled'`"]) ovs-appctl netdev-dummy/set-admin-state p1 up ovs-appctl time/warp 100 -OVS_WAIT_UNTIL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [0], [dnl +OVS_WAIT_UNTIL_EQUAL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [dnl ---- bond0 ---- bond_mode: active-backup bond may use recirculation: no, <del> bond-hash-basis: 0 +lb_output action: disabled, bond-id: -1 updelay: 0 ms downdelay: 0 ms lacp_status: off @@ -150,7 +151,6 @@ member p2: enabled member p3: enabled may_enable: true - ]) dnl Now delete the primary and verify that the output shows that the @@ -171,11 +171,12 @@ ovs-vsctl \ --id=@p1 create Interface name=p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p1.sock ofport_request=1 -- \ set Port bond0 interfaces="$uuids, @p1]" ovs-appctl time/warp 100 -OVS_WAIT_UNTIL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [0], [dnl +OVS_WAIT_UNTIL_EQUAL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [dnl ---- bond0 ---- bond_mode: active-backup bond may use recirculation: no, <del> bond-hash-basis: 0 +lb_output action: disabled, bond-id: -1 updelay: 0 ms downdelay: 0 ms lacp_status: off @@ -192,17 +193,17 @@ member p2: enabled member p3: enabled may_enable: true - ]) dnl Switch to another primary ovs-vsctl set port bond0 other_config:bond-primary=p2 ovs-appctl time/warp 100 -OVS_WAIT_UNTIL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [0], [dnl +OVS_WAIT_UNTIL_EQUAL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [dnl ---- bond0 ---- bond_mode: active-backup bond may use recirculation: no, <del> bond-hash-basis: 0 +lb_output action: disabled, bond-id: -1 updelay: 0 ms downdelay: 0 ms lacp_status: off @@ -211,25 +212,25 @@ active-backup primary: p2 <active member mac del> member p1: enabled - active member may_enable: true member p2: enabled + active member may_enable: true member p3: enabled may_enable: true - ]) dnl Remove the "bond-primary" config directive from the bond. AT_CHECK([ovs-vsctl remove Port bond0 other_config bond-primary]) ovs-appctl time/warp 100 -OVS_WAIT_UNTIL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [0], [dnl +OVS_WAIT_UNTIL_EQUAL([ovs-appctl bond/show | STRIP_RECIRC_ID | STRIP_ACTIVE_MEMBER_MAC], [dnl ---- bond0 ---- bond_mode: active-backup bond may use recirculation: no, <del> bond-hash-basis: 0 +lb_output action: disabled, bond-id: -1 updelay: 0 ms downdelay: 0 ms lacp_status: off @@ -238,15 +239,14 @@ active-backup primary: <none> <active member mac del> member p1: enabled - active member may_enable: true member p2: enabled + active member may_enable: true member p3: enabled may_enable: true - ]) OVS_VSWITCHD_STOP diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 66545da57..7f1e78664 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -261,6 +261,15 @@ dnl in IF-FAILED (if provided) and fails the test. m4_define([OVS_WAIT_UNTIL], [OVS_WAIT([$1], [$2], [AT_LINE], [until $1])]) +dnl OVS_WAIT_UNTIL_EQUAL(COMMAND, OUTPUT) +dnl +dnl Executes shell COMMAND in a loop until it returns zero and the output +dnl equals OUTPUT. If COMMAND does not return zero or a desired output within +dnl a reasonable time limit, fails the test. +m4_define([OVS_WAIT_UNTIL_EQUAL], + [echo "$2" > wait_until_expected + OVS_WAIT_UNTIL([$1 | diff -u wait_until_expected - ])]) + dnl OVS_WAIT_WHILE(COMMAND, [IF-FAILED]) dnl dnl Executes shell COMMAND in a loop until it returns nonzero. If COMMAND does -- 2.34.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev