5 from framework import VppTestCase, VppTestRunner
6 from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
9 class TestTCP(VppTestCase):
14 super(TestTCP, cls).setUpClass()
17 def tearDownClass(cls):
18 super(TestTCP, cls).tearDownClass()
21 super(TestTCP, self).setUp()
22 self.vapi.session_enable_disable(is_enable=1)
23 self.create_loopback_interfaces(2)
27 for i in self.lo_interfaces:
31 tbl = VppIpTable(self, table_id)
34 i.set_table_ip4(table_id)
38 # Configure namespaces
39 self.vapi.app_namespace_add_del(
40 namespace_id="0", sw_if_index=self.loop0.sw_if_index
42 self.vapi.app_namespace_add_del(
43 namespace_id="1", sw_if_index=self.loop1.sw_if_index
47 for i in self.lo_interfaces:
51 self.vapi.session_enable_disable(is_enable=0)
52 super(TestTCP, self).tearDown()
54 def test_tcp_transfer(self):
55 """TCP echo client/server transfer"""
57 # Add inter-table routes
62 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=1)],
68 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=0)],
71 ip_t01.add_vpp_config()
72 ip_t10.add_vpp_config()
74 # Start builtin server and client
75 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
76 error = self.vapi.cli("test echo server appns 0 fifo-size 4 uri " + uri)
78 self.logger.critical(error)
79 self.assertNotIn("failed", error)
81 error = self.vapi.cli(
82 "test echo client mbytes 10 appns 1 "
83 + "fifo-size 4 no-output test-bytes "
84 + "syn-timeout 2 uri "
88 self.logger.critical(error)
89 self.assertNotIn("failed", error)
91 # Delete inter-table routes
92 ip_t01.remove_vpp_config()
93 ip_t10.remove_vpp_config()
96 class TestTCPUnitTests(VppTestCase):
101 super(TestTCPUnitTests, cls).setUpClass()
104 def tearDownClass(cls):
105 super(TestTCPUnitTests, cls).tearDownClass()
108 super(TestTCPUnitTests, self).setUp()
109 self.vapi.session_enable_disable(is_enable=1)
112 super(TestTCPUnitTests, self).tearDown()
113 self.vapi.session_enable_disable(is_enable=0)
115 def test_tcp_unittest(self):
117 error = self.vapi.cli("test tcp all")
120 self.logger.critical(error)
121 self.assertNotIn("failed", error)
124 if __name__ == "__main__":
125 unittest.main(testRunner=VppTestRunner)