Skip to content

Commit 81a114e

Browse files
committed
tests: Add support for running OFTest.
Signed-off-by: Ben Pfaff <blp@nicira.com>
1 parent eab5611 commit 81a114e

5 files changed

Lines changed: 173 additions & 0 deletions

File tree

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ EXTRA_DIST = \
5555
NOTICE \
5656
OPENFLOW-1.1+ \
5757
PORTING \
58+
README-OFTest \
5859
README-gcov \
5960
README-lisp \
6061
REPORTING-BUGS \

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ post-v1.11.0
44
* New support for matching outer source and destination IP address
55
of tunneled packets, for tunnel ports configured with the newly
66
added "remote_ip=flow" and "local_ip=flow" options.
7+
- New "check-oftest" Makefile target for running OFTest against Open
8+
vSwitch. See README-OFTest for details.
79

810

911
v1.11.0 - xx xxx xxxx

README-OFTest

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
How to Use OFTest With Open vSwitch
2+
===================================
3+
4+
This document describes how to use the OFTest OpenFlow protocol
5+
testing suite with Open vSwitch in "dummy mode". In this mode of
6+
testing, no packets travel across physical or virtual networks.
7+
Instead, Unix domain sockets stand in as simulated networks. This
8+
simulation is imperfect, but it is much easier to set up, does not
9+
require extra physical or virtual hardware, and does not require
10+
supervisor privileges.
11+
12+
Prerequisites
13+
-------------
14+
15+
First, build Open vSwitch according to the instructions in INSTALL.
16+
You need not install it.
17+
18+
Second, obtain a copy of OFTest and install its prerequisites. You
19+
need a copy of OFTest that includes commit 406614846c5 (make ovs-dummy
20+
platform work again). This commit was merged into the OFTest
21+
repository on Feb 1, 2013, so any copy of OFTest more recent than that
22+
should work.
23+
24+
Testing OVS in dummy mode does not require root privilege, so you may
25+
ignore that requirement.
26+
27+
Optionally, add the top-level OFTest directory (containing the "oft"
28+
program) to your $PATH. This slightly simplifies running OFTest later.
29+
30+
Running OFTest
31+
--------------
32+
33+
To run OFTest in dummy mode, run the following command from your Open
34+
vSwitch build directory:
35+
36+
make check-oftest OFT=<oft-binary>
37+
38+
where <oft-binary> is the absolute path to the "oft" program in
39+
OFTest.
40+
41+
If you added "oft" to your $PATH, you may omit the OFT variable
42+
assignment:
43+
44+
make check-oftest
45+
46+
By default, "check-oftest" passes "oft" just enough options to enable
47+
dummy mode. You can use OFTFLAGS to pass additional options. For
48+
example, to run just the basic.Echo test instead of all tests (the
49+
default) and enable verbose logging:
50+
51+
make check-oftest OFT=<oft-binary> OFTFLAGS='--verbose -T basic.Echo'
52+
53+
Interpreting OFTest Results
54+
---------------------------
55+
56+
Please interpret OFTest results cautiously. Open vSwitch can fail a
57+
given test in OFTest for many reasons, including bugs in Open vSwitch,
58+
bugs in OFTest, bugs in the "dummy mode" integration, and differing
59+
interpretations of the OpenFlow standard and other standards.
60+
61+
Open vSwitch has not been validated against OFTest. Please do report
62+
test failures that you believe to represent bugs in Open vSwitch.
63+
Include the precise versions of Open vSwitch and OFTest in your bug
64+
report, plus any other information needed to reproduce the problem.
65+
66+
Contact
67+
-------
68+
69+
bugs@openvswitch.org
70+
http://openvswitch.org/

tests/automake.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ check-valgrind: all tests/atconfig tests/atlocal $(TESTSUITE) \
145145
@echo 'Valgrind output can be found in tests/testsuite.dir/*/valgrind.*'
146146
@echo '----------------------------------------------------------------------'
147147

