Signed-off-by: Ben Pfaff <b...@nicira.com>
---
 tests/automake.mk       |    1 +
 tests/bond.at           |  349 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/lacp.at           |    4 +-
 tests/ofproto-macros.at |    2 +-
 tests/testsuite.at      |    1 +
 5 files changed, 353 insertions(+), 4 deletions(-)
 create mode 100644 tests/bond.at

diff --git a/tests/automake.mk b/tests/automake.mk
index 2977f76..600056e 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -21,6 +21,7 @@ TESTSUITE_AT = \
        tests/odp.at \
        tests/multipath.at \
        tests/autopath.at \
+       tests/bond.at \
        tests/lacp.at \
        tests/learn.at \
        tests/vconn.at \
diff --git a/tests/bond.at b/tests/bond.at
new file mode 100644
index 0000000..765afef
--- /dev/null
+++ b/tests/bond.at
@@ -0,0 +1,349 @@
+AT_BANNER([bonds])
+
+AT_SETUP([active-backup bond - active slave])
+# Create bond0 on br0 with interfaces p1 and p2, and br1 with ports p3
+# and p4, with p1 patched to p3 and p2 patched to p4.
+OVS_VSWITCHD_START(
+  [set bridge br0 fail-mode=standalone -- \
+   add-bond br0 bond0 p1 p2 bond_mode=active-backup -- \
+   set interface p1 type=dummy options:peer=p3 -- \
+   set interface p2 type=dummy options:peer=p4 -- \
+   add-br br1 -- \
+   set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 \
+                  datapath-type=dummy other-config:datapath-id=1234 -- \
+   add-port br1 p3 -- set interface p3 type=dummy options:peer=p1 -- \
+   add-port br1 p4 -- set interface p4 type=dummy options:peer=p2])
+
+AT_CHECK([ovs-appctl time/stop])
+
+# Start sending packets between the bridges,
+# at a rate of one 100-byte packet every 10 ms for 10 s.
+# None of the bonded interfaces are up yet.
+AT_CHECK([ovs-appctl netdev-dummy/set-admin-state br0 br1 up], [0], [OK
+])
+AT_CHECK([ovs-appctl netdev-dummy/pktgen br0 10 100 10000 icmp 1 
cc:66:cc:66:cc:66 aa:55:aa:55:aa:55])
+AT_CHECK([ovs-appctl netdev-dummy/pktgen br1 10 100 10000 icmp 2 
aa:55:aa:55:aa:55 cc:66:cc:66:cc:66])
+
+slave_status () {
+    AS_CASE([$2],
+        [disabled], [printf "slave $1: disabled\n\tmay_enable: false\n"],
+        [enabled], [printf "slave $1: enabled\n\tmay_enable: true\n"],
+        [active], [printf "slave $1: enabled\n\tactive slave\n\tmay_enable: 
true\n"])
+    echo
+}
+
+check_bond () {
+    cat > expout <<EOF
+---- bond0 ----
+bond_mode: active-backup
+bond-hash-basis: 0
+updelay: 0 ms
+downdelay: 0 ms
+lacp_status: off
+
+EOF
+    slave_status p1 $1 >> expout
+    slave_status p2 $2 >> expout
+
+    AT_CHECK_UNQUOTED([ovs-appctl bond/show bond0], [0], [expout])
+}
+
+read_ports () {
+    bridge=$1; shift
+    for port
+    do
+        AS_VAR_SET([${bridge}_p${port}_rx], [0])
+        AS_VAR_SET([${bridge}_p${port}_tx], [0])
+    done
+    ovs-ofctl dump-ports $bridge > $bridge.ports
+    sed -n '1d
+N
+s/.*port *\([[0-9]]*\): rx pkts=\([[0-9]]*\),.*tx 
pkts=\([[0-9]]*\),.*/'$bridge'_p\1_rx=\2 '$bridge'_p\1_tx=\3/p' < $bridge.ports 
> $bridge.ports.sh
+    . ./$bridge.ports.sh
+    for port
+    do
+        AS_VAR_COPY([rx], [${bridge}_p${port}_rx])
+        AS_VAR_COPY([tx], [${bridge}_p${port}_tx])
+        echo ${bridge}_p${port}_rx=$rx ${bridge}_p${port}_tx=$tx
+    done
+}
+
+# Initially there should be no active slave since all the slaves are down.
+check_bond disabled disabled
+for i in `seq 1 25`; do ovs-appctl time/warp 100; done
+read_ports br0 1 2 65534
+read_ports br1 3 4 65534
+# About 250 packets should have been generated on each end.
+AT_FAIL_IF([test $br0_p65534_rx -lt 200])
+AT_FAIL_IF([test $br1_p65534_rx -lt 200])
+# Each packet generated on br1 should have been flooded to p3 and p4.
+AT_FAIL_IF([test $br1_p3_tx -lt 200])
+AT_FAIL_IF([test $br1_p3_tx -ne $br1_p4_tx])
+# Each packet transmitted on p3 and p4 should have been received on p1 or p2.
+AT_FAIL_IF([test $br0_p1_rx -lt 200])
+AT_FAIL_IF([test $br0_p1_rx -ne $br0_p2_rx])
+# The packets generated by br0 should have been entirely dropped.
+AT_CHECK([echo $br0_p1_tx $br0_p2_tx $br1_p3_rx $br1_p4_rx], [0], [0 0 0 0
+])
+
+# Bring up p1 so that it becomes the active slave.
+AT_CHECK([ovs-appctl netdev-dummy/set-admin-state p1 p3 up], 0, [OK
+])
+check_bond active disabled
+for i in `seq 1 25`; do ovs-appctl time/warp 100; done
+read_ports br0 1 2 65534
+read_ports br1 3 4 65534
+ovs-appctl fdb/show br0
+ovs-appctl fdb/show br1
+# About 500 packets should have been generated on each end.
+AT_FAIL_IF([test $br0_p65534_rx -lt 450 || test $br0_p65534_rx -gt 550])
+AT_FAIL_IF([test $br1_p65534_rx -lt 450 || test $br1_p65534_rx -gt 550])
+# About 250 packets from br0 should have gone out on p1, received on p3,
+# and forwarded to br1.
+AT_FAIL_IF([test $br0_p1_tx -lt 200     || test $br0_p1_tx -gt 300])
+AT_FAIL_IF([test $br1_p3_rx -lt 200     || test $br1_p3_rx -gt 300])
+AT_FAIL_IF([test $br1_p65534_tx -lt 200 || test $br1_p65534_tx -gt 300])
+# br1 should have learned quickly to only transmit on p3.
+AT_FAIL_IF([test $br1_p3_tx -lt 450 || test $br1_p3_tx -gt 550])
+AT_FAIL_IF([test $br1_p4_tx -lt 200 || test $br1_p4_tx -gt 300])
+AT_FAIL_IF([test $br0_p2_rx -lt 200 || test $br0_p2_rx -gt 300])
+# About 250 packets from br1 should have been received on p2 and
+# forwarded to br0.
+AT_FAIL_IF([test $br0_p1_rx -lt 450 || test $br0_p1_rx -gt 550])
+AT_FAIL_IF([test $br0_p65534_tx -lt 200 || test $br0_p65534_tx -gt 300])
+# p2/p4 has been down the whole time.
+AT_CHECK([echo $br0_p2_tx $br1_p4_rx], [0], [0 0
+])
+
+# Bring up p2 and p4 so that they become enabled (but p1 remains the active
+# slaves).
+AT_CHECK([ovs-appctl netdev-dummy/set-admin-state p2 p4 up], 0, [OK
+])
+check_bond active enabled
+for i in `seq 1 25`; do ovs-appctl time/warp 100; done
+read_ports br0 1 2 65534
+read_ports br1 3 4 65534
+ovs-appctl fdb/show br0
+ovs-appctl fdb/show br1
+# About 750 packets should have been generated on each end.
+AT_FAIL_IF([test $br0_p65534_rx -lt 700 || test $br0_p65534_rx -gt 800])
+AT_FAIL_IF([test $br1_p65534_rx -lt 700 || test $br1_p65534_rx -gt 800])
+# About 500 packets from br0 should have gone out on p1, received on p3,
+# and forwarded to br1.
+AT_FAIL_IF([test $br0_p1_tx -lt 450     || test $br0_p1_tx -gt 550])
+AT_FAIL_IF([test $br1_p3_rx -lt 450     || test $br1_p3_rx -gt 550])
+AT_FAIL_IF([test $br1_p65534_tx -lt 450 || test $br1_p65534_tx -gt 550])
+# br1 should have learned to only transmit on p3.
+AT_FAIL_IF([test $br1_p3_tx -lt 700 || test $br1_p3_tx -gt 800])
+AT_FAIL_IF([test $br1_p4_tx -lt 200 || test $br1_p4_tx -gt 300])
+AT_FAIL_IF([test $br0_p2_rx -lt 200 || test $br0_p2_rx -gt 300])
+# About 500 packets from br1 should have been received on p1, following
+# its selection as active slave, and forwarded to br0.
+AT_FAIL_IF([test $br0_p1_rx -lt 700 || test $br0_p1_rx -gt 800])
+AT_FAIL_IF([test $br0_p65534_tx -lt 450 || test $br0_p65534_tx -gt 550])
+# p2/p4 has been unused the whole time.
+AT_CHECK([echo $br0_p2_tx $br1_p4_rx], [0], [0 0
+])
+
+# Take p1 and p3 down so that the active slave shifts to p2.
+AT_CHECK([ovs-appctl netdev-dummy/set-admin-state p1 p3 down], 0, [OK
+])
+check_bond disabled active
+for i in `seq 1 25`; do ovs-appctl time/warp 100; done
+read_ports br0 1 2 65534
+read_ports br1 3 4 65534
+ovs-appctl fdb/show br0
+ovs-appctl fdb/show br1
+# About 1000 packets should have been generated on each end.
+AT_FAIL_IF([test $br0_p65534_rx -lt 950 || test $br0_p65534_rx -gt 1050])
+AT_FAIL_IF([test $br1_p65534_rx -lt 950 || test $br1_p65534_rx -gt 1050])
+# About 500 packets from br0 should have gone out on p1, received on p3,
+# and forwarded to br1.
+# About 250 packets from br0 should have gone out on p2, received on p4,
+# and forwarded to br1.
+AT_FAIL_IF([test $br0_p1_tx -lt 450     || test $br0_p1_tx -gt 550])
+AT_FAIL_IF([test $br1_p3_rx -lt 450     || test $br1_p3_rx -gt 550])
+AT_FAIL_IF([test $br0_p2_tx -lt 200     || test $br0_p2_tx -gt 300])
+AT_FAIL_IF([test $br1_p4_rx -lt 200     || test $br1_p4_rx -gt 300])
+AT_FAIL_IF([test $br1_p65534_tx -lt 700 || test $br1_p65534_tx -gt 800])
+# br1 should have learned to transmit on p4 now.
+AT_FAIL_IF([test $br1_p3_tx -lt 700 || test $br1_p3_tx -gt 800])
+AT_FAIL_IF([test $br1_p4_tx -lt 450 || test $br1_p4_tx -gt 550])
+# About 500 packets from br1 should have been received on p1, following
+# its selection as active slave, and forwarded to br0.
+# About 500 packets from br1 should have been received on p2, following
+# its selection as active slave, and forwarded to br0.
+AT_FAIL_IF([test $br0_p1_rx -lt 700 || test $br0_p1_rx -gt 800])
+AT_FAIL_IF([test $br0_p2_rx -lt 450 || test $br0_p2_rx -gt 550])
+AT_FAIL_IF([test $br0_p65534_tx -lt 700 || test $br0_p65534_tx -gt 800])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([active-backup bond - failover])
+# Create bond0 on br0 with interfaces p1 and p2, and br1 with ports p3
+# and p4, with p1 patched to p3 and p2 patched to p4.
+OVS_VSWITCHD_START(
+  [set bridge br0 fail-mode=standalone -- \
+   add-bond br0 bond0 p1 p2 bond_mode=active-backup -- \
+   set interface br0 options:rx_pcap=br0.pcap -- \
+   set interface p1 type=dummy options:peer=p3 -- \
+   set interface p2 type=dummy options:peer=p4 -- \
+   add-br br1 -- \
+   set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 \
+                  datapath-type=dummy other-config:datapath-id=1234 -- \
+   add-port br1 p3 -- set interface p3 type=dummy options:peer=p1 -- \
+   add-port br1 p4 -- set interface p4 type=dummy options:peer=p2])
+
+AT_CHECK([ovs-appctl time/stop])
+
+ovs-appctl netdev-dummy/set-admin-state br0 br1 p1 p3 up
+
+read_ports () {
+    bridge=$1; shift
+    for port
+    do
+        AS_VAR_SET([${bridge}_p${port}_rx], [0])
+        AS_VAR_SET([${bridge}_p${port}_tx], [0])
+    done
+    ovs-ofctl dump-ports $bridge > $bridge.ports
+    sed -n '1d
+N
+s/.*port *\([[0-9]]*\): rx pkts=\([[0-9]]*\),.*tx 
pkts=\([[0-9]]*\),.*/'$bridge'_p\1_rx=\2 '$bridge'_p\1_tx=\3/p' < $bridge.ports 
> $bridge.ports.sh
+    . ./$bridge.ports.sh
+    for port
+    do
+        AS_VAR_COPY([rx], [${bridge}_p${port}_rx])
+        AS_VAR_COPY([tx], [${bridge}_p${port}_tx])
+        echo ${bridge}_p${port}_rx=$rx ${bridge}_p${port}_tx=$tx
+    done
+}
+
+# Start sending packets between the bridges,
+# at a rate of one 100-byte packet every 10 ms for 10 s.
+AT_CHECK([ovs-appctl netdev-dummy/pktgen br0 10 100 100000 icmp 1 
cc:66:cc:66:cc:66 aa:55:aa:55:aa:55])
+AT_CHECK([ovs-appctl netdev-dummy/pktgen br1 10 100 100000 icmp 2 
aa:55:aa:55:aa:55 cc:66:cc:66:cc:66])
+
+check_bond disabled disabled
+for i in `seq 1 25`; do
+    ovs-appctl netdev-dummy/set-admin-state p2 p4 down
+    for i in `seq 1 10`; do ovs-appctl time/warp 100; done
+    ovs-appctl netdev-dummy/set-admin-state p2 p4 up
+    for i in `seq 1 10`; do ovs-appctl time/warp 100; done
+    ovs-appctl netdev-dummy/set-admin-state p1 p3 down
+    for i in `seq 1 10`; do ovs-appctl time/warp 100; done
+    ovs-appctl netdev-dummy/set-admin-state p1 p3 up
+    for i in `seq 1 10`; do ovs-appctl time/warp 100; done
+done
+read_ports br0 1 2 65534
+read_ports br1 3 4 65534
+
+# About 1000 packets should have been generated on each end.
+AT_FAIL_IF([test $br0_p65534_rx -lt 1050])
+AT_FAIL_IF([test $br1_p65534_rx -lt 950])
+# About 500 packets should have been forwarded to p1, p2, p3, and p4.
+AT_FAIL_IF([test $br0_p1_tx -lt 450 || test $br0_p1_tx -gt 550])
+AT_FAIL_IF([test $br0_p2_tx -lt 450 || test $br0_p2_tx -gt 550])
+AT_FAIL_IF([test $br1_p3_tx -lt 450 || test $br1_p3_tx -gt 550])
+AT_FAIL_IF([test $br1_p4_tx -lt 450 || test $br1_p4_tx -gt 550])
+# Each packet transmitted on p3 and p4 should have been received on p1 or p2.
+AT_FAIL_IF([test $br0_p1_rx -lt 200])
+AT_FAIL_IF([test $br0_p1_rx -ne $br0_p2_rx])
+# The packets generated by br0 should have been entirely dropped.
+AT_CHECK([echo $br0_p1_tx $br0_p2_tx $br1_p3_rx $br1_p4_rx], [0], [0 0 0 0
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([lacp bond - rebalancing])
+AT_CHECK([perl $srcdir/choose-port.pl], [0], [stdout])
+NETFLOW_PORT=`cat stdout`
+
+# Create bond0 on br0 with interfaces p1, p2, and p3
+#    and bond1 on br1 with interfaces p4, p5, and p6
+# with p1<->p4, p2<->p5, p3<->p6
+OVS_VSWITCHD_START(
+  [set bridge br0 fail-mode=standalone -- \
+   add-bond br0 bond0 p1 p2 p3 bond_mode=balance-tcp lacp=active \
+                               other-config:lacp-time=fast \
+                               other-config:bond-rebalance-interval=0 -- \
+   set interface p1 type=dummy options:peer=p4 -- \
+   set interface p2 type=dummy options:peer=p5 -- \
+   set interface p3 type=dummy options:peer=p6 -- \
+   add-br br1 -- \
+   set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 \
+                  datapath-type=dummy other-config:datapath-id=1234 -- \
+   add-bond br1 bond1 p4 p5 p6 bond_mode=balance-tcp lacp=active \
+                               other-config:lacp-time=fast \
+                               other-config:bond-rebalance-interval=1000 -- \
+   set interface br1 options:rx_pcap=br0.pcap -- \
+   set interface p4 type=dummy options:peer=p1 -- \
+   set interface p5 type=dummy options:peer=p2 -- \
+   set interface p6 type=dummy options:peer=p3 -- \
+   set Bridge br1 netflow=@nf -- \
+   --id=@nf create NetFlow targets=\"127.0.0.1:$NETFLOW_PORT\" \
+     engine_id=1 engine_type=2 active_timeout=1 \
+     add-id-to-interface=false], [<0>
+])
+
+ON_EXIT([kill `cat test-netflow.pid`])
+AT_CHECK([test-netflow --detach --no-chdir --pidfile $NETFLOW_PORT:127.0.0.1 > 
netflow.log])
+AT_CAPTURE_FILE([netflow.log])
+
+read_ports () {
+    bridge=$1; shift
+    for port
+    do
+        AS_VAR_SET([${bridge}_p${port}_rx], [0])
+        AS_VAR_SET([${bridge}_p${port}_tx], [0])
+    done
+    ovs-ofctl dump-ports $bridge > $bridge.ports
+    sed -n '1d
+N
+s/.*port *\([[0-9]]*\): rx pkts=\([[0-9]]*\),.*tx 
pkts=\([[0-9]]*\),.*/'$bridge'_p\1_rx=\2 '$bridge'_p\1_tx=\3/p' < $bridge.ports 
> $bridge.ports.sh
+    . ./$bridge.ports.sh
+    for port
+    do
+        AS_VAR_COPY([rx], [${bridge}_p${port}_rx])
+        AS_VAR_COPY([tx], [${bridge}_p${port}_tx])
+        echo ${bridge}_p${port}_rx=$rx ${bridge}_p${port}_tx=$tx
+    done
+}
+
+AT_CHECK([ovs-appctl time/stop])
+AT_CHECK([ovs-appctl netdev-dummy/set-admin-state up], 0, [OK
+])
+
+# Wait for up to 5 (simulated) seconds, until LACP negotiation finishes.
+i=0
+while :; do
+    ovs-appctl lacp/show bond0 > bond0
+    AT_CAPTURE_FILE([bond0])
+    ovs-appctl lacp/show bond1 > bond1
+    AT_CAPTURE_FILE([bond1])
+    if grep negotiated bond0 && grep negotiated bond1; then
+        if grep expired bond0 || grep expired bond1; then
+            :
+        else
+            break
+        fi
+    fi
+    i=`expr $i + 1`
+    AT_FAIL_IF([test $i = 50])
+    ovs-appctl time/warp 100
+done
+
+# Start sending packets between the bridges,
+# at a rate of 125 kB/s with max-length Ethernet frames.
+AT_CHECK([ovs-appctl netdev-dummy/pktgen br0 1 100 100000 icmpv6 1 
cc:66:cc:66:cc:66 aa:55:aa:55:aa:55])
+
+for i in `seq 1 25`; do
+    AT_CHECK([ovs-appctl netdev-dummy/pktgen br1 125 1514 3000 icmpv6 $i 
aa:55:aa:55:aa:55 cc:66:cc:66:cc:`printf %02d $i`])
+    for i in `seq 1 10`; do ovs-appctl time/warp 100; done
+done
+
+read_ports br0 1 2 3 65534
+read_ports br1 4 5 6 65534
+OVS_VSWITCHD_STOP
+ovs-appctl -t test-netflow exit
+AT_CLEANUP
diff --git a/tests/lacp.at b/tests/lacp.at
index e9c1948..81613d6 100644
--- a/tests/lacp.at
+++ b/tests/lacp.at
@@ -156,9 +156,7 @@ while :; do
         fi
     fi
     i=`expr $i + 1`
-    if test $i = 50; then
-        AT_FAIL_IF([:])
-    fi
+    AT_FAIL_IF([test $i = 50])
     ovs-appctl time/warp 100
 done
 
diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 585bcae..0535dbb 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -50,7 +50,7 @@ m4_define([OVS_VSWITCHD_START],
    AT_CHECK([ovs-vsctl --no-wait init])
 
    dnl Start ovs-vswitchd.
-   AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --enable-dummy 
--disable-system --log-file -vvconn -vofproto_dpif], [0], [], [stderr])
+   AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --enable-dummy 
--disable-system --log-file -vvconn -vofproto_dpif -vbond], [0], [], [stderr])
    AT_CAPTURE_FILE([ovs-vswitchd.log])
    AT_CHECK([[sed < stderr '
 /vlog|INFO|opened log file/d
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 2b4ccdb..7cc9cf6 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -67,6 +67,7 @@ EOF
 m4_include([tests/ovsdb-macros.at])
 m4_include([tests/ofproto-macros.at])
 
+m4_include([tests/bond.at])
 m4_include([tests/lacp.at])
 m4_include([tests/library.at])
 m4_include([tests/heap.at])
-- 
1.7.2.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to