2 """ Container integration tests """
5 from config import config
6 from framework import VppTestCase
7 from asfframework import VppTestRunner
8 from scapy.layers.inet import UDP
9 from socket import AF_INET, AF_INET6
10 from util import L4_Conn
14 # for now same as L4_Conn
18 @unittest.skipUnless(config.extended, "part of extended tests")
19 class ContainerIntegrationTestCase(VppTestCase):
20 """Container integration extended testcases"""
24 super(ContainerIntegrationTestCase, cls).setUpClass()
26 cls.create_pg_interfaces(range(2))
27 for i in cls.pg_interfaces:
35 def tearDownClass(cls):
36 super(ContainerIntegrationTestCase, cls).tearDownClass()
39 """Run standard test teardown and log various show commands"""
40 super(ContainerIntegrationTestCase, self).tearDown()
42 def show_commands_at_teardown(self):
43 self.logger.info(self.vapi.cli("show ip neighbors"))
45 def run_basic_conn_test(self, af, acl_side):
46 """Basic connectivity test"""
47 conn1 = Conn(self, self.pg0, self.pg1, af, UDP, 42001, 4242)
49 # the return packets should pass
52 def run_negative_conn_test(self, af, acl_side):
53 """Packets with local spoofed address"""
54 conn1 = Conn(self, self.pg0, self.pg1, af, UDP, 42001, 4242)
56 p2 = conn1.send_through(0).command()
58 # If we asserted while waiting, it's good.
59 # the conn should have timed out.
61 self.assert_equal(p2, None, ": packet should have been dropped")
63 def test_0010_basic_conn_test(self):
64 """IPv4 basic connectivity test"""
65 self.run_basic_conn_test(AF_INET, 0)
67 def test_0011_basic_conn_test(self):
68 """IPv6 basic connectivity test"""
69 self.run_basic_conn_test(AF_INET6, 0)
71 def test_0050_loopback_prepare_test(self):
72 """Create loopbacks overlapping with remote addresses"""
73 self.create_loopback_interfaces(2)
75 intf = self.lo_interfaces[i]
77 intf.local_ip4 = self.pg_interfaces[i].remote_ip4
78 intf.local_ip4_prefix_len = 32
80 intf.local_ip6 = self.pg_interfaces[i].remote_ip6
81 intf.local_ip6_prefix_len = 128
84 def test_0110_basic_conn_test(self):
85 """IPv4 local-spoof connectivity test"""
86 self.run_negative_conn_test(AF_INET, 0)
88 def test_0111_basic_conn_test(self):
89 """IPv6 local-spoof connectivity test"""
90 self.run_negative_conn_test(AF_INET, 1)
92 def test_0200_basic_conn_test(self):
93 """Configure container commands"""
96 self.pg_interfaces[i].remote_ip4,
97 self.pg_interfaces[i].remote_ip6,
100 "ip container " + addr + " " + self.pg_interfaces[i].name
106 + self.pg_interfaces[i].name
109 def test_0210_basic_conn_test(self):
110 """IPv4 test after configuring container"""
111 self.run_basic_conn_test(AF_INET, 0)
113 def test_0211_basic_conn_test(self):
114 """IPv6 test after configuring container"""
115 self.run_basic_conn_test(AF_INET, 1)
117 def test_0300_unconfigure_commands(self):
118 """Unconfigure container commands"""
121 self.pg_interfaces[i].remote_ip4,
122 self.pg_interfaces[i].remote_ip6,
125 "ip container " + addr + " " + self.pg_interfaces[i].name + " del"
131 + self.pg_interfaces[i].name
135 def test_0410_spoof_test(self):
136 """IPv4 local-spoof after unconfig test"""
137 self.run_negative_conn_test(AF_INET, 0)
139 def test_0411_spoof_test(self):
140 """IPv6 local-spoof after unconfig test"""
141 self.run_negative_conn_test(AF_INET, 1)