5 from framework import VppTestCase, VppTestRunner
6 from framework import tag_run_solo
7 from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
10 class TestSession(VppTestCase):
11 """ Session Test Case """
15 super(TestSession, cls).setUpClass()
18 def tearDownClass(cls):
19 super(TestSession, cls).tearDownClass()
22 super(TestSession, self).setUp()
24 self.vapi.session_enable_disable(is_enable=1)
25 self.create_loopback_interfaces(2)
29 for i in self.lo_interfaces:
33 tbl = VppIpTable(self, table_id)
36 i.set_table_ip4(table_id)
40 # Configure namespaces
41 self.vapi.app_namespace_add_del(namespace_id="0",
42 sw_if_index=self.loop0.sw_if_index)
43 self.vapi.app_namespace_add_del(namespace_id="1",
44 sw_if_index=self.loop1.sw_if_index)
47 for i in self.lo_interfaces:
52 super(TestSession, self).tearDown()
53 self.vapi.session_enable_disable(is_enable=1)
55 def test_segment_manager_alloc(self):
56 """ Session Segment Manager Multiple Segment Allocation """
58 # Add inter-table routes
59 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
60 [VppRoutePath("0.0.0.0",
63 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
64 [VppRoutePath("0.0.0.0",
66 nh_table_id=0)], table_id=1)
67 ip_t01.add_vpp_config()
68 ip_t10.add_vpp_config()
70 # Start builtin server and client with small private segments
71 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
72 error = self.vapi.cli("test echo server appns 0 fifo-size 64 " +
73 "private-segment-size 1m uri " + uri)
75 self.logger.critical(error)
76 self.assertNotIn("failed", error)
78 error = self.vapi.cli("test echo client nclients 100 appns 1 " +
79 "no-output fifo-size 64 syn-timeout 2 " +
80 "private-segment-size 1m uri " + uri)
82 self.logger.critical(error)
83 self.assertNotIn("failed", error)
88 # Delete inter-table routes
89 ip_t01.remove_vpp_config()
90 ip_t10.remove_vpp_config()
93 class TestSessionUnitTests(VppTestCase):
94 """ Session Unit Tests Case """
98 super(TestSessionUnitTests, cls).setUpClass()
101 def tearDownClass(cls):
102 super(TestSessionUnitTests, cls).tearDownClass()
105 super(TestSessionUnitTests, self).setUp()
106 self.vapi.session_enable_disable(is_enable=1)
108 def test_session(self):
109 """ Session Unit Tests """
110 error = self.vapi.cli("test session all")
113 self.logger.critical(error)
114 self.assertNotIn("failed", error)
117 super(TestSessionUnitTests, self).tearDown()
118 self.vapi.session_enable_disable(is_enable=0)
122 class TestSvmFifoUnitTests(VppTestCase):
123 """ SVM Fifo Unit Tests Case """
127 super(TestSvmFifoUnitTests, cls).setUpClass()
130 def tearDownClass(cls):
131 super(TestSvmFifoUnitTests, cls).tearDownClass()
134 super(TestSvmFifoUnitTests, self).setUp()
136 def test_svm_fifo(self):
137 """ SVM Fifo Unit Tests """
138 error = self.vapi.cli("test svm fifo all")
141 self.logger.critical(error)
142 self.assertNotIn("failed", error)
145 super(TestSvmFifoUnitTests, self).tearDown()
147 if __name__ == '__main__':
148 unittest.main(testRunner=VppTestRunner)