[ovs-dev] [PATCH v2 3/4] tests: Add system-userspace-testsuite.

Daniele Di Proietto diproiettod at vmware.com
Fri Aug 7 18:40:36 UTC 2015


The new system-userspace-testsuite, which can be launched via
`make check-system-userspace`, reuses the kmod tests on the userspace
datapath.

The userspace datapath is already tested by the main testsuite (and
that's not going to change), but having also the
system-userspace-testsuite has the following advantages:

* More complicated tests are possible: real client and server
  applications can be used.
* The same tests run on both kernel and userspace datapath: this gives
  us an easy way to make sure that the behaviour is consistent (e.g.
  with the upcoming connection tracker integration)

The userspace datapath is able to use system network interfaces via an
AF_PACKET socket.

Signed-off-by: Daniele Di Proietto <diproiettod at vmware.com>
---
 tests/.gitignore                    |  1 +
 tests/automake.mk                   | 22 ++++++++++++++++++--
 tests/system-common-macros.at       |  3 ++-
 tests/system-kmod-macros.at         | 19 +++++++++++-------
 tests/system-traffic.at             | 26 ++++++++++++------------
 tests/system-userspace-macros.at    | 40 +++++++++++++++++++++++++++++++++++++
 tests/system-userspace-testsuite.at | 23 +++++++++++++++++++++
 7 files changed, 111 insertions(+), 23 deletions(-)
 create mode 100644 tests/system-userspace-macros.at
 create mode 100644 tests/system-userspace-testsuite.at

diff --git a/tests/.gitignore b/tests/.gitignore
index 98a42f9..f4540a3 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -11,6 +11,7 @@
 /ovs-pki.log
 /pki/
 /system-kmod-testsuite
+/system-userspace-testsuite
 /test-aes128
 /test-atomic
 /test-bundle
diff --git a/tests/automake.mk b/tests/automake.mk
index 9e428ea..20bcb3f 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -1,9 +1,12 @@
 EXTRA_DIST += \
 	$(COMMON_MACROS_AT) \
 	$(TESTSUITE_AT) \
+	$(SYSTEM_TESTSUITE_AT) \
 	$(SYSTEM_KMOD_TESTSUITE_AT) \
+	$(SYSTEM_USERSPACE_TESTSUITE_AT) \
 	$(TESTSUITE) \
 	$(SYSTEM_KMOD_TESTSUITE) \
+	$(SYSTEM_USERSPACE_TESTSUITE) \
 	tests/atlocal.in \
 	$(srcdir)/package.m4 \
 	$(srcdir)/tests/testsuite \
@@ -88,12 +91,20 @@ TESTSUITE_AT = \
 SYSTEM_KMOD_TESTSUITE_AT = \
 	tests/system-common-macros.at \
 	tests/system-kmod-testsuite.at \
-	tests/system-kmod-macros.at \
+	tests/system-kmod-macros.at
+
+SYSTEM_USERSPACE_TESTSUITE_AT = \
+	tests/system-userspace-testsuite.at \
+	tests/system-userspace-macros.at
+
+SYSTEM_TESTSUITE_AT = \
+	tests/system-common-macros.at \
 	tests/system-traffic.at
 
 TESTSUITE = $(srcdir)/tests/testsuite
 TESTSUITE_PATCH = $(srcdir)/tests/testsuite.patch
 SYSTEM_KMOD_TESTSUITE = $(srcdir)/tests/system-kmod-testsuite
+SYSTEM_USERSPACE_TESTSUITE = $(srcdir)/tests/system-userspace-testsuite
 DISTCLEANFILES += tests/atconfig tests/atlocal
 
 AUTOTEST_PATH = utilities:vswitchd:ovsdb:vtep:tests:$(PTHREAD_WIN32_DIR_DLL)
@@ -199,6 +210,9 @@ check-kmod: all tests/atconfig tests/atlocal $(SYSTEM_KMOD_TESTSUITE)
 	modprobe -r openvswitch
 	$(MAKE) check-kernel
 
+check-system-userspace: all tests/atconfig tests/atlocal $(SYSTEM_USERSPACE_TESTSUITE)
+	$(SHELL) '$(SYSTEM_USERSPACE_TESTSUITE)' -C tests  AUTOTEST_PATH='$(AUTOTEST_PATH)' $(TESTSUITEFLAGS)
+
 clean-local:
 	test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean
 
@@ -215,7 +229,11 @@ $(TESTSUITE): package.m4 $(TESTSUITE_AT) $(COMMON_MACROS_AT)
 	$(AM_V_at)mv $@.tmp $@
 endif
 
-$(SYSTEM_KMOD_TESTSUITE): package.m4 $(SYSTEM_KMOD_TESTSUITE_AT) $(COMMON_MACROS_AT)
+$(SYSTEM_KMOD_TESTSUITE): package.m4 $(SYSTEM_TESTSUITE_AT) $(SYSTEM_KMOD_TESTSUITE_AT) $(COMMON_MACROS_AT)
+	$(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
+	$(AM_V_at)mv $@.tmp $@
+
+$(SYSTEM_USERSPACE_TESTSUITE): package.m4 $(SYSTEM_TESTSUITE_AT) $(SYSTEM_USERSPACE_TESTSUITE_AT) $(COMMON_MACROS_AT)
 	$(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
 	$(AM_V_at)mv $@.tmp $@
 
diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index ccdfdc6..1321e58 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -49,10 +49,11 @@ m4_define([NS_CHECK_EXEC],
 m4_define([ADD_VETH],
     [ AT_CHECK([ip link add $1 type veth peer name ovs-$1])
       AT_CHECK([ip link set $1 netns $2])
-      AT_CHECK([ovs-vsctl add-port $3 ovs-$1])
       AT_CHECK([ip link set dev ovs-$1 up])
+      AT_CHECK([ovs-vsctl add-port $3 ovs-$1])
       NS_CHECK_EXEC([$2], [ip addr add $4 dev $1])
       NS_CHECK_EXEC([$2], [ip link set dev $1 up])
+      ON_EXIT([ip link del ovs-$1])
     ]
 )
 
diff --git a/tests/system-kmod-macros.at b/tests/system-kmod-macros.at
index c74d348..eacdc5d 100644
--- a/tests/system-kmod-macros.at
+++ b/tests/system-kmod-macros.at
@@ -1,4 +1,10 @@
-# OVS_KMOD_VSWITCHD_START([vsctl-args], [vsctl-output], [=override])
+# ADD_BR([name])
+#
+# Expands into the proper ovs-vsctl commands to create a bridge with the
+# appropriate type
+m4_define([ADD_BR], [[add-br $1]])
+
+# OVS_TRAFFIC_VSWITCHD_START([vsctl-args], [vsctl-output], [=override])
 #
 # Creates a database and starts ovsdb-server, starts ovs-vswitchd
 # connected to that database, calls ovs-vsctl to create a bridge named
@@ -7,23 +13,22 @@
 # output (e.g. because it includes "create" commands) then 'vsctl-output'
 # specifies the expected output after filtering through uuidfilt.pl.
 #
-m4_define([OVS_KMOD_VSWITCHD_START],
+m4_define([OVS_TRAFFIC_VSWITCHD_START],
   [ AT_CHECK([modprobe openvswitch])
     ON_EXIT([modprobe -r openvswitch])
    _OVS_VSWITCHD_START([])
    dnl Add bridges, ports, etc.
-   AT_CHECK([ovs-vsctl -- add-br br0 -- set bridge br0 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15]] fail-mode=secure -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2])
+   AT_CHECK([ovs-vsctl -- ADD_BR([br0]) -- set bridge br0 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15]] fail-mode=secure -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2])
 ])
-#
-#
-# OVS_KMOD_VSWITCHD_STOP([WHITELIST], [extra_cmds])
+
+# OVS_TRAFFIC_VSWITCHD_STOP([WHITELIST], [extra_cmds])
 #
 # Gracefully stops ovs-vswitchd and ovsdb-server, checking their log files
 # for messages with severity WARN or higher and signaling an error if any
 # is present.  The optional WHITELIST may contain shell-quoted "sed"
 # commands to delete any warnings that are actually expected, e.g.:
 #
-#   OVS_KMOD_VSWITCHD_STOP(["/expected error/d"])
+#   OVS_TRAFFIC_VSWITCHD_STOP(["/expected error/d"])
 #
 # 'extra_cmds' are shell commands to be executed afte OVS_VSWITCHD_STOP() is
 # invoked. They can be used to perform additional cleanups such as name space
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 34342d6..1ff2286 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -1,7 +1,7 @@
-AT_BANNER([kmod-sanity])
+AT_BANNER([datapath-sanity])
 
-AT_SETUP([kmod - ping between two ports])
-OVS_KMOD_VSWITCHD_START(
+AT_SETUP([datapath - ping between two ports])
+OVS_TRAFFIC_VSWITCHD_START(
    [set-fail-mode br0 standalone -- ])
 
 ADD_NAMESPACES(at_ns0, at_ns1)
@@ -20,11 +20,11 @@ AT_CHECK([cat ping.output | grep "transmitted" | sed 's/time.*ms$/time 0ms/'], [
 3 packets transmitted, 3 received, 0% packet loss, time 0ms
 ])
 
-OVS_KMOD_VSWITCHD_STOP
+OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
-AT_SETUP([kmod - ping between two ports on vlan])
-OVS_KMOD_VSWITCHD_START(
+AT_SETUP([datapath - ping between two ports on vlan])
+OVS_TRAFFIC_VSWITCHD_START(
    [set-fail-mode br0 standalone -- ])
 
 ADD_NAMESPACES(at_ns0, at_ns1)
@@ -46,11 +46,11 @@ AT_CHECK([cat ping.output | grep "transmitted" | sed 's/time.*ms$/time 0ms/'], [
 3 packets transmitted, 3 received, 0% packet loss, time 0ms
 ])
 
-OVS_KMOD_VSWITCHD_STOP
+OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
-AT_SETUP([kmod - ping6 between two ports])
-OVS_KMOD_VSWITCHD_START(
+AT_SETUP([datapath - ping6 between two ports])
+OVS_TRAFFIC_VSWITCHD_START(
    [set-fail-mode br0 standalone -- ])
 
 ADD_NAMESPACES(at_ns0, at_ns1)
@@ -73,11 +73,11 @@ AT_CHECK([cat ping.output | grep "transmitted" | sed 's/time.*ms$/time 0ms/'], [
 3 packets transmitted, 3 received, 0% packet loss, time 0ms
 ])
 
-OVS_KMOD_VSWITCHD_STOP
+OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
-AT_SETUP([kmod - ping6 between two ports on vlan])
-OVS_KMOD_VSWITCHD_START(
+AT_SETUP([datapath - ping6 between two ports on vlan])
+OVS_TRAFFIC_VSWITCHD_START(
    [set-fail-mode br0 standalone -- ])
 
 ADD_NAMESPACES(at_ns0, at_ns1)
@@ -103,5 +103,5 @@ AT_CHECK([cat ping.output | grep "transmitted" | sed 's/time.*ms$/time 0ms/'], [
 3 packets transmitted, 3 received, 0% packet loss, time 0ms
 ])
 
-OVS_KMOD_VSWITCHD_STOP
+OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
diff --git a/tests/system-userspace-macros.at b/tests/system-userspace-macros.at
new file mode 100644
index 0000000..b273576
--- /dev/null
+++ b/tests/system-userspace-macros.at
@@ -0,0 +1,40 @@
+# ADD_BR([name])
+#
+# Expands into the proper ovs-vsctl commands to create a bridge with the
+# appropriate type
+m4_define([ADD_BR], [[add-br $1 -- set Bridge $1 datapath_type="netdev" ]])
+
+# OVS_TRAFFIC_VSWITCHD_START([vsctl-args], [vsctl-output], [=override])
+#
+# Creates a database and starts ovsdb-server, starts ovs-vswitchd
+# connected to that database, calls ovs-vsctl to create a bridge named
+# br0 with predictable settings, passing 'vsctl-args' as additional
+# commands to ovs-vsctl.  If 'vsctl-args' causes ovs-vsctl to provide
+# output (e.g. because it includes "create" commands) then 'vsctl-output'
+# specifies the expected output after filtering through uuidfilt.pl.
+m4_define([OVS_TRAFFIC_VSWITCHD_START],
+  [
+   _OVS_VSWITCHD_START([--disable-system])
+   dnl Add bridges, ports, etc.
+   AT_CHECK([ovs-vsctl -- ADD_BR([br0]) -- set bridge br0 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15]] fail-mode=secure -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2])
+])
+
+# OVS_TRAFFIC_VSWITCHD_STOP([WHITELIST], [extra_cmds])
+#
+# Gracefully stops ovs-vswitchd and ovsdb-server, checking their log files
+# for messages with severity WARN or higher and signaling an error if any
+# is present.  The optional WHITELIST may contain shell-quoted "sed"
+# commands to delete any warnings that are actually expected, e.g.:
+#
+#   OVS_TRAFFIC_VSWITCHD_STOP(["/expected error/d"])
+#
+# 'extra_cmds' are shell commands to be executed afte OVS_VSWITCHD_STOP() is
+# invoked. They can be used to perform additional cleanups such as name space
+# removal.
+m4_define([OVS_TRAFFIC_VSWITCHD_STOP],
+  [AT_CHECK([ovs-vsctl del-br br0])
+   OVS_VSWITCHD_STOP([dnl
+"/netdev_linux.*obtaining netdev stats via vport failed/d
+/dpif_netlink.*Generic Netlink family 'ovs_datapath' does not exist. The Open vSwitch kernel module is probably not loaded./d"])
+   AT_CHECK([:; $2])
+  ])
diff --git a/tests/system-userspace-testsuite.at b/tests/system-userspace-testsuite.at
new file mode 100644
index 0000000..239e6ea
--- /dev/null
+++ b/tests/system-userspace-testsuite.at
@@ -0,0 +1,23 @@
+AT_INIT
+
+AT_COPYRIGHT([Copyright (c) 2015 Nicira, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at:
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.])
+
+m4_include([tests/ovs-macros.at])
+m4_include([tests/ovsdb-macros.at])
+m4_include([tests/ofproto-macros.at])
+m4_include([tests/system-userspace-macros.at])
+m4_include([tests/system-common-macros.at])
+
+m4_include([tests/system-traffic.at])
-- 
2.1.4




More information about the dev mailing list