5 from framework import VppTestCase, VppTestRunner
6 from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
9 class TestSession(VppTestCase):
10 """ Session Test Case """
14 super(TestSession, cls).setUpClass()
17 super(TestSession, self).setUp()
19 self.vapi.session_enable_disable(is_enabled=1)
20 self.create_loopback_interfaces(2)
24 for i in self.lo_interfaces:
28 tbl = VppIpTable(self, table_id)
31 i.set_table_ip4(table_id)
35 # Configure namespaces
36 self.vapi.app_namespace_add(namespace_id="0",
37 sw_if_index=self.loop0.sw_if_index)
38 self.vapi.app_namespace_add(namespace_id="1",
39 sw_if_index=self.loop1.sw_if_index)
42 for i in self.lo_interfaces:
47 super(TestSession, self).tearDown()
48 self.vapi.session_enable_disable(is_enabled=1)
50 def test_session(self):
51 """ Session Unit Tests """
52 error = self.vapi.cli("test session all")
55 self.logger.critical(error)
56 self.assertEqual(error.find("failed"), -1)
58 def test_segment_manager_alloc(self):
59 """ Session Segment Manager Multiple Segment Allocation """
61 # Add inter-table routes
62 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
63 [VppRoutePath("0.0.0.0",
66 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
67 [VppRoutePath("0.0.0.0",
69 nh_table_id=0)], table_id=1)
70 ip_t01.add_vpp_config()
71 ip_t10.add_vpp_config()
73 # Start builtin server and client with small private segments
74 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
75 error = self.vapi.cli("test echo server appns 0 fifo-size 64 " +
76 "private-segment-size 1m uri " + uri)
78 self.logger.critical(error)
79 self.assertEqual(error.find("failed"), -1)
81 error = self.vapi.cli("test echo client nclients 100 appns 1 " +
82 "no-output fifo-size 64 syn-timeout 2 " +
83 "private-segment-size 1m uri " + uri)
85 self.logger.critical(error)
86 self.assertEqual(error.find("failed"), -1)
91 # Delete inter-table routes
92 ip_t01.remove_vpp_config()
93 ip_t10.remove_vpp_config()
95 if __name__ == '__main__':
96 unittest.main(testRunner=VppTestRunner)