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 def tearDownClass(cls):
18 super(TestSession, cls).tearDownClass()
21 super(TestSession, self).setUp()
23 self.vapi.session_enable_disable(is_enabled=1)
24 self.create_loopback_interfaces(2)
28 for i in self.lo_interfaces:
32 tbl = VppIpTable(self, table_id)
35 i.set_table_ip4(table_id)
39 # Configure namespaces
40 self.vapi.app_namespace_add_del(namespace_id=b"0",
41 sw_if_index=self.loop0.sw_if_index)
42 self.vapi.app_namespace_add_del(namespace_id=b"1",
43 sw_if_index=self.loop1.sw_if_index)
46 for i in self.lo_interfaces:
51 super(TestSession, self).tearDown()
52 self.vapi.session_enable_disable(is_enabled=1)
54 def test_segment_manager_alloc(self):
55 """ Session Segment Manager Multiple Segment Allocation """
57 # Add inter-table routes
58 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
59 [VppRoutePath("0.0.0.0",
62 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
63 [VppRoutePath("0.0.0.0",
65 nh_table_id=0)], table_id=1)
66 ip_t01.add_vpp_config()
67 ip_t10.add_vpp_config()
69 # Start builtin server and client with small private segments
70 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
71 error = self.vapi.cli("test echo server appns 0 fifo-size 64 " +
72 "private-segment-size 1m uri " + uri)
74 self.logger.critical(error)
75 self.assertNotIn("failed", error)
77 error = self.vapi.cli("test echo client nclients 100 appns 1 " +
78 "no-output fifo-size 64 syn-timeout 2 " +
79 "private-segment-size 1m uri " + uri)
81 self.logger.critical(error)
82 self.assertNotIn("failed", error)
87 # Delete inter-table routes
88 ip_t01.remove_vpp_config()
89 ip_t10.remove_vpp_config()
92 class TestSessionUnitTests(VppTestCase):
93 """ Session Unit Tests Case """
97 super(TestSessionUnitTests, cls).setUpClass()
100 def tearDownClass(cls):
101 super(TestSessionUnitTests, cls).tearDownClass()
104 super(TestSessionUnitTests, self).setUp()
105 self.vapi.session_enable_disable(is_enabled=1)
107 def test_session(self):
108 """ Session Unit Tests """
109 error = self.vapi.cli("test session all")
112 self.logger.critical(error)
113 self.assertNotIn("failed", error)
116 super(TestSessionUnitTests, self).tearDown()
117 self.vapi.session_enable_disable(is_enabled=0)
120 class TestSvmFifoUnitTests(VppTestCase):
121 """ SVM Fifo Unit Tests Case """
125 super(TestSvmFifoUnitTests, cls).setUpClass()
128 def tearDownClass(cls):
129 super(TestSvmFifoUnitTests, cls).tearDownClass()
132 super(TestSvmFifoUnitTests, self).setUp()
134 def test_svm_fifo(self):
135 """ SVM Fifo Unit Tests """
136 error = self.vapi.cli("test svm fifo all")
139 self.logger.critical(error)
140 self.assertNotIn("failed", error)
143 super(TestSvmFifoUnitTests, self).tearDown()
145 if __name__ == '__main__':
146 unittest.main(testRunner=VppTestRunner)