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_enabled=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(namespace_id="0",
40 sw_if_index=self.loop0.sw_if_index)
41 self.vapi.app_namespace_add_del(namespace_id="1",
42 sw_if_index=self.loop1.sw_if_index)
45 for i in self.lo_interfaces:
49 self.vapi.session_enable_disable(is_enabled=0)
50 super(TestTCP, self).tearDown()
52 def test_tcp_transfer(self):
53 """ TCP echo client/server transfer """
55 # Add inter-table routes
56 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
57 [VppRoutePath("0.0.0.0",
60 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
61 [VppRoutePath("0.0.0.0",
63 nh_table_id=0)], table_id=1)
64 ip_t01.add_vpp_config()
65 ip_t10.add_vpp_config()
67 # Start builtin server and client
68 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
69 error = self.vapi.cli("test echo server appns 0 fifo-size 4 uri " +
72 self.logger.critical(error)
73 self.assertNotIn("failed", error)
75 error = self.vapi.cli("test echo client mbytes 10 appns 1 " +
76 "fifo-size 4 no-output test-bytes " +
77 "syn-timeout 2 uri " + uri)
79 self.logger.critical(error)
80 self.assertNotIn("failed", error)
82 # Delete inter-table routes
83 ip_t01.remove_vpp_config()
84 ip_t10.remove_vpp_config()
87 class TestTCPUnitTests(VppTestCase):
92 super(TestTCPUnitTests, cls).setUpClass()
95 def tearDownClass(cls):
96 super(TestTCPUnitTests, cls).tearDownClass()
99 super(TestTCPUnitTests, self).setUp()
100 self.vapi.session_enable_disable(is_enabled=1)
103 super(TestTCPUnitTests, self).tearDown()
104 self.vapi.session_enable_disable(is_enabled=0)
106 def test_tcp_unittest(self):
107 """ TCP Unit Tests """
108 error = self.vapi.cli("test tcp all")
111 self.logger.critical(error)
112 self.assertNotIn("failed", error)
114 if __name__ == '__main__':
115 unittest.main(testRunner=VppTestRunner)