summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey V. Lobanov <sergey@lobanov.in>2022-09-05 23:02:15 +0300
committerSergey V. Lobanov <sergey@lobanov.in>2022-09-06 00:18:57 +0300
commit127b1de95923fccdfdc892c20f931d364e099f4b (patch)
treed38c0f14337d9fe5e6b19af576a730f9077ae3e8 /tests
parentc92ff6266b18a9655edef231391739f0479dfb3a (diff)
downloadaccel-ppp-127b1de95923fccdfdc892c20f931d364e099f4b.tar.gz
accel-ppp-127b1de95923fccdfdc892c20f931d364e099f4b.zip
tests ci: add testing in Qemu (Ubuntu 18.04, 20.04, 22.04, Debian 10,11,12)
Diffstat (limited to 'tests')
-rw-r--r--tests/accel-pppd/test_vlan_mon_driver.py1
-rw-r--r--tests/common/iface.py23
-rw-r--r--tests/common/veth.py55
3 files changed, 51 insertions, 28 deletions
diff --git a/tests/accel-pppd/test_vlan_mon_driver.py b/tests/accel-pppd/test_vlan_mon_driver.py
index 3e937f83..a230c7c8 100644
--- a/tests/accel-pppd/test_vlan_mon_driver.py
+++ b/tests/accel-pppd/test_vlan_mon_driver.py
@@ -3,5 +3,6 @@ import os
# test that vlan_mon kernel module is loaded
@pytest.mark.dependency(name = 'vlan_mon_driver_loaded', scope = 'session')
+@pytest.mark.vlan_mon_driver
def test_vlan_mon_kernel_module_loaded():
assert os.path.isdir("/sys/module/vlan_mon") \ No newline at end of file
diff --git a/tests/common/iface.py b/tests/common/iface.py
new file mode 100644
index 00000000..dbd052ab
--- /dev/null
+++ b/tests/common/iface.py
@@ -0,0 +1,23 @@
+from common import netns
+
+# up interface. if netns is None, then up in global rt. if ok returns 0
+def up(iface, netns_name):
+ command = ["ip", "link", "set", iface, "up"]
+ exit, out, err = netns.exec(netns_name, command)
+ print(
+ "iface.up: iface=%s netns=%s exit=%d out=%s err=%s"
+ % (iface, netns_name, exit, out, err)
+ )
+
+ return exit
+
+
+# delete interface. if netns is None, then up in global rt. if ok returns 0
+def delete(iface, netns_name):
+ exit, out, err = netns.exec(netns_name, ["ip", "link", "delete", iface])
+ print(
+ "iface.delete: iface=%s netns=%s exit=%d out=%s err=%s"
+ % (iface, netns_name, exit, out, err)
+ )
+
+ return exit
diff --git a/tests/common/veth.py b/tests/common/veth.py
index a31d2453..c9d3006c 100644
--- a/tests/common/veth.py
+++ b/tests/common/veth.py
@@ -1,4 +1,4 @@
-from common import process, netns, vlan
+from common import process, netns, vlan, iface
import time
import math
@@ -12,14 +12,6 @@ def create_pair(name_a, name_b):
return veth
-# deletes veth pair. if ok returns 0
-def delete_veth(name_a):
- veth, out, err = process.run(["ip", "link", "delete", name_a])
- print("veth.delete: exit=%d out=%s err=%s" % (veth, out, err))
-
- return veth
-
-
# put veth to netns. if ok returns 0
def assign_netns(veth, netns):
veth, out, err = process.run(["ip", "link", "set", veth, "netns", netns])
@@ -28,18 +20,6 @@ def assign_netns(veth, netns):
return veth
-# up interface. if netns is None, then up in global rt. if ok returns 0
-def up_interface(iface, netns_name):
- command = ["ip", "link", "set", iface, "up"]
- exit, out, err = netns.exec(netns_name, command)
- print(
- "veth.up_interface: iface=%s netns=%s exit=%d out=%s err=%s"
- % (iface, str(netns_name), exit, out, err)
- )
-
- return exit
-
-
# creates netns, creates veth pair and place second link to netns
# creates vlans over veth interfaces according to veth_pair_vlans_config
# return dict with 'netns', 'veth_a', 'veth_b'
@@ -55,30 +35,49 @@ def create_veth_pair_netns(veth_pair_vlans_config):
pair_status = create_pair(veth_a, veth_b)
print("create_veth_pair_netns: pair_status=%d" % pair_status)
- up_interface(veth_a, None)
+ iface.up(veth_a, None)
assign_status = assign_netns(veth_b, netns_name)
print("create_veth_pair_netns: assign_status=%d" % assign_status)
- up_interface(veth_b, netns_name)
+ iface.up(veth_b, netns_name)
vlans_a = veth_pair_vlans_config["vlans_a"]
for vlan_num in vlans_a:
vlan.create(veth_a, vlan_num, None)
- up_interface(veth_a + "." + str(vlan_num), None)
+ iface.up(veth_a + "." + str(vlan_num), None)
vlans_b = veth_pair_vlans_config["vlans_b"]
for vlan_num in vlans_b:
vlan.create(veth_b, vlan_num, netns_name)
- up_interface(veth_b + "." + str(vlan_num), netns_name)
+ iface.up(veth_b + "." + str(vlan_num), netns_name)
- return {"netns": netns_name, "veth_a": veth_a, "veth_b": veth_b}
+ return {
+ "netns": netns_name,
+ "veth_a": veth_a,
+ "veth_b": veth_b,
+ "vlans_a": vlans_a,
+ "vlans_b": vlans_b,
+ }
# deletes veth pair and netns created by create_veth_pair_netns
def delete_veth_pair_netns(veth_pair_netns):
- veth_status = delete_veth(veth_pair_netns["veth_a"])
+
+ vlans_a = veth_pair_netns["vlans_a"]
+ veth_a = veth_pair_netns["veth_a"]
+ vlans_b = veth_pair_netns["vlans_b"]
+ veth_b = veth_pair_netns["veth_b"]
+ netns_name = veth_pair_netns["netns"]
+
+ # remove vlans on top of veth interface
+ for vlan_num in vlans_a:
+ iface.delete(veth_a + "." + str(vlan_num), None)
+ for vlan_num in vlans_b:
+ iface.delete(veth_b + "." + str(vlan_num), netns_name)
+
+ veth_status = iface.delete(veth_a, None)
print("delete_veth_pair_netns: veth_status=%d" % veth_status)
- netns_status = netns.delete(veth_pair_netns["netns"])
+ netns_status = netns.delete(netns_name)
print("delete_veth_pair_netns: netns_status=%d" % netns_status)