[ovs-dev] [PATCH] tests: Add support for running OFTest.

Ben Pfaff blp at nicira.com
Sat Oct 27 06:35:34 UTC 2012


Signed-off-by: Ben Pfaff <blp at nicira.com>
---
This is an additional commit that, applied on top of the series that
I posted yesterday, makes it possible to run OFTest against an
Open vSwitch build tree with just "make check-oftest".

The previous series starts here:
	http://openvswitch.org/pipermail/dev/2012-October/022300.html

 Makefile.am       |    1 +
 NEWS              |    2 ++
 README-OFTest     |   68 ++++++++++++++++++++++++++++++++++++++
 tests/automake.mk |    6 ++++
 tests/run-oftest  |   94 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 171 insertions(+)
 create mode 100644 README-OFTest
 create mode 100755 tests/run-oftest

diff --git a/Makefile.am b/Makefile.am
index dafba2b..13309a7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,6 +54,7 @@ EXTRA_DIST = \
 	IntegrationGuide \
 	NOTICE \
 	PORTING \
+	README-OFTest \
 	README-gcov \
 	REPORTING-BUGS \
 	SubmittingPatches \
diff --git a/NEWS b/NEWS
index fa0a249..f138d0f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
 post-v1.9.0
 --------------------
+    - New "check-oftest" Makefile target for running OFTest against Open
+      vSwitch.  See README-OFTest for details.
 
 
 v1.9.0 - xx xxx xxxx
diff --git a/README-OFTest b/README-OFTest
new file mode 100644
index 0000000..0155894
--- /dev/null
+++ b/README-OFTest
@@ -0,0 +1,68 @@
+		 How to Use OFTest With Open vSwitch
+		 ===================================
+
+This document describes how to use the OFTest OpenFlow protocol
+testing suite with Open vSwitch in "dummy mode".  In this mode of
+testing, no packets travel across physical or virtual networks.
+Instead, Unix domain sockets stand in as simulated networks.  This
+simulation is imperfect, but it is much easier to set up, does not
+require extra physical or virtual hardware, and does not require
+supervisor privileges.
+
+Prerequisites
+-------------
+
+First, build Open vSwitch according to the instructions in INSTALL.
+You need not install it.
+
+Second, obtain a copy of OFTest, then install the prerequisites and
+build the OpenFlow message classes described in its top-level README.
+The version of OFTest you use must be new enough to include a file
+named platforms/ovs-dummy.py, which provides OVS dummy mode support.
+Testing OVS in dummy mode does not require root privilege, so you may
+ignore that requirement.
+
+Optionally, add the top-level OFTest directory (containing the "oft"
+program) to your $PATH.  This slightly simplifies running OFTest later.
+
+Running OFTest
+--------------
+
+To run OFTest in dummy mode, run the following command from your Open
+vSwitch build directory:
+
+    make check-oftest OFT=<oft-binary>
+
+where <oft-binary> is the absolute path to the "oft" program in
+OFTest.
+
+If you added "oft" to your $PATH, you may omit the OFT variable
+assignment:
+
+    make check-oftest
+
+By default, "check-oftest" passes "oft" just enough options to enable
+dummy mode.  You can use OFTFLAGS to pass additional options.  For
+example, to run just the basic.Echo test instead of all tests (the
+default) and enable verbose logging:
+
+    make check-oftest OFT=<oft-binary> OFTFLAGS='--verbose -T basic.Echo'
+
+Interpreting OFTest Results
+---------------------------
+
+Please interpret OFTest results cautiously.  Open vSwitch can fail a
+given test in OFTest for many reasons, including bugs in Open vSwitch,
+bugs in OFTest, bugs in the "dummy mode" integration, and differing
+interpretations of the OpenFlow standard and other standards.
+
+Open vSwitch has not been validated against OFTest.  Please do report
+test failures that you believe to represent bugs in Open vSwitch.
+Include the precise versions of Open vSwitch and OFTest in your bug
+report, plus any other information needed to reproduce the problem.
+
+Contact 
+-------
+
+bugs at openvswitch.org
+http://openvswitch.org/
diff --git a/tests/automake.mk b/tests/automake.mk
index 600056e..d7fcc15 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -144,6 +144,12 @@ check-valgrind: all tests/atconfig tests/atlocal $(TESTSUITE) \
 	@echo 'Valgrind output can be found in tests/testsuite.dir/*/valgrind.*'
 	@echo '----------------------------------------------------------------------'
 
