The new userspace-testsuite, which can be launched via `make
check-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 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 <diproiet...@vmware.com>
---
 tests/.gitignore               |  1 +
 tests/automake.mk              | 21 +++++++++++++++++++--
 tests/kmod-macros.at           | 19 ++++++++++++-------
 tests/traffic-common-macros.at |  7 ++++---
 tests/traffic.at               | 26 +++++++++++++-------------
 tests/userspace-macros.at      | 41 +++++++++++++++++++++++++++++++++++++++++
 tests/userspace-testsuite.at   | 23 +++++++++++++++++++++++
 7 files changed, 113 insertions(+), 25 deletions(-)
 create mode 100644 tests/userspace-macros.at
 create mode 100644 tests/userspace-testsuite.at

diff --git a/tests/.gitignore b/tests/.gitignore
index 9d0be33..37e9089 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -50,3 +50,4 @@
 /testsuite.log
 /test-lib
 /testsuite.tmp.orig
+/userspace-testsuite
diff --git a/tests/automake.mk b/tests/automake.mk
index 502bbd5..b2287fe 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -1,9 +1,12 @@
 EXTRA_DIST += \
        $(COMMON_MACROS_AT) \
        $(TESTSUITE_AT) \
+       $(TRAFFIC_TESTSUITE_AT) \
        $(KMOD_TESTSUITE_AT) \
+       $(USERSPACE_TESTSUITE_AT) \
        $(TESTSUITE) \
        $(KMOD_TESTSUITE) \
+       $(USERSPACE_TESTSUITE) \
        tests/atlocal.in \
        $(srcdir)/package.m4 \
        $(srcdir)/tests/testsuite \
@@ -87,13 +90,20 @@ TESTSUITE_AT = \
 
 KMOD_TESTSUITE_AT = \
        tests/kmod-testsuite.at \
-       tests/kmod-macros.at \
+       tests/kmod-macros.at
+
+USERSPACE_TESTSUITE_AT = \
+       tests/userspace-testsuite.at \
+       tests/userspace-macros.at
+
+TRAFFIC_TESTSUITE_AT = \
        tests/traffic-common-macros.at \
        tests/traffic.at
 
 TESTSUITE = $(srcdir)/tests/testsuite
 TESTSUITE_PATCH = $(srcdir)/tests/testsuite.patch
 KMOD_TESTSUITE = $(srcdir)/tests/kmod-testsuite
+USERSPACE_TESTSUITE = $(srcdir)/tests/userspace-testsuite
 DISTCLEANFILES += tests/atconfig tests/atlocal
 
 AUTOTEST_PATH = utilities:vswitchd:ovsdb:vtep:tests:$(PTHREAD_WIN32_DIR_DLL)
@@ -199,6 +209,9 @@ check-kmod: all tests/atconfig tests/atlocal 
$(KMOD_TESTSUITE)
        modprobe -r openvswitch
        $(MAKE) check-kernel
 
+check-userspace: all tests/atconfig tests/atlocal $(USERSPACE_TESTSUITE)
+       $(SHELL) '$(USERSPACE_TESTSUITE)' -C tests  
AUTOTEST_PATH='$(AUTOTEST_PATH)' $(TESTSUITEFLAGS)
+
 clean-local:
        test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean
 
@@ -215,7 +228,11 @@ $(TESTSUITE): package.m4 $(TESTSUITE_AT) 
$(COMMON_MACROS_AT)
        $(AM_V_at)mv $@.tmp $@
 endif
 
-$(KMOD_TESTSUITE): package.m4 $(KMOD_TESTSUITE_AT) $(COMMON_MACROS_AT)
+$(KMOD_TESTSUITE): package.m4 $(TRAFFIC_TESTSUITE_AT) $(KMOD_TESTSUITE_AT) 
$(COMMON_MACROS_AT)
+       $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
+       $(AM_V_at)mv $@.tmp $@
+
+$(USERSPACE_TESTSUITE): package.m4 $(TRAFFIC_TESTSUITE_AT) 
$(USERSPACE_TESTSUITE_AT) $(COMMON_MACROS_AT)
        $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
        $(AM_V_at)mv $@.tmp $@
 
diff --git a/tests/kmod-macros.at b/tests/kmod-macros.at
index 902f8e1..8a4ac5e 100644
--- a/tests/kmod-macros.at
+++ b/tests/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/traffic-common-macros.at b/tests/traffic-common-macros.at
index bd622d2..1268de5 100644
--- a/tests/traffic-common-macros.at
+++ b/tests/traffic-common-macros.at
@@ -7,7 +7,7 @@ m4_define([DEL_NAMESPACES],
 ])
    ]
 )
-#
+
 # ADD_NAMESPACES(ns [, ns ... ])
 #
 # Add new namespaces, if ns exists, the old one
@@ -32,10 +32,11 @@ m4_define([ADD_NAMESPACES],
 # The existing 'port' or 'ovs-port' will be removed before new ones are added.
 #
 m4_define([ADD_VETH],
-    [ AT_CHECK([ip link add $1 type veth peer name ovs-$1])
+    [ ip link del ovs-$1
+      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])
       AT_CHECK([ip netns exec $2 ip addr add $4 dev $1])
       AT_CHECK([ip netns exec $2 ip link set dev $1 up])
     ]
diff --git a/tests/traffic.at b/tests/traffic.at
index 9df8b62..8c588b6 100644
--- a/tests/traffic.at
+++ b/tests/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/userspace-macros.at b/tests/userspace-macros.at
new file mode 100644
index 0000000..2c58109
--- /dev/null
+++ b/tests/userspace-macros.at
@@ -0,0 +1,41 @@
+# 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/userspace-testsuite.at b/tests/userspace-testsuite.at
new file mode 100644
index 0000000..5e40ec4
--- /dev/null
+++ b/tests/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/userspace-macros.at])
+m4_include([tests/traffic-common-macros.at])
+
+m4_include([tests/traffic.at])
-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to