ovs-vswitchd.at: Port tests to run successfully on Windows.
[cascardo/ovs.git] / tests / ovs-vswitchd.at
index a90477d..d3120f7 100644 (file)
@@ -29,7 +29,7 @@ AT_CLEANUP
 
 dnl ----------------------------------------------------------------------
 m4_define([OVS_VSCTL_CHECK_RX_PKT], [
-AT_CHECK([ovs-vsctl list int $1 | grep statistics | sed -n 's/^.*\(rx_packets=[[0-9]]\+\).*$/\1/p'],[0],
+AT_CHECK([ovs-vsctl list int $1 | grep statistics | sed -n 's/^.*\(rx_packets=[[0-9]][[0-9]]*\).*$/\1/p'],[0],
 [dnl
 rx_packets=$2
 ])
@@ -39,7 +39,7 @@ AT_SETUP([ovs-vswitchd -- stats-update-interval])
 OVS_VSWITCHD_START([add-port br0 p1 -- set int p1 type=internal])
 ovs-appctl time/stop
 
-dnl at the beginning, the udpate of rx_packets should happen every 5 seconds.
+dnl at the beginning, the update of rx_packets should happen every 5 seconds.
 for i in `seq 0 10`; do ovs-appctl time/warp 1000; done
 OVS_VSCTL_CHECK_RX_PKT([p1], [0])
 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
@@ -65,4 +65,67 @@ for i in `seq 0 10`; do ovs-appctl time/warp 1000; done
 OVS_VSCTL_CHECK_RX_PKT([p1], [7])
 
 OVS_VSWITCHD_STOP
-AT_CLEANUP
\ No newline at end of file
+AT_CLEANUP
+
+dnl ----------------------------------------------------------------------
+AT_SETUP([ovs-vswitchd -- start additional ovs-vswitchd process])
+OVS_VSWITCHD_START
+
+# start another ovs-vswitchd process.
+ovs-vswitchd --log-file=fakelog --unixctl="`pwd`"/unixctl &
+
+# sleep for a while
+sleep 5
+
+# stop the process.
+ovs-appctl -t `pwd`/unixctl exit
+
+# check the fakelog, should only see one ERR for reporting
+# the existing ovs-vswitchd process.
+AT_CHECK([test `grep ERR fakelog | wc -l` -eq 1])
+
+AT_CHECK([tail -n1 fakelog | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl
+another ovs-vswitchd process is running, disabling this process () until it goes away
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+dnl ----------------------------------------------------------------------
+AT_SETUP([ovs-vswitchd -- switch over to another ovs-vswitchd process])
+OVS_VSWITCHD_START
+
+# start a new ovs-vswitchd process.
+ovs-vswitchd --log-file=fakelog --enable-dummy --unixctl="`pwd`"/unixctl &
+
+# sleep for a while.
+sleep 5
+
+# kill the current active ovs-vswitchd process.
+kill `cat ovs-vswitchd.pid`
+
+sleep 5
+
+# check the creation of br0 on the new ovs-vswitchd process.
+AT_CHECK([grep "bridge br0" fakelog | sed -e 's/port [[0-9]]*$/port/;
+s/datapath ID [[a-z0-9]]*$/datapath ID/;s/^.*INFO|//'], [0], [dnl
+bridge br0: added interface br0 on port
+bridge br0: using datapath ID
+])
+
+# stop the process.
+ovs-appctl -t `pwd`/unixctl exit
+
+# check the fakelog, should not see WARN/ERR/EMER log other than the one
+# for reporting the existing ovs-vswitchd process and the one for killing
+# the process.
+AT_CHECK([sed -n "
+/|ERR|another ovs-vswitchd process is running/d
+/|WARN|/p
+/|ERR|/p
+/|EMER|/p" fakelog
+])
+
+# cleanup.
+kill `cat ovsdb-server.pid`
+AT_CLEANUP