[ovs-dev] [PATCH] tests: Add test for ovs-vswitchd regression with empty db.

Ben Pfaff blp at nicira.com
Thu Apr 11 21:10:05 UTC 2013


Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 tests/automake.mk     |    1 +
 tests/ovs-vswitchd.at |   27 +++++++++++++++++++++++++++
 tests/testsuite.at    |    3 ++-
 3 files changed, 30 insertions(+), 1 deletions(-)
 create mode 100644 tests/ovs-vswitchd.at

diff --git a/tests/automake.mk b/tests/automake.mk
index 275ff53..b9dbf3b 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -35,6 +35,7 @@ TESTSUITE_AT = \
 	tests/tunnel.at \
 	tests/lockfile.at \
 	tests/reconnect.at \
+	tests/ovs-vswitchd.at \
 	tests/ofproto-dpif.at \
 	tests/ofproto-macros.at \
 	tests/ofproto.at \
diff --git a/tests/ovs-vswitchd.at b/tests/ovs-vswitchd.at
new file mode 100644
index 0000000..c552741
--- /dev/null
+++ b/tests/ovs-vswitchd.at
@@ -0,0 +1,27 @@
+AT_BANNER([ovs-vswitchd])
+
+dnl The OVS initscripts never make an empty database (one without even an
+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`])
+
+dnl Create database.
+touch .conf.db.~lock~
+AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
+
+dnl Start ovsdb-server.  *Don't* initialize database.
+AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [ignore], [ignore])
+AT_CAPTURE_FILE([ovsdb-server.log])
+
+dnl Start ovs-vswitchd.
+AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --enable-dummy --disable-system --log-file], [0], [], [stderr])
+AT_CAPTURE_FILE([ovs-vswitchd.log])
+
+dnl ovs-vswitchd detached OK or we wouldn't have made it this far.  Success.
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 97bc247..da52593 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -1,6 +1,6 @@
 AT_INIT
 
-AT_COPYRIGHT([Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+AT_COPYRIGHT([Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -95,6 +95,7 @@ m4_include([tests/timeval.at])
 m4_include([tests/tunnel.at])
 m4_include([tests/lockfile.at])
 m4_include([tests/reconnect.at])
+m4_include([tests/ovs-vswitchd.at])
 m4_include([tests/ofproto.at])
 m4_include([tests/ofproto-dpif.at])
 m4_include([tests/ovsdb.at])
-- 
1.7.2.5




More information about the dev mailing list