tests: refactor virtual interface tests

Split virtual interface tests in VPP into smaller and modular
tests for testing various interface types and features.

Type: test

Change-Id: Ic38af88379f75eee3090679d411edbdc8fd5d2e5
Signed-off-by: Naveen Joy <najoy@cisco.com>
This commit is contained in:
Naveen Joy 2024-01-31 08:46:18 -08:00 committed by Dave Wallace
parent 28aef29e01
commit 0215ef1010
17 changed files with 718 additions and 98 deletions

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuAfPacketGsoL2(TestVPPInterfacesQemu, VppTestCase):
"""Test af_packet interfaces with GSO in L2 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "14,16,22,23"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuAfPacketGsoL2, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuAfPacketGsoL2, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuAfPacketGsoL2, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuAfPacketGsoL2.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuAfPacketGsoL2)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuAfPacketGsoL3(TestVPPInterfacesQemu, VppTestCase):
"""Test af_packet interfaces with GSO in L3 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "15,19"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuAfPacketGsoL3, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuAfPacketGsoL3, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuAfPacketGsoL3, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuAfPacketGsoL3.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuAfPacketGsoL3)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuAfPacketL2(TestVPPInterfacesQemu, VppTestCase):
"""Test af_packet interfaces in L2 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "12,20"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuAfPacketL2, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuAfPacketL2, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuAfPacketL2, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuAfPacketL2.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuAfPacketL2)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuAfpacketL3(TestVPPInterfacesQemu, VppTestCase):
"""Test af_packet interfaces in L3 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "13"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuAfpacketL3, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuAfpacketL3, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuAfpacketL3, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuAfpacketL3.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuAfpacketL3)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuAfPacketTapGsoL2(TestVPPInterfacesQemu, VppTestCase):
"""Test af_packet & tap interfaces with GSO in L2 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "17"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuAfPacketTapGsoL2, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuAfPacketTapGsoL2, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuAfPacketTapGsoL2, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuAfPacketTapGsoL2.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuAfPacketTapGsoL2)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuAfPacketTunGroL3(TestVPPInterfacesQemu, VppTestCase):
"""Test af_packet & tun interfaces with GRO in L3 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "21"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuAfPacketTunGroL3, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuAfPacketTunGroL3, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuAfPacketTunGroL3, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuAfPacketTunGroL3.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuAfPacketTunGroL3)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuAfPacketTunGsoL3(TestVPPInterfacesQemu, VppTestCase):
"""Test af_packet & tun interfaces with GSO in L3 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "18"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuAfPacketTunGsoL3, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuAfPacketTunGsoL3, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuAfPacketTunGsoL3, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuAfPacketTunGsoL3.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuAfPacketTunGsoL3)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

38
test/test_vm_memif_l2.py Normal file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuMemifL2(TestVPPInterfacesQemu, VppTestCase):
"""Test Memif interfaces in L2 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "27"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuMemifL2, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuMemifL2, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuMemifL2, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuMemifL2.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuMemifL2)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuTapChecksumOffloadL2(TestVPPInterfacesQemu, VppTestCase):
"""Test tap interfaces in L2 mode with checksum offload for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "24"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuTapChecksumOffloadL2, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuTapChecksumOffloadL2, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuTapChecksumOffloadL2, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuTapChecksumOffloadL2.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuTapChecksumOffloadL2)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuTapChecksumOffloadL3(TestVPPInterfacesQemu, VppTestCase):
"""Test tap interfaces in L3 mode with checksum offload for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "25,26"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuTapChecksumOffloadL3, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuTapChecksumOffloadL3, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuTapChecksumOffloadL3, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuTapChecksumOffloadL3.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuTapChecksumOffloadL3)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuTapGroL2(TestVPPInterfacesQemu, VppTestCase):
"""Test tap interfaces with GRO in L2 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "4,5,9"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuTapGroL2, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuTapGroL2, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuTapGroL2, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuTapGroL2.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuTapGroL2)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuTapGsoGroL2(TestVPPInterfacesQemu, VppTestCase):
"""Test tap interfaces with GSO & GRO in L2 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "6,7"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuTapGsoGroL2, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuTapGsoGroL2, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuTapGsoGroL2, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuTapGsoGroL2.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuTapGsoGroL2)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuTapGsoL2(TestVPPInterfacesQemu, VppTestCase):
"""Test tap interfaces with GSO in L2 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "2,3,8"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuTapGsoL2, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuTapGsoL2, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuTapGsoL2, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuTapGsoL2.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuTapGsoL2)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

38
test/test_vm_tap_l2.py Normal file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuTapL2(TestVPPInterfacesQemu, VppTestCase):
"""Test VPP tap interfaces in L2 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "1"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuTapL2, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuTapL2, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuTapL2, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuTapL2.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuTapL2)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import unittest
from framework import VppTestCase
from vm_vpp_interfaces import (
TestSelector,
TestVPPInterfacesQemu,
generate_vpp_interface_tests,
)
from asfframework import VppTestRunner
from vm_test_config import test_config
class TestVPPInterfacesQemuTapTunGroL3(TestVPPInterfacesQemu, VppTestCase):
"""Test tap & tun interfaces with GRO in L3 mode for IPv4/v6."""
# Set test_id(s) to run from vm_test_config
# The expansion of these numbers are included in the test docstring
tests_to_run = "10,11"
@classmethod
def setUpClass(cls):
super(TestVPPInterfacesQemuTapTunGroL3, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestVPPInterfacesQemuTapTunGroL3, cls).tearDownClass()
def tearDown(self):
super(TestVPPInterfacesQemuTapTunGroL3, self).tearDown()
SELECTED_TESTS = TestVPPInterfacesQemuTapTunGroL3.tests_to_run
tests = filter(TestSelector(SELECTED_TESTS).filter_tests, test_config["tests"])
generate_vpp_interface_tests(tests, TestVPPInterfacesQemuTapTunGroL3)
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)