148+
# OFTest support.
149+
150+
check-oftest: all
151+
srcdir='$(srcdir)' $(SHELL) $(srcdir)/tests/run-oftest
152+
EXTRA_DIST += tests/run-oftest
153+
148154
clean-local:
149155
test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean
150156

tests/run-oftest

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#! /bin/sh
2+
3+
set -e
4+
5+
run () {
6+
echo "$@"
7+
"$@" || exit 1
8+
}
9+
10+
# Put built tools early in $PATH.
11+
builddir=`pwd`
12+
if test ! -e vswitchd/ovs-vswitchd; then
13+
echo >&2 'not in build directory, please change directory or run via \"make check-oftest'
14+
exit 1
15+
fi
16+
PATH=$builddir/ovsdb:$builddir/vswitchd:$builddir/utilities:$PATH; export PATH
17+
18+
# Find srcdir.
19+
case $srcdir in
20+
'') srcdir=$builddir ;;
21+
/*) ;;
22+
*) srcdir=`pwd`/$srcdir ;;
23+
esac
24+
if test ! -e "$srcdir"/WHY-OVS; then
25+
echo >&2 'source directory not found, please set $srcdir or run via \"make check-oftest'
26+
exit 1
27+
fi
28+
29+
# Make sure oftest is available.
30+
if test X"$OFT" = X; then
31+
OFT=oft
32+
fi
33+
if ($OFT --version) >/dev/null 2>&1; then
34+
:
35+
else
36+
echo >&2 'OFTest "oft" binary not found or cannot be run, please add to $PATH or set $OFT'
37+
exit 1
38+
fi
39+
40+
# Create sandbox.
41+
rm -rf sandbox
42+
mkdir sandbox
43+
cd sandbox
44+
sandbox=`pwd`
45+
46+
# Set up environment for OVS programs to sandbox themselves.
47+
OVS_RUNDIR=$sandbox; export OVS_RUNDIR
48+
OVS_LOGDIR=$sandbox; export OVS_LOGDIR
49+
OVS_DBDIR=$sandbox; export OVS_DBDIR
50+
OVS_SYSCONFDIR=$sandbox; export OVS_SYSCONFDIR
51+
52+
trap 'kill `cat *.pid`' 0 1 2 3 13 14 15
53+
54+
# Create database and start ovsdb-server.
55+
touch .conf.db.~lock~
56+
rm -f conf.db
57+
run ovsdb-tool create conf.db "$srcdir"/vswitchd/vswitch.ovsschema
58+
run ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
59+
--remote=punix:"$sandbox"/db.sock
60+
61+
# Start ovs-vswitchd.
62+
run ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file \
63+
--enable-dummy --disable-system -vvconn -vnetdev_dummy
64+
65+
# Add a bridge and some ports for OFTest to use,
66+
# and configure ovs-vswitchd to connect to OFTest.
67+
run ovs-vsctl --no-wait \
68+
-- add-br br0 \
69+
-- set bridge br0 datapath-type=dummy fail-mode=secure
70+
for port in p1 p2 p3 p4; do
71+
run ovs-vsctl --no-wait \
72+
-- add-port br0 $port \
73+
-- set interface $port type=dummy \
74+
options:pstream=punix:$OVS_RUNDIR/$port
75+
done
76+
run ovs-vsctl \
77+
-- set-controller br0 tcp:127.0.0.1 \
78+
-- set controller br0 connection-mode=out-of-band max-backoff=1000
79+
80+
# Run OFTest.
81+
run $OFT -P ovs-dummy $OFTFLAGS; status=$?
82+
83+
cat <<EOF
84+
85+
----------------------------------------------------------------------
86+
Logs may be found under $sandbox, e.g.:
87+
$sandbox/oft.log
88+
$sandbox/ovs-vswitchd.log
89+
$sandbox/ovsdb-server.log
90+
----------------------------------------------------------------------
91+
EOF
92+
93+
# Propagate OFTest exit status.
94+
exit $status

0 commit comments

Comments
 (0)