public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 7/7] avocado: Convert pasta transfer tests to Avocado
Date: Thu, 20 Apr 2023 11:11:08 +1000	[thread overview]
Message-ID: <20230420011108.494181-8-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20230420011108.494181-1-david@gibson.dropbear.id.au>

Convert the basic transfer tests for pasta (test/pasta) into avocado
scripts.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 avocado/pasta.py      | 196 ++++++++++++++++++++++++++++++++++++++++++
 avocado/pasta_dhcp.py |  95 ++++++++++++++++++++
 avocado/pasta_ndp.py  |  52 +++++++++++
 avocado/pasta_tcp.py  |  61 +++++++++++++
 avocado/pasta_udp.py  |  55 ++++++++++++
 oldtest/run           |  14 +--
 test/lib/layout       |  31 -------
 test/lib/setup        |  30 -------
 test/pasta/dhcp       |  46 ----------
 test/pasta/ndp        |  33 -------
 test/pasta/tcp        |  96 ---------------------
 test/pasta/udp        |  59 -------------
 test/run              |   8 --
 13 files changed, 466 insertions(+), 310 deletions(-)
 create mode 100644 avocado/pasta.py
 create mode 100644 avocado/pasta_dhcp.py
 create mode 100644 avocado/pasta_ndp.py
 create mode 100644 avocado/pasta_tcp.py
 create mode 100644 avocado/pasta_udp.py
 delete mode 100644 test/pasta/dhcp
 delete mode 100644 test/pasta/ndp
 delete mode 100644 test/pasta/tcp
 delete mode 100644 test/pasta/udp

