datapath-windows: Rename OvsGetVportNo into OvsComputeVportNo and make public
[cascardo/ovs.git] / tests / ovs-vswitchd.at
index 2c72a7f..3b7c516 100644 (file)
@@ -72,34 +72,84 @@ AT_SETUP([ovs-vswitchd -- start additional ovs-vswitchd process])
 OVS_VSWITCHD_START
 
 # start another ovs-vswitchd process.
-ovs-vswitchd --log-file=fakelog &
-pid=`echo $!`
+ovs-vswitchd --log-file=fakelog --unixctl="`pwd`"/unixctl &
 
 # sleep for a while
 sleep 5
 
 # stop the process.
-kill $pid
+ovs-appctl -t `pwd`/unixctl exit
 
 # check the fakelog, should only see one ERR for reporting
-# the existing ovs-vswitchd process and one WARN for killing
-# the process.
-AT_CHECK([grep ERR fakelog | wc -l], [0], [dnl
-1
+# 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
 ])
 
-AT_CHECK([grep WARN fakelog | wc -l], [0], [dnl
-1
+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
 ])
 
-AT_CHECK([grep ERR fakelog | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl
-another ovs-vswitchd process is running, disabling this process () until it goes away
+# 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
 ])
 
-# check the fakelog, the ERR log should be the last line.
-AT_CHECK([tail -n 2 fakelog | head -n 1 | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl
-another ovs-vswitchd process is running, disabling this process () until it goes away
+# cleanup.
+kill `cat ovsdb-server.pid`
+AT_CLEANUP
+
+dnl ----------------------------------------------------------------------
+AT_SETUP([ovs-vswitchd -- invalid database path])
+
+# start an ovs-vswitchd process with invalid db path.
+ovs-vswitchd unix:invalid.db.sock --log-file=fakelog --enable-dummy --unixctl="`pwd`"/unixctl &
+
+# sleep for a while.
+sleep 10
+
+# stop the process.
+ovs-appctl -t `pwd`/unixctl exit
+
+# should not see this log (which indicates high cpu utilization).
+AT_CHECK([grep "wakeup due to" fakelog], [ignore])
+
+# check the fakelog, should not see any WARN/ERR/EMER log.
+AT_CHECK([sed -n "
+/|WARN|/p
+/|ERR|/p
+/|EMER|/p" fakelog
 ])
 
-OVS_VSWITCHD_STOP
 AT_CLEANUP