+# OFTest support.
+
+check-oftest: all
+	srcdir='$(srcdir)' $(SHELL) $(srcdir)/tests/run-oftest
+EXTRA_DIST += tests/run-oftest
+
 clean-local:
 	test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean
 
diff --git a/tests/run-oftest b/tests/run-oftest
new file mode 100755
index 0000000..d12a22f
--- /dev/null
+++ b/tests/run-oftest
@@ -0,0 +1,94 @@
+#! /bin/sh
+
+set -e
+
+run () {
+    echo "$@"
+    "$@" || exit 1
+}
+
+# Put built tools early in $PATH.
+builddir=`pwd`
+if test ! -e vswitchd/ovs-vswitchd; then
+    echo >&2 'not in build directory, please change directory or run via \"make check-oftest'
+    exit 1
+fi
+PATH=$builddir/ovsdb:$builddir/vswitchd:$builddir/utilities:$PATH; export PATH
+
+# Find srcdir.
+case $srcdir in
+    '') srcdir=$builddir ;;
+    /*) ;;
+    *) srcdir=`pwd`/$srcdir ;;
+esac
+if test ! -e "$srcdir"/WHY-OVS; then
+    echo >&2 'source directory not found, please set $srcdir or run via \"make check-oftest'
+    exit 1
+fi
+
+# Make sure oftest is available.
+if test X"$OFT" = X; then
+    OFT=oft
+fi
+if ($OFT --version) >/dev/null 2>&1; then
+    :
+else
+    echo >&2 'OFTest "oft" binary not found or cannot be run, please add to $PATH or set $OFT'
+    exit 1
+fi
+
+# Create sandbox.
+rm -rf sandbox
+mkdir sandbox
+cd sandbox
+sandbox=`pwd`
+
+# Set up environment for OVS programs to sandbox themselves.
+OVS_RUNDIR=$sandbox; export OVS_RUNDIR
+OVS_LOGDIR=$sandbox; export OVS_LOGDIR
+OVS_DBDIR=$sandbox; export OVS_DBDIR
+OVS_SYSCONFDIR=$sandbox; export OVS_SYSCONFDIR
+
+trap 'kill `cat *.pid`' 0 1 2 3 13 14 15
+
+# Create database and start ovsdb-server.
+touch .conf.db.~lock~
+rm -f conf.db
+run ovsdb-tool create conf.db "$srcdir"/vswitchd/vswitch.ovsschema
+run ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
+    --remote=punix:"$sandbox"/db.sock
+
+# Start ovs-vswitchd.
+run ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file \
+    --enable-dummy --disable-system -vvconn -vnetdev_dummy
+
+# Add a bridge and some ports for OFTest to use,
+# and configure ovs-vswitchd to connect to OFTest.
+run ovs-vsctl --no-wait \
+    -- add-br br0 \
+    -- set bridge br0 datapath-type=dummy fail-mode=secure
+for port in p1 p2 p3 p4; do
+    run ovs-vsctl --no-wait \
+	-- add-port br0 $port \
+	-- set interface $port type=dummy \
+                               options:pstream=punix:$OVS_RUNDIR/$port
+done
+run ovs-vsctl \
+    -- set-controller br0 tcp:127.0.0.1 \
+    -- set controller br0 connection-mode=out-of-band max-backoff=1000
+
+# Run OFTest.
+run $OFT -P ovs-dummy $OFTFLAGS; status=$?
+
+cat <<EOF
+
+----------------------------------------------------------------------
+Logs may be found under $sandbox, e.g.:
+	$sandbox/oft.log
+	$sandbox/ovs-vswitchd.log
+	$sandbox/ovsdb-server.log
+----------------------------------------------------------------------
+EOF
+
+# Propagate OFTest exit status.
+exit $status
-- 
1.7.10.4




More information about the dev mailing list