File diff suppressed because it is too large Load Diff

View File

@ -65,6 +65,7 @@ class VppIperf:
sys.exit(1)
def start_iperf_server(self):
"""Starts the iperf server and returns the process cmdline args."""
args = [
"ip",
"netns",
@ -75,11 +76,11 @@ class VppIperf:
"-D",
]
args.extend(self.server_args.split())
args = " ".join(args)
self.logger.debug(f"Starting iperf server: {args}")
cmd = " ".join(args)
self.logger.debug(f"Starting iperf server: {cmd}")
try:
return subprocess.run(
args,
subprocess.run(
cmd,
timeout=self.duration + 5,
encoding="utf-8",
shell=True,
@ -88,6 +89,7 @@ class VppIperf:
)
except subprocess.TimeoutExpired as e:
raise Exception("Error: Timeout expired for iPerf", e.output)
return args[4:]
def start_iperf_client(self):
args = [
@ -125,7 +127,7 @@ class VppIperf:
"""
self.ensure_init()
if not client_only:
self.start_iperf_server()
return self.start_iperf_server()
if not server_only:
result = self.start_iperf_client()
self.logger.debug(f"Iperf client args: {result.args}")
@ -192,17 +194,22 @@ def start_iperf(
return iperf.start(server_only=server_only, client_only=client_only)
def stop_iperf():
args = ["pkill", "iperf"]
args = " ".join(args)
try:
return subprocess.run(
args,
encoding="utf-8",
shell=True,
)
except Exception:
pass
def stop_iperf(iperf_cmd):
"""Stop the iperf process matching the iperf_cmd string."""
args = ["pgrep", "-x", "-f", iperf_cmd]
p = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8"
)
stdout, _ = p.communicate()
for pid in stdout.split():
try:
subprocess.run(
f"kill -9 {pid}",
encoding="utf-8",
shell=True,
)
except Exception:
pass
if __name__ == "__main__":