diff --git a/avocado/pasta.py b/avocado/pasta.py
new file mode 100644
index 0000000..ac7331e
--- /dev/null
+++ b/avocado/pasta.py
@@ -0,0 +1,196 @@
+#! /usr/bin/python3
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# avocado/pasta.py - Set up test environments for pasta
+#
+# Copyright Red Hat
+# Author: David Gibson <david@gibson.dropbear.id.au>
+
+import ipaddress
+import itertools
+import json
+import os
+import os.path
+
+import common
+
+PASTA = './pasta'
+
+
+def base_config_net(x, ifname, ip4, net4, ip6, net6):
+    x('ip link set lo up', sudo=True)
+    x('ip -4 addr add {}/{} dev {}'.format(ip4, net4.prefixlen, ifname), sudo=True)
+    x('ip -6 addr add {}/{} dev {}'.format(ip6, net6.prefixlen, ifname), sudo=True)
+    x('ip link set {} up'.format(ifname), sudo=True)
+
+
+class PastaBaseTest(common.BaseTest):
+    IFNAME = 'testif'
+
+    IP4_NET = ipaddress.IPv4Network('192.0.2.0/24')
+    (GW_IP4, OUTER_IP4) = itertools.islice(IP4_NET.hosts(), 2)
+
+    IP6_NET = ipaddress.IPv6Network('2001:db8:9a55::/112')
+    (GW_IP6, OUTER_IP6) = itertools.islice(IP6_NET.hosts(), 2)
+
+    INBOUND_FWD = 10002
+    OUTBOUND_FWD = 10003
+
+    def outerx(self, cmd, **kwargs):
+        return self.outer.system_output(cmd, **kwargs)
+
+    def innerx(self, cmd, **kwargs):
+        return self.inner.system_output(cmd, **kwargs)
+
+    def setUp(self):
+        super().setUp()
+
+        # Create the testing namespaces
+        self.sandbox = common.NsToolUnshare(self.workdir, 'sandbox',
+                                            '-Ucnpf --mount-proc')
+        self.gw = common.NsToolUnshare(self.workdir, 'gw',
+                                       '-n', parent=self.sandbox)
+        self.outer = common.NsToolUnshare(self.workdir, 'outer',
+                                          '-n', parent=self.sandbox)
+        self.inner = common.NsToolUnshare(self.workdir, 'inner',
+                                          '-Ucnpf --mount-proc', parent=self.sandbox)
+
+        # Create the link from gw <-> outer
+        gw_ifname = 'gw-{}'.format(self.IFNAME)
+        self.sandbox.system_output('ip link add {} type veth peer name {}'
+                                   .format(self.IFNAME, gw_ifname), sudo=True)
+        pid = self.gw.relative_pid(self.sandbox)
+        self.sandbox.system_output(
+            'ip link set {} netns {}'.format(gw_ifname, pid), sudo=True)
+        pid = self.outer.relative_pid(self.sandbox)
+        self.sandbox.system_output(
+            'ip link set {} netns {}'.format(self.IFNAME, pid), sudo=True)
+
+        # Basic network configuration on gw and outer
+        base_config_net(self.gw.system_output, gw_ifname, self.GW_IP4, self.IP4_NET,
+                        self.GW_IP6, self.IP6_NET)
+        base_config_net(self.outerx, self.IFNAME, self.OUTER_IP4, self.IP4_NET,
+                        self.OUTER_IP6, self.IP6_NET)
+
+        # Get the gateway's link-local address
+        self.gw_ll = common.slaac_wait(self.gw.system_output, gw_ifname)
+
+        # Make gw the default route for outer
+        self.outerx(
+            'ip -4 route add default via {}'.format(self.GW_IP4), sudo=True)
+        self.outerx('ip -6 route add default via {} dev {}'
+                    .format(self.gw_ll, self.IFNAME), sudo=True)
+
+    def tearDown(self):
+        # PID namespace means shutting down the sandbox will kill
+        # everything else
+        del(self.sandbox)
+
+        super().tearDown()
+
+
+class PastaUnconfiguredTest(PastaBaseTest):
+    def setUp(self):
+        super().setUp()
+
+        pidfile = os.path.join(self.workdir, 'pasta.pid')
+        relpid = self.inner.relative_pid(self.sandbox)
+        pastacmd = ('{} -f -t {} -T {} -u {} -U {} -P {} {}'
+                    .format(PASTA, self.INBOUND_FWD, self.OUTBOUND_FWD,
+                            self.INBOUND_FWD, self.OUTBOUND_FWD, pidfile, relpid))
+        self.pasta = self.outer.subprocess(pastacmd)
+        self.pasta.start()
+        # Pasta is ready once the pid file is written
+        while not os.path.exists(pidfile) or not open(pidfile).read():
+            pass
+        # PID of pasta relative to outer ns
+        self.pastapid = int(open(pidfile).read())
+
+    # Shut down pasta and check for errors
+    def shutdown(self):
+        # We can't use self.pasta.stop() or self.pasta.terminate()
+        # because that will just kill the nstool and won't propagate
+        # the signal to pasta itself
+        self.outer.system_output('kill -TERM {}'.format(self.pastapid))
+        rc = self.pasta.wait(timeout=1.0)
+        self.assertEqual(rc, 0)
+
+    def test_ifname(self):
+        ifs = json.loads(self.innerx('ip -j link show'))
+        ifnames = set([ifi['ifname'] for ifi in ifs])
+        self.assertEquals(ifnames, set(('lo', self.IFNAME)))
+        self.shutdown()
+
+
+class PastaConfiguredTest(PastaBaseTest):
+    def setUp(self):
+        super().setUp()
+
+        pidfile = os.path.join(self.workdir, 'pasta.pid')
+        relpid = self.inner.relative_pid(self.sandbox)
+        pastacmd = ('{} -f -t {} -T {} -u {} -U {} -P {} --config-net {}'
+                    .format(PASTA, self.INBOUND_FWD, self.OUTBOUND_FWD,
+                            self.INBOUND_FWD, self.OUTBOUND_FWD, pidfile, relpid))
+        self.pasta = self.outer.subprocess(pastacmd)
+        self.pasta.start()
+        # Pasta is ready once the pid file is written
+        while not os.path.exists(pidfile) or not open(pidfile).read():
+            pass
+        # PID of pasta relative to sandbox ns
+        self.pastapid = int(open(pidfile).read())
+
+    # Shut down pasta and check for errors
+    def shutdown(self):
+        # We can't use self.pasta.stop() or self.pasta.terminate()
+        # because that will just kill the nstool and won't propagate
+        # the signal to pasta itself
+        self.sandbox.system_output('kill -TERM {}'.format(self.pastapid))
+        rc = self.pasta.wait(timeout=1.0)
+        self.assertEqual(rc, 0)
+
+
+class ConfigNetTest(PastaConfiguredTest):
+    def test_addr4(self):
+        ifinfo = self.innerx('ip -4 -j addr show {}'.format(self.IFNAME))
+        ifinfo = json.loads(ifinfo)[0]
+        self.assertEquals(len(ifinfo['addr_info']), 1)
+        adinfo = ifinfo['addr_info'][0]
+        addr = ipaddress.ip_address(adinfo['local'])
+        self.assertEquals(addr, self.OUTER_IP4)
+        self.shutdown()
+
+    def test_addr6(self):
+        ifinfo = self.innerx('ip -6 -j addr show {}'.format(self.IFNAME))
+        ifinfo = json.loads(ifinfo)[0]
+        for adinfo in ifinfo['addr_info']:
+            if adinfo['scope'] == 'global' and not 'dynamic' in adinfo:
+                global_addr = ipaddress.ip_address(adinfo['local'])
+        self.assertEquals(global_addr, self.OUTER_IP6)
+        self.shutdown()
+
+    def test_route4(self):
+        rinfo = self.innerx('ip -j -4 route show')
+        rinfo = json.loads(rinfo)
+        for route in rinfo:
+            if route['dst'] != 'default':
+                continue
+            gateway = ipaddress.ip_address(route['gateway'])
+        self.assertEquals(gateway, self.GW_IP4)
+        self.shutdown()
+
+    def test_route6(self):
+        rinfo = self.innerx('ip -j -6 route show')
+        rinfo = json.loads(rinfo)
+        for route in rinfo:
+            if route['dst'] != 'default':
+                continue
+            gateway = ipaddress.ip_address(route['gateway'])
+        self.assertEquals(gateway, self.gw_ll)
+        self.shutdown()
+
+    def test_mtu(self):
+        ifinfo = self.innerx('ip -j link show {}'.format(self.IFNAME))
+        ifinfo = json.loads(ifinfo)[0]
+        self.assertEquals(ifinfo['mtu'], 65520)
+        self.shutdown()
diff --git a/avocado/pasta_dhcp.py b/avocado/pasta_dhcp.py
new file mode 100644
index 0000000..83424f3
--- /dev/null
+++ b/avocado/pasta_dhcp.py
@@ -0,0 +1,95 @@
+#! /usr/bin/python3
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# avocado/pasta_dhcp.py - Test DHCP & DHCPv6 with pasta
+#
+# Copyright Red Hat
+# Author: David Gibson <david@gibson.dropbear.id.au>
+
+import ipaddress
+import json
+
+import common
+from pasta import PastaUnconfiguredTest
+
+
+class PastaDhcpTest(PastaUnconfiguredTest):
+    DHCLIENT = '/sbin/dhclient'
+
+    def setUp(self):
+        super().setUp()
+
+        # Allow namespaced dhclient to write lease & pid files
+        self.innerx('mount -t tmpfs none /var/lib/dhclient', sudo=True)
+        self.innerx('mount -t tmpfs none /var/run', sudo=True)
+
+        # We need '-nc' because we're running with capabilities but
+        # not UID 0.  Without -nc dhclient drops capabilities before
+        # invoking dhclient-script, so it's unable to actually
+        # configure the interface
+        self.innerx('{} -4 -v -nc {}'.format(self.DHCLIENT,
+                    self.IFNAME), sudo=True)
+
+    def test_addr(self):
+        ifinfo = self.innerx('ip -4 -j addr show {}'.format(self.IFNAME))
+        ifinfo = json.loads(ifinfo)[0]
+        self.assertEquals(len(ifinfo['addr_info']), 1)
+        adinfo = ifinfo['addr_info'][0]
+        addr = ipaddress.ip_address(adinfo['local'])
+        self.assertEquals(addr, self.OUTER_IP4)
+        self.shutdown()
+
+    def test_route(self):
+        rinfo = self.innerx('ip -j -4 route show')
+        rinfo = json.loads(rinfo)
+        for route in rinfo:
+            if route['dst'] != 'default':
+                continue
+            gateway = ipaddress.ip_address(route['gateway'])
+        self.assertEquals(gateway, self.GW_IP4)
+        self.shutdown()
+
+    def test_mtu(self):
+        ifinfo = self.innerx('ip -j link show {}'.format(self.IFNAME))
+        ifinfo = json.loads(ifinfo)[0]
+        self.assertEquals(ifinfo['mtu'], 65520)
+        self.shutdown()
+
+
+class PastaDhcpv6Test(PastaUnconfiguredTest):
+    DHCLIENT = '/sbin/dhclient'
+    timeout = 10.0
+
+    def setUp(self):
+        super().setUp()
+
+        # Allow namespaced dhclient to write lease & pid files
+        self.innerx('mount -t tmpfs none /var/lib/dhclient', sudo=True)
+        self.innerx('mount -t tmpfs none /var/run', sudo=True)
+
+        # We need '-nc' because we're running with capabilities but
+        # not UID 0.  Without -nc dhclient drops capabilities before
+        # invoking dhclient-script, so it's unable to actually
+        # configure the interface
+        self.innerx('{} -6 -nc -v {}'.format(self.DHCLIENT,
+                    self.IFNAME), sudo=True)
+
+    def test_addr(self):
+        ifinfo = self.innerx('ip -6 -j addr show {}'.format(self.IFNAME))
+        ifinfo = json.loads(ifinfo)[0]
+        for adinfo in ifinfo['addr_info']:
+            if adinfo['scope'] == 'global' and not 'dynamic' in adinfo:
+                global_addr = ipaddress.ip_address(adinfo['local'])
+        self.assertEquals(global_addr, self.OUTER_IP6)
+        self.shutdown()
+
+    def test_route(self):
+        rinfo = self.innerx('ip -j -6 route show')
+        rinfo = json.loads(rinfo)
+        for route in rinfo:
+            if route['dst'] != 'default':
+                continue
+            gateway = ipaddress.ip_address(route['gateway'])
+        self.assertEquals(gateway, self.gw_ll)
+        self.shutdown()
diff --git a/avocado/pasta_ndp.py b/avocado/pasta_ndp.py
new file mode 100644
index 0000000..9b95772
--- /dev/null
+++ b/avocado/pasta_ndp.py
@@ -0,0 +1,52 @@
+#! /usr/bin/python3
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# avocado/pasta_ndp.py - Test NDP operations with pasta
+#
+# Copyright Red Hat
+# Author: David Gibson <david@gibson.dropbear.id.au>
+
+import ipaddress
+import json
+
+import common
+from pasta import PastaUnconfiguredTest
+
+
+class PastaNdpTest(PastaUnconfiguredTest):
+    def setUp(self):
+        super().setUp()
+
+        self.innerx('ip link set dev {} up'.format(self.IFNAME), sudo=True)
+        common.slaac_wait(self.innerx, self.IFNAME)
+
+    def test_addr(self):
+        ifinfo = self.innerx('ip -6 -j addr show {}'.format(self.IFNAME))
+        ifinfo = json.loads(ifinfo)[0]
+        for adinfo in ifinfo['addr_info']:
+            if adinfo['scope'] == 'global':
+                print(adinfo)
+                global_addr = ipaddress.ip_address(adinfo['local'])
+                prefixlen = adinfo['prefixlen']
+
+        # The SLAAC address is derived from the guest ns MAC, so
+        # probably won't exactly match the host address (we need
+        # DHCPv6 for that).  It should match the prefix of the host
+        # address, though
+        inner_if = ipaddress.IPv6Interface('{}/{}'
+                                           .format(global_addr, prefixlen))
+        outer_if = ipaddress.IPv6Interface('{}/{}'
+                                           .format(self.OUTER_IP6, prefixlen))
+        self.assertEquals(inner_if.network, outer_if.network)
+        self.shutdown()
+
+    def test_route(self):
+        rinfo = self.innerx('ip -j -6 route show')
+        rinfo = json.loads(rinfo)
+        for route in rinfo:
+            if route['dst'] != 'default':
+                continue
+            gateway = ipaddress.ip_address(route['gateway'])
+        self.assertEquals(gateway, self.gw_ll)
+        self.shutdown()
diff --git a/avocado/pasta_tcp.py b/avocado/pasta_tcp.py
new file mode 100644
index 0000000..0f90bcd
--- /dev/null
+++ b/avocado/pasta_tcp.py
@@ -0,0 +1,61 @@
+#! /usr/bin/python3
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# avocado/pasta_tcp.py - Test TCP transfers with pasta
+#
+# Copyright Red Hat
+# Author: David Gibson <david@gibson.dropbear.id.au>
+
+import filecmp
+import os.path
+
+import common
+from pasta import PastaConfiguredTest
+
+
+class PastaTcpSmall(PastaConfiguredTest):
+    DATA_FILE = './test/small.bin'
+
+    def transfer(self, fromx, fromaddr, tox, toaddr):
+        tmpfile = os.path.join(self.workdir, 'transfer.tmp')
+        listener = tox.subprocess(
+            'socat -u {} OPEN:{},create,trunc'.format(toaddr, tmpfile))
+        listener.start()
+        fromx.system_output(
+            'socat -u OPEN:{} {}'.format(self.DATA_FILE, fromaddr))
+        status = listener.wait()
+        self.assertEquals(status, 0)
+        self.assertTrue(filecmp.cmp(self.DATA_FILE, tmpfile, shallow=False))
+
+    def test_inbound_v4(self):
+        self.transfer(self.outer, 'TCP4:127.0.0.1:{}'.format(self.INBOUND_FWD),
+                      self.inner, 'TCP4-LISTEN:{},bind=127.0.0.1'.format(self.INBOUND_FWD))
+
+    def test_outbound_splice_v4(self):
+        self.transfer(self.inner, 'TCP4:127.0.0.1:{}'.format(self.OUTBOUND_FWD),
+                      self.outer, 'TCP4-LISTEN:{},bind=127.0.0.1'.format(self.OUTBOUND_FWD))
+
+    def test_outbound_tap_v4(self):
+        self.transfer(self.inner, 'TCP4:{}:{}'.format(self.GW_IP4, self.OUTBOUND_FWD),
+                      self.outer, 'TCP4-LISTEN:{}'.format(self.OUTBOUND_FWD))
+
+    def test_inbound_v6(self):
+        self.transfer(self.outer, 'TCP6:[::1]:{}'.format(self.INBOUND_FWD),
+                      self.inner, 'TCP6-LISTEN:{},bind=[::1]'.format(self.INBOUND_FWD))
+
+    def test_outbound_splice_v6(self):
+        self.transfer(self.inner, 'TCP6:[::1]:{}'.format(self.OUTBOUND_FWD),
+                      self.outer, 'TCP6-LISTEN:{},bind=[::1]'.format(self.OUTBOUND_FWD))
+
+    def test_outbound_tap_v6(self):
+        # We need the gateway route to be configured
+        common.slaac_wait(self.innerx, self.IFNAME)
+        self.transfer(self.inner, 'TCP6:[{}%{}]:{}'.format(self.gw_ll, self.IFNAME, self.OUTBOUND_FWD),
+                      self.outer, 'TCP6-LISTEN:{}'.format(self.OUTBOUND_FWD))
+
+
+# Sane again but with a larger data file
+class PastaTcpBig(PastaTcpSmall):
+    DATA_FILE = './test/big.bin'
+    timeout = 15.0
diff --git a/avocado/pasta_udp.py b/avocado/pasta_udp.py
new file mode 100644
index 0000000..1801071
--- /dev/null
+++ b/avocado/pasta_udp.py
@@ -0,0 +1,55 @@
+#! /usr/bin/python3
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# avocado/pasta_udp.py - Test TCP transfers with pasta
+#
+# Copyright Red Hat
+# Author: David Gibson <david@gibson.dropbear.id.au>
+
+import filecmp
+import os.path
+
+import common
+from pasta import PastaConfiguredTest
+
+
+class PastaUdp(PastaConfiguredTest):
+    DATA_FILE = './test/medium.bin'
+
+    def transfer(self, fromx, fromaddr, tox, toaddr):
+        tmpfile = os.path.join(self.workdir, 'transfer.tmp')
+        listener = tox.subprocess(
+            'socat -u {} OPEN:{},create,trunc'.format(toaddr, tmpfile))
+        listener.start()
+        fromx.system_output(
+            'socat -u OPEN:{} {}'.format(self.DATA_FILE, fromaddr))
+        status = listener.wait()
+        self.assertEquals(status, 0)
+        self.assertTrue(filecmp.cmp(self.DATA_FILE, tmpfile, shallow=False))
+
+    def test_inbound_v4(self):
+        self.transfer(self.outer, 'UDP4:127.0.0.1:{},shut-null'.format(self.INBOUND_FWD),
+                      self.inner, 'UDP4-LISTEN:{},null-eof,bind=127.0.0.1'.format(self.INBOUND_FWD))
+
+    def test_outbound_splice_v4(self):
+        self.transfer(self.inner, 'UDP4:127.0.0.1:{},shut-null'.format(self.OUTBOUND_FWD),
+                      self.outer, 'UDP4-LISTEN:{},null-eof,bind=127.0.0.1'.format(self.OUTBOUND_FWD))
+
+    def test_outbound_tap_v4(self):
+        self.transfer(self.inner, 'UDP4:{}:{},shut-null'.format(self.GW_IP4, self.OUTBOUND_FWD),
+                      self.outer, 'UDP4-LISTEN:{},null-eof'.format(self.OUTBOUND_FWD))
+
+    def test_inbound_v6(self):
+        self.transfer(self.outer, 'UDP6:[::1]:{},shut-null'.format(self.INBOUND_FWD),
+                      self.inner, 'UDP6-LISTEN:{},null-eof,bind=[::1]'.format(self.INBOUND_FWD))
+
+    def test_outbound_splice_v6(self):
+        self.transfer(self.inner, 'UDP6:[::1]:{},shut-null'.format(self.OUTBOUND_FWD),
+                      self.outer, 'UDP6-LISTEN:{},null-eof,bind=[::1]'.format(self.OUTBOUND_FWD))
+
+    def test_outbound_tap_v6(self):
+        # We need the gateway route to be configured
+        common.slaac_wait(self.innerx, self.IFNAME)
+        self.transfer(self.inner, 'UDP6:[{}%{}]:{},shut-null'.format(self.gw_ll, self.IFNAME, self.OUTBOUND_FWD),
+                      self.outer, 'UDP6-LISTEN:{},null-eof'.format(self.OUTBOUND_FWD))
diff --git a/oldtest/run b/oldtest/run
index a16bc49..f1157f9 100755
--- a/oldtest/run
+++ b/oldtest/run
@@ -70,13 +70,13 @@ run() {
 	test build/clang_tidy
 	teardown build
 
-#	setup pasta
-#	test pasta/ndp
-#	test pasta/dhcp
-#	test pasta/tcp
-#	test pasta/udp
-#	test passt/shutdown
-#	teardown pasta
+	setup pasta
+	test pasta/ndp
+	test pasta/dhcp
+	test pasta/tcp
+	test pasta/udp
+	test passt/shutdown
+	teardown pasta
 
 #	setup pasta_options
 #	test pasta_options/log_to_file
diff --git a/test/lib/layout b/test/lib/layout
index f9a1cf1..e2b1db0 100644
--- a/test/lib/layout
+++ b/test/lib/layout
@@ -13,37 +13,6 @@
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio@redhat.com>
 
-# layout_pasta() - Panes for host, pasta, and separate one for namespace
-layout_pasta() {
-	sleep 3
-
-	tmux kill-pane -a -t 0
-	cmd_write 0 clear
-
-	tmux split-window -v -t passt_test
-	tmux split-window -h -t passt_test
-	tmux split-window -h -l '42%' -t passt_test:1.0
-
-	PANE_NS=0
-	PANE_INFO=1
-	PANE_HOST=2
-	PANE_PASST=3
-
-	get_info_cols
-
-	tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
-	tmux send-keys -t ${PANE_INFO} -N 100 C-m
-	tmux select-pane -t ${PANE_INFO} -T "test log"
-
-	pane_watch_contexts ${PANE_HOST} host host
-	pane_watch_contexts ${PANE_PASST} pasta passt
-	pane_watch_contexts ${PANE_NS} "namespace" unshare ns
-
-	info_layout "single pasta instance with namespace"
-
-	sleep 1
-}
-
 # layout_passt() - Panes for host, passt, and guest
 layout_passt() {
 	sleep 3
diff --git a/test/lib/setup b/test/lib/setup
index 5386805..d0da2ca 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -61,36 +61,6 @@ setup_passt() {
 	context_setup_guest guest $GUEST_CID
 }
 
-# setup_pasta() - Create a network and user namespace, connect pasta to it
-setup_pasta() {
-	context_setup_host host
-	context_setup_host passt
-	context_setup_host unshare
-
-	layout_pasta
-
-	context_run_bg unshare "unshare -rUnpf ${NSTOOL} hold ${STATESETUP}/ns.hold"
-
-	context_setup_nstool ns ${STATESETUP}/ns.hold
-
-	# Ports:
-	#
-	#                 ns        |         host
-	#         ------------------|---------------------
-	#  10002      as server     |    spliced to ns
-	#  10003   spliced to init  |      as server
-
-	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta.pcap"
-	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
-	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
-
-	context_run_bg passt "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 -P ${STATESETUP}/passt.pid $(${NSTOOL} info -pw ${STATESETUP}/ns.hold)"
-
-	# pidfile isn't created until pasta is ready
-	wait_for [ -f "${STATESETUP}/passt.pid" ]
-}
-
 # setup_passt_in_ns() - Set up namespace (with pasta), run qemu and passt into it
 setup_passt_in_ns() {
 	context_setup_host host
diff --git a/test/pasta/dhcp b/test/pasta/dhcp
deleted file mode 100644
index 309001b..0000000
--- a/test/pasta/dhcp
+++ /dev/null
@@ -1,46 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-#
-# PASST - Plug A Simple Socket Transport
-#  for qemu/UNIX domain socket mode
-#
-# PASTA - Pack A Subtle Tap Abstraction
-#  for network namespace/tap device mode
-#
-# test/pasta/dhcp - Check DHCP and DHCPv6 functionality in pasta mode
-#
-# Copyright (c) 2021 Red Hat GmbH
-# Author: Stefano Brivio <sbrivio@redhat.com>
-
-nstools	ip jq /sbin/dhclient
-htools	ip jq
-
-test	Interface name
-nsout	IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
-check	[ -n "__IFNAME__" ]
-
-test	DHCP: address
-ns	/sbin/dhclient -4 --no-pid __IFNAME__
-nsout	ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
-hout	HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
-check	[ __ADDR__ = __HOST_ADDR__ ]
-
-test	DHCP: route
-nsout	GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
-check	[ __GW__ = __HOST_GW__ ]
-
-test	DHCP: MTU
-nsout	MTU ip -j link show | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu'
-check	[ __MTU__ = 65520 ]
-
-test	DHCPv6: address
-ns	/sbin/dhclient -6 --no-pid __IFNAME__
-hout	HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]'
-nsout	ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.prefixlen == 128).local'
-hout	HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME6__").addr_info[] | select(.scope == "global").local'
-check	[ __ADDR6__ = __HOST_ADDR6__ ]
-
-test	DHCPv6: route
-nsout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
-check	[ __GW6__ = __HOST_GW6__ ]
diff --git a/test/pasta/ndp b/test/pasta/ndp
deleted file mode 100644
index bb33110..0000000
--- a/test/pasta/ndp
+++ /dev/null
@@ -1,33 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-#
-# PASST - Plug A Simple Socket Transport
-#  for qemu/UNIX domain socket mode
-#
-# PASTA - Pack A Subtle Tap Abstraction
-#  for network namespace/tap device mode
-#
-# test/pasta/ndp - Check DHCP and DHCPv6 functionality in pasta mode
-#
-# Copyright (c) 2021 Red Hat GmbH
-# Author: Stefano Brivio <sbrivio@redhat.com>
-
-nstools	ip jq sipcalc grep cut
-htools	ip jq sipcalc grep cut
-
-test	Interface name
-nsout	IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
-check	[ -n "__IFNAME__" ]
-ns	ip link set dev __IFNAME__ up
-sleep	2
-
-test	SLAAC: prefix
-nsout	ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global" and .prefixlen == 64).local'
-nsout	PREFIX6 sipcalc __ADDR6__/64 | grep prefix | cut -d' ' -f4
-hout	HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local'
-hout	HOST_PREFIX6 sipcalc __HOST_ADDR6__/64 | grep prefix | cut -d' ' -f4
-check	[ "__PREFIX6__" = "__HOST_PREFIX6__" ]
-
-test	SLAAC: route
-nsout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
-hout	HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]'
-check	[ __GW6__ = __HOST_GW6__ ]
diff --git a/test/pasta/tcp b/test/pasta/tcp
deleted file mode 100644
index 6ab18c5..0000000
--- a/test/pasta/tcp
+++ /dev/null
@@ -1,96 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-#
-# PASST - Plug A Simple Socket Transport
-#  for qemu/UNIX domain socket mode
-#
-# PASTA - Pack A Subtle Tap Abstraction
-#  for network namespace/tap device mode
-#
-# test/pasta/tcp - Check TCP functionality for pasta
-#
-# Copyright (c) 2021 Red Hat GmbH
-# Author: Stefano Brivio <sbrivio@redhat.com>
-
-htools	socat ip jq
-nstools	socat ip jq
-
-set	TEMP_BIG __STATEDIR__/test_big.bin
-set	TEMP_NS_BIG __STATEDIR__/test_ns_big.bin
-set	TEMP_SMALL __STATEDIR__/test_small.bin
-set	TEMP_NS_SMALL __STATEDIR__/test_ns_small.bin
-
-test	TCP/IPv4: host to ns: big transfer
-nsb	socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_BIG__,create,trunc
-host	socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10002
-nsw
-check	cmp __BASEPATH__/big.bin __TEMP_NS_BIG__
-
-test	TCP/IPv4: ns to host (spliced): big transfer
-hostb	socat -u TCP4-LISTEN:10003,bind=127.0.0.1 OPEN:__TEMP_BIG__,create,trunc
-ns	socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10003
-hostw
-check	cmp __BASEPATH__/big.bin __TEMP_BIG__
-
-test	TCP/IPv4: ns to host (via tap): big transfer
-hostb	socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc
-nsout	GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
-ns	socat -u OPEN:__BASEPATH__/big.bin TCP4:__GW__:10003
-hostw
-check	cmp __BASEPATH__/big.bin __TEMP_BIG__
-
-test	TCP/IPv4: host to ns: small transfer
-nsb	socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_SMALL__,create,trunc
-host	socat OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10002
-nsw
-check	cmp __BASEPATH__/small.bin __TEMP_NS_SMALL__
-
-test	TCP/IPv4: ns to host (spliced): small transfer
-hostb	socat -u TCP4-LISTEN:10003,bind=127.0.0.1 OPEN:__TEMP_SMALL__,create,trunc
-ns	socat OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10003
-hostw
-check	cmp __BASEPATH__/small.bin __TEMP_SMALL__
-
-test	TCP/IPv4: ns to host (via tap): small transfer
-hostb	socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc
-nsout	GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
-ns	socat -u OPEN:__BASEPATH__/small.bin TCP4:__GW__:10003
-hostw
-check	cmp __BASEPATH__/small.bin __TEMP_SMALL__
-
-test	TCP/IPv6: host to ns: big transfer
-nsb	socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_BIG__,create,trunc
-host	socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10002
-nsw
-check	cmp __BASEPATH__/big.bin __TEMP_NS_BIG__
-
-test	TCP/IPv6: ns to host (spliced): big transfer
-hostb	socat -u TCP6-LISTEN:10003,bind=[::1] OPEN:__TEMP_BIG__,create,trunc
-ns	socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10003
-hostw
-check	cmp __BASEPATH__/big.bin __TEMP_BIG__
-
-test	TCP/IPv6: ns to host (via tap): big transfer
-hostb	socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc
-nsout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
-nsout	IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
-ns	socat -u OPEN:__BASEPATH__/big.bin TCP6:[__GW6__%__IFNAME__]:10003
-hostw
-check	cmp __BASEPATH__/big.bin __TEMP_BIG__
-
-test	TCP/IPv6: host to ns: small transfer
-nsb	socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_SMALL__,create,trunc
-host	socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10002
-nsw
-check	cmp __BASEPATH__/small.bin __TEMP_NS_SMALL__
-
-test	TCP/IPv6: ns to host (spliced): small transfer
-hostb	socat -u TCP6-LISTEN:10003,bind=[::1] OPEN:__TEMP_SMALL__,create,trunc
-ns	socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10003
-hostw
-check	cmp __BASEPATH__/small.bin __TEMP_SMALL__
-
-test	TCP/IPv6: ns to host (via tap): small transfer
-hostb	socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc
-ns	socat -u OPEN:__BASEPATH__/small.bin TCP6:[__GW6__%__IFNAME__]:10003
-hostw
-check	cmp __BASEPATH__/small.bin __TEMP_SMALL__
diff --git a/test/pasta/udp b/test/pasta/udp
deleted file mode 100644
index 30e3a85..0000000
--- a/test/pasta/udp
+++ /dev/null
@@ -1,59 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-#
-# PASST - Plug A Simple Socket Transport
-#  for qemu/UNIX domain socket mode
-#
-# PASTA - Pack A Subtle Tap Abstraction
-#  for network namespace/tap device mode
-#
-# test/pasta/udp - Check UDP functionality for pasta
-#
-# Copyright (c) 2021 Red Hat GmbH
-# Author: Stefano Brivio <sbrivio@redhat.com>
-
-nstools	socat ip jq
-htools	dd socat ip jq
-
-set	TEMP __STATEDIR__/test.bin
-set	TEMP_NS __STATEDIR__/test_ns.bin
-
-test	UDP/IPv4: host to ns
-nsb	socat -u UDP4-LISTEN:10002,bind=127.0.0.1,null-eof OPEN:__TEMP_NS__,create,trunc
-host	socat OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10002,shut-null
-nsw
-check	cmp __BASEPATH__/medium.bin __TEMP_NS__
-
-test	UDP/IPv4: ns to host (recvmmsg/sendmmsg)
-hostb	socat -u UDP4-LISTEN:10003,bind=127.0.0.1,null-eof OPEN:__TEMP__,create,trunc
-sleep	1
-ns	socat OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10003,shut-null
-hostw
-check	cmp __BASEPATH__/medium.bin __TEMP__
-
-test	UDP/IPv4: ns to host (via tap)
-hostb	socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc
-nsout	GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
-ns	socat -u OPEN:__BASEPATH__/medium.bin UDP4:__GW__:10003,shut-null
-hostw
-check	cmp __BASEPATH__/medium.bin __TEMP__
-
-test	UDP/IPv6: host to ns
-nsb	socat -u UDP6-LISTEN:10002,bind=[::1],null-eof OPEN:__TEMP_NS__,create,trunc
-host	socat -u OPEN:__BASEPATH__/medium.bin UDP6:[::1]:10002,shut-null
-nsw
-check	cmp __BASEPATH__/medium.bin __TEMP_NS__
-
-test	UDP/IPv6: ns to host (recvmmsg/sendmmsg)
-hostb	socat -u UDP6-LISTEN:10003,bind=[::1],null-eof OPEN:__TEMP__,create,trunc
-sleep	1
-ns	socat -u OPEN:__BASEPATH__/medium.bin UDP6:[::1]:10003,shut-null
-hostw
-check	cmp __BASEPATH__/medium.bin __TEMP__
-
-test	UDP/IPv6: ns to host (via tap)
-hostb	socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc
-nsout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
-nsout	IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
-ns	socat -u OPEN:__BASEPATH__/medium.bin UDP6:[__GW6__%__IFNAME__]:10003,shut-null
-hostw
-check	cmp __BASEPATH__/medium.bin __TEMP__
diff --git a/test/run b/test/run
index b800022..f4f5fc8 100755
--- a/test/run
+++ b/test/run
@@ -64,14 +64,6 @@ run() {
 	perf_init
 	[ ${CI} -eq 1 ]   && video_start ci
 
-	setup pasta
-	test pasta/ndp
-	test pasta/dhcp
-	test pasta/tcp
-	test pasta/udp
-	test passt/shutdown
-	teardown pasta
-
 	setup pasta_options
 	test pasta_options/log_to_file
 	teardown pasta_options
-- 
@@ -64,14 +64,6 @@ run() {
 	perf_init
 	[ ${CI} -eq 1 ]   && video_start ci
 
-	setup pasta
-	test pasta/ndp
-	test pasta/dhcp
-	test pasta/tcp
-	test pasta/udp
-	test passt/shutdown
-	teardown pasta
-
 	setup pasta_options
 	test pasta_options/log_to_file
 	teardown pasta_options
-- 
2.40.0


      parent reply	other threads:[~2023-04-20  1:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20  1:11 [PATCH 0/7] RFC: Proof-of-concept conversion of some tests to Avocado framework David Gibson
2023-04-20  1:11 ` [PATCH 1/7] avocado: Make a duplicate copy of testsuite for comparison purposes David Gibson
2023-04-20  1:11 ` [PATCH 2/7] avocado: Don't double download assets for test/ and oldtest/ David Gibson
2023-04-20  1:11 ` [PATCH 3/7] avocado: Move static checkers to avocado David Gibson
2023-04-20  1:11 ` [PATCH 4/7] avocado: Convert build tests " David Gibson
2023-04-20  1:11 ` [PATCH 5/7] avocado: Helper functions and classes to run commands via nstool David Gibson
2023-04-20  1:11 ` [PATCH 6/7] avocado: Helper to get link-local address and wait for SLAAC to complete David Gibson
2023-04-20  1:11 ` David Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230420011108.494181-8-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).