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 super(TestTCP, self).setUp()
18 self.vapi.session_enable_disable(is_enabled=1)
19 self.create_loopback_interfaces(2)
23 for i in self.lo_interfaces:
27 tbl = VppIpTable(self, table_id)
30 i.set_table_ip4(table_id)
34 # Configure namespaces
35 self.vapi.app_namespace_add(namespace_id="0",
36 sw_if_index=self.loop0.sw_if_index)
37 self.vapi.app_namespace_add(namespace_id="1",
38 sw_if_index=self.loop1.sw_if_index)
41 for i in self.lo_interfaces:
45 self.vapi.session_enable_disable(is_enabled=0)
46 super(TestTCP, self).tearDown()
48 def test_tcp_transfer(self):
49 """ TCP echo client/server transfer """
51 # Add inter-table routes
52 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
53 [VppRoutePath("0.0.0.0",
56 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
57 [VppRoutePath("0.0.0.0",
59 nh_table_id=0)], table_id=1)
60 ip_t01.add_vpp_config()
61 ip_t10.add_vpp_config()
63 # Start builtin server and client
64 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
65 error = self.vapi.cli("test echo server appns 0 fifo-size 4 uri " +
68 self.logger.critical(error)
69 self.assertEqual(error.find("failed"), -1)
71 error = self.vapi.cli("test echo client mbytes 10 appns 1 " +
72 "fifo-size 4 no-output test-bytes " +
73 "syn-timeout 2 uri " + uri)
75 self.logger.critical(error)
76 self.assertEqual(error.find("failed"), -1)
78 # Delete inter-table routes
79 ip_t01.remove_vpp_config()
80 ip_t10.remove_vpp_config()
83 class TestTCPUnitTests(VppTestCase):
87 super(TestTCPUnitTests, self).setUp()
88 self.vapi.session_enable_disable(is_enabled=1)
91 super(TestTCPUnitTests, self).tearDown()
92 self.vapi.session_enable_disable(is_enabled=0)
94 def test_tcp_unittest(self):
95 """ TCP Unit Tests """
96 error = self.vapi.cli("test tcp all")
99 self.logger.critical(error)
100 self.assertEqual(error.find("failed"), -1)
102 if __name__ == '__main__':
103 unittest.main(testRunner=VppTestRunner)