ovsdb: test ovs-vswitchd for backward compatibility
[cascardo/ovs.git] / tests / ovs-vswitchd.at
index 1040caa..492b944 100644 (file)
@@ -5,11 +5,7 @@ dnl Open_vSwitch record) visible to ovs-vswitchd, but hand-rolled scripts
 dnl sometimes do.  At one point, "ovs-vswitchd --detach" would never detach
 dnl and use 100% CPU if this happened, so this test checks for regression.
 AT_SETUP([ovs-vswitchd detaches correctly with empty db])
-OVS_RUNDIR=`pwd`; export OVS_RUNDIR
-OVS_LOGDIR=`pwd`; export OVS_LOGDIR
-OVS_DBDIR=`pwd`; export OVS_DBDIR
-OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
-ON_EXIT([kill `cat ovsdb-server.pid ovs-vswitchd.pid`])
+on_exit 'kill `cat ovsdb-server.pid ovs-vswitchd.pid`'
 
 dnl Create database.
 touch .conf.db.~lock~
@@ -72,29 +68,122 @@ 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.
+# the existing ovs-vswitchd process.
 AT_CHECK([test `grep ERR fakelog | wc -l` -eq 1])
-AT_CHECK([test `grep WARN fakelog | wc -l` -eq 1])
 
-AT_CHECK([grep ERR fakelog | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl
+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
 ])
 
-# 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
+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
+
+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
 ])
 
+AT_CLEANUP
+
+dnl ----------------------------------------------------------------------
+AT_SETUP([ovs-vswitchd -- set service controller])
+AT_SKIP_IF([test "$IS_WIN32" = "yes"])
+OVS_VSWITCHD_START
+
+AT_CHECK([ovs-vsctl set-controller br0 punix:$(pwd)/br0.void])
+OVS_WAIT_UNTIL([test -e br0.void])
+
+AT_CHECK([ovs-vsctl set-controller br0 punix:$(pwd)/br0.void/../overwrite.file])
+OVS_WAIT_UNTIL([test -n "`grep ERR ovs-vswitchd.log | grep overwrite.file`"])
+
+OVS_VSWITCHD_STOP(["/Not adding Unix domain socket controller/d"])
+AT_CLEANUP
+
+dnl ----------------------------------------------------------------------
+dnl OVSDB server before release version 2.5 does not support the monitor2
+dnl method.  This test defeatures the OVSDB server to simulate an older
+dnl OVSDB server and make sure ovs-vswitchd can still work with it
+AT_SETUP([ovs-vswitchd -- Compatible with OVSDB server - w/o monitor2)])
+OVS_VSWITCHD_START
+
+dnl defeature OVSDB server -- no monitor2
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor2])
+
+sleep 1
+
+AT_CHECK([ovs-vsctl add-port br0 p0  -- set interface p0 type=internal])
+AT_CHECK([ovs-vsctl add-port br0 p1  -- set interface p1 type=internal])
+
+dnl ovs-vswitchd should still 'see' ovsdb change with the 'monitor' method
+AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
+               br0 65534/100: (dummy)
+               p0 1/1: (dummy)
+               p1 2/2: (dummy)
+])
 OVS_VSWITCHD_STOP
 AT_CLEANUP