[ovs-dev,PATCHv2,2/2] tests: Add tests using tap device.
diff mbox series

Message ID 1582225172-78476-2-git-send-email-u9012063@gmail.com
State New
Headers show
Series
  • [ovs-dev,PATCHv2,1/2] userspace: Enable TSO support for non-DPDK.
Related show

Commit Message

William Tu Feb. 20, 2020, 6:59 p.m. UTC
Similar to using veth across namespaces, this patch creates
tap devices, assigns to namespaces, and allows traffic to
go through different test cases.

Signed-off-by: William Tu <u9012063@gmail.com>
---
 tests/atlocal.in              |  3 +++
 tests/automake.mk             |  1 +
 tests/system-tap.at           | 34 ++++++++++++++++++++++++++++++++++
 tests/system-tso-testsuite.at |  1 +
 4 files changed, 39 insertions(+)
 create mode 100644 tests/system-tap.at

Comments

Ilya Maximets March 6, 2020, 3:31 p.m. UTC | #1
On 2/20/20 7:59 PM, William Tu wrote:
> Similar to using veth across namespaces, this patch creates
> tap devices, assigns to namespaces, and allows traffic to
> go through different test cases.
> 
> Signed-off-by: William Tu <u9012063@gmail.com>
> ---
>  tests/atlocal.in              |  3 +++
>  tests/automake.mk             |  1 +
>  tests/system-tap.at           | 34 ++++++++++++++++++++++++++++++++++
>  tests/system-tso-testsuite.at |  1 +
>  4 files changed, 39 insertions(+)
>  create mode 100644 tests/system-tap.at
> 
> diff --git a/tests/atlocal.in b/tests/atlocal.in
> index 1dc7cd5d087a..a49c5047a0a5 100644
> --- a/tests/atlocal.in
> +++ b/tests/atlocal.in
> @@ -165,6 +165,9 @@ find_command()
>  # Set HAVE_NC
>  find_command nc
>  
> +# Set HAVE_TUNCTL
> +find_command tunctl

It might be better to use 'ip tuntap' instead.  It should be available
on most platforms where 'ip' is present.

> +
>  # Determine correct netcat option to quit on stdin EOF
>  if nc --version 2>&1 | grep -q nmap.org; then
>      # Nmap netcat
> diff --git a/tests/automake.mk b/tests/automake.mk
> index b8ddc069417e..b6100399f775 100644
> --- a/tests/automake.mk
> +++ b/tests/automake.mk
> @@ -158,6 +158,7 @@ SYSTEM_USERSPACE_TESTSUITE_AT = \
>  
>  SYSTEM_TSO_TESTSUITE_AT = \
>  	tests/system-tso-testsuite.at \
> +	tests/system-tap.at \
>  	tests/system-tso-macros.at
>  
>  SYSTEM_AFXDP_TESTSUITE_AT = \
> diff --git a/tests/system-tap.at b/tests/system-tap.at
> new file mode 100644
> index 000000000000..3b9015a550bb
> --- /dev/null
> +++ b/tests/system-tap.at
> @@ -0,0 +1,34 @@
> +AT_SETUP([traffic between namespaces using tap])
> +AT_KEYWORDS([http_tap])
> +OVS_TRAFFIC_VSWITCHD_START()
> +AT_SKIP_IF([test $HAVE_TUNCTL = no])
> +
> +AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
> +
> +ADD_NAMESPACES(at_ns0, at_ns1)
> +
> +AT_CHECK([tunctl -t tap0 1> /dev/null])
> +on_exit 'tunctl -d tap0'
> +AT_CHECK([tunctl -t tap1 1> /dev/null])
> +on_exit 'tunctl -d tap1'
> +
> +AT_CHECK([ovs-vsctl add-port br0 tap0 -- set int tap0 type=tap])
> +AT_CHECK([ovs-vsctl add-port br0 tap1 -- set int tap1 type=tap])
> +AT_CHECK([ip link set tap0 netns at_ns0])
> +AT_CHECK([ip link set tap1 netns at_ns1])
> +
> +AT_CHECK([ip netns exec at_ns0 ip link set dev tap0 up])
> +AT_CHECK([ip netns exec at_ns1 ip link set dev tap1 up])
> +AT_CHECK([ip netns exec at_ns0 ip addr add 10.1.1.1/24 dev tap0])
> +AT_CHECK([ip netns exec at_ns1 ip addr add 10.1.1.2/24 dev tap1])
> +
> +NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
> +3 packets transmitted, 3 received, 0% packet loss, time 0ms
> +])
> +
> +OVS_START_L7([at_ns1], [http])
> +NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
> +
> +OVS_TRAFFIC_VSWITCHD_STOP(["/.*ethtool command ETHTOOL_G.*/d"])
> +
> +AT_CLEANUP
> diff --git a/tests/system-tso-testsuite.at b/tests/system-tso-testsuite.at
> index 99d748006a86..594d1a6fde85 100644
> --- a/tests/system-tso-testsuite.at
> +++ b/tests/system-tso-testsuite.at
> @@ -23,4 +23,5 @@ m4_include([tests/system-common-macros.at])
>  m4_include([tests/system-userspace-macros.at])
>  m4_include([tests/system-tso-macros.at])
>  
> +m4_include([tests/system-tap.at])
>  m4_include([tests/system-traffic.at])
>
William Tu March 6, 2020, 7:19 p.m. UTC | #2
On Fri, Mar 6, 2020 at 7:31 AM Ilya Maximets <i.maximets@ovn.org> wrote:
>
> On 2/20/20 7:59 PM, William Tu wrote:
> > Similar to using veth across namespaces, this patch creates
> > tap devices, assigns to namespaces, and allows traffic to
> > go through different test cases.
> >
> > Signed-off-by: William Tu <u9012063@gmail.com>
> > ---
> >  tests/atlocal.in              |  3 +++
> >  tests/automake.mk             |  1 +
> >  tests/system-tap.at           | 34 ++++++++++++++++++++++++++++++++++
> >  tests/system-tso-testsuite.at |  1 +
> >  4 files changed, 39 insertions(+)
> >  create mode 100644 tests/system-tap.at
> >
> > diff --git a/tests/atlocal.in b/tests/atlocal.in
> > index 1dc7cd5d087a..a49c5047a0a5 100644
> > --- a/tests/atlocal.in
> > +++ b/tests/atlocal.in
> > @@ -165,6 +165,9 @@ find_command()
> >  # Set HAVE_NC
> >  find_command nc
> >
> > +# Set HAVE_TUNCTL
> > +find_command tunctl
>
> It might be better to use 'ip tuntap' instead.  It should be available
> on most platforms where 'ip' is present.
>
Make sense, will fix it next version.
William

Patch
diff mbox series

diff --git a/tests/atlocal.in b/tests/atlocal.in
index 1dc7cd5d087a..a49c5047a0a5 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -165,6 +165,9 @@  find_command()
 # Set HAVE_NC
 find_command nc
 
+# Set HAVE_TUNCTL
+find_command tunctl
+
 # Determine correct netcat option to quit on stdin EOF
 if nc --version 2>&1 | grep -q nmap.org; then
     # Nmap netcat
diff --git a/tests/automake.mk b/tests/automake.mk
index b8ddc069417e..b6100399f775 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -158,6 +158,7 @@  SYSTEM_USERSPACE_TESTSUITE_AT = \
 
 SYSTEM_TSO_TESTSUITE_AT = \
 	tests/system-tso-testsuite.at \
+	tests/system-tap.at \
 	tests/system-tso-macros.at
 
 SYSTEM_AFXDP_TESTSUITE_AT = \
diff --git a/tests/system-tap.at b/tests/system-tap.at
new file mode 100644
index 000000000000..3b9015a550bb
--- /dev/null
+++ b/tests/system-tap.at
@@ -0,0 +1,34 @@ 
+AT_SETUP([traffic between namespaces using tap])
+AT_KEYWORDS([http_tap])
+OVS_TRAFFIC_VSWITCHD_START()
+AT_SKIP_IF([test $HAVE_TUNCTL = no])
+
+AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+AT_CHECK([tunctl -t tap0 1> /dev/null])
+on_exit 'tunctl -d tap0'
+AT_CHECK([tunctl -t tap1 1> /dev/null])
+on_exit 'tunctl -d tap1'
+
+AT_CHECK([ovs-vsctl add-port br0 tap0 -- set int tap0 type=tap])
+AT_CHECK([ovs-vsctl add-port br0 tap1 -- set int tap1 type=tap])
+AT_CHECK([ip link set tap0 netns at_ns0])
+AT_CHECK([ip link set tap1 netns at_ns1])
+
+AT_CHECK([ip netns exec at_ns0 ip link set dev tap0 up])
+AT_CHECK([ip netns exec at_ns1 ip link set dev tap1 up])
+AT_CHECK([ip netns exec at_ns0 ip addr add 10.1.1.1/24 dev tap0])
+AT_CHECK([ip netns exec at_ns1 ip addr add 10.1.1.2/24 dev tap1])
+
+NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+])
+
+OVS_START_L7([at_ns1], [http])
+NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
+
+OVS_TRAFFIC_VSWITCHD_STOP(["/.*ethtool command ETHTOOL_G.*/d"])
+
+AT_CLEANUP
diff --git a/tests/system-tso-testsuite.at b/tests/system-tso-testsuite.at
index 99d748006a86..594d1a6fde85 100644
--- a/tests/system-tso-testsuite.at
+++ b/tests/system-tso-testsuite.at
@@ -23,4 +23,5 @@  m4_include([tests/system-common-macros.at])
 m4_include([tests/system-userspace-macros.at])
 m4_include([tests/system-tso-macros.at])
 
+m4_include([tests/system-tap.at])
 m4_include([tests/system-traffic.at])