blob: 699ebafc386fca5c3f3fc0d36230864428949742 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Florin Coras3ea6ce22017-12-11 09:09:05 -08002
3import unittest
4
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +00005from framework import tag_fixme_vpp_workers
Florin Coras3ea6ce22017-12-11 09:09:05 -08006from framework import VppTestCase, VppTestRunner
Andrew Yourtchenko06f32812021-01-14 10:19:08 +00007from framework import tag_run_solo
Florin Corasa332c462018-01-31 06:52:17 -08008from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
Florin Coras3ea6ce22017-12-11 09:09:05 -08009
10
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +000011@tag_fixme_vpp_workers
Florin Coras3ea6ce22017-12-11 09:09:05 -080012class TestSession(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020013 """Session Test Case"""
Florin Coras3ea6ce22017-12-11 09:09:05 -080014
15 @classmethod
16 def setUpClass(cls):
17 super(TestSession, cls).setUpClass()
18
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070019 @classmethod
20 def tearDownClass(cls):
21 super(TestSession, cls).tearDownClass()
22
Florin Coras3ea6ce22017-12-11 09:09:05 -080023 def setUp(self):
24 super(TestSession, self).setUp()
25
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010026 self.vapi.session_enable_disable(is_enable=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020027 self.create_loopback_interfaces(2)
Florin Corasa332c462018-01-31 06:52:17 -080028
29 table_id = 0
30
31 for i in self.lo_interfaces:
32 i.admin_up()
33
34 if table_id != 0:
35 tbl = VppIpTable(self, table_id)
36 tbl.add_vpp_config()
37
38 i.set_table_ip4(table_id)
39 i.config_ip4()
40 table_id += 1
41
42 # Configure namespaces
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020043 self.vapi.app_namespace_add_del(
44 namespace_id="0", sw_if_index=self.loop0.sw_if_index
45 )
46 self.vapi.app_namespace_add_del(
47 namespace_id="1", sw_if_index=self.loop1.sw_if_index
48 )
Florin Corasa332c462018-01-31 06:52:17 -080049
Florin Coras3ea6ce22017-12-11 09:09:05 -080050 def tearDown(self):
Florin Corasa332c462018-01-31 06:52:17 -080051 for i in self.lo_interfaces:
52 i.unconfig_ip4()
53 i.set_table_ip4(0)
54 i.admin_down()
55
Florin Coras3ea6ce22017-12-11 09:09:05 -080056 super(TestSession, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010057 self.vapi.session_enable_disable(is_enable=1)
Florin Coras3ea6ce22017-12-11 09:09:05 -080058
Florin Corasa332c462018-01-31 06:52:17 -080059 def test_segment_manager_alloc(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020060 """Session Segment Manager Multiple Segment Allocation"""
Florin Corasa332c462018-01-31 06:52:17 -080061
62 # Add inter-table routes
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020063 ip_t01 = VppIpRoute(
64 self,
65 self.loop1.local_ip4,
66 32,
67 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=1)],
68 )
69 ip_t10 = VppIpRoute(
70 self,
71 self.loop0.local_ip4,
72 32,
73 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=0)],
74 table_id=1,
75 )
Florin Corasa332c462018-01-31 06:52:17 -080076 ip_t01.add_vpp_config()
77 ip_t10.add_vpp_config()
78
79 # Start builtin server and client with small private segments
80 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020081 error = self.vapi.cli(
82 "test echo server appns 0 fifo-size 64 "
83 + "private-segment-size 1m uri "
84 + uri
85 )
Florin Corasa332c462018-01-31 06:52:17 -080086 if error:
87 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080088 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080089
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020090 error = self.vapi.cli(
91 "test echo client nclients 100 appns 1 "
92 + "no-output fifo-size 64 syn-timeout 2 "
93 + "private-segment-size 1m uri "
94 + uri
95 )
Florin Corasa332c462018-01-31 06:52:17 -080096 if error:
97 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080098 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080099
Florin Corasf8f516a2018-02-08 15:10:09 -0800100 if self.vpp_dead:
101 self.assert_equal(0)
102
Florin Corasa332c462018-01-31 06:52:17 -0800103 # Delete inter-table routes
104 ip_t01.remove_vpp_config()
105 ip_t10.remove_vpp_config()
Florin Coras3ea6ce22017-12-11 09:09:05 -0800106
Florin Coras5665ced2018-10-25 18:03:45 -0700107
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +0000108@tag_fixme_vpp_workers
Florin Coras5665ced2018-10-25 18:03:45 -0700109class TestSessionUnitTests(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200110 """Session Unit Tests Case"""
Florin Coras5665ced2018-10-25 18:03:45 -0700111
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700112 @classmethod
113 def setUpClass(cls):
114 super(TestSessionUnitTests, cls).setUpClass()
115
116 @classmethod
117 def tearDownClass(cls):
118 super(TestSessionUnitTests, cls).tearDownClass()
119
Florin Coras5665ced2018-10-25 18:03:45 -0700120 def setUp(self):
121 super(TestSessionUnitTests, self).setUp()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100122 self.vapi.session_enable_disable(is_enable=1)
Florin Coras5665ced2018-10-25 18:03:45 -0700123
124 def test_session(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200125 """Session Unit Tests"""
Florin Coras5665ced2018-10-25 18:03:45 -0700126 error = self.vapi.cli("test session all")
127
128 if error:
129 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800130 self.assertNotIn("failed", error)
Florin Coras5665ced2018-10-25 18:03:45 -0700131
132 def tearDown(self):
133 super(TestSessionUnitTests, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100134 self.vapi.session_enable_disable(is_enable=0)
Florin Coras5665ced2018-10-25 18:03:45 -0700135
Florin Corasf682fac2019-04-18 20:50:50 -0700136
Andrew Yourtchenko06f32812021-01-14 10:19:08 +0000137@tag_run_solo
Filip Tehlarf6879862021-11-30 13:55:58 +0000138class TestSegmentManagerTests(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200139 """SVM Fifo Unit Tests Case"""
Filip Tehlarf6879862021-11-30 13:55:58 +0000140
141 @classmethod
142 def setUpClass(cls):
143 super(TestSegmentManagerTests, cls).setUpClass()
144
145 @classmethod
146 def tearDownClass(cls):
147 super(TestSegmentManagerTests, cls).tearDownClass()
148
149 def setUp(self):
150 super(TestSegmentManagerTests, self).setUp()
151
152 def test_segment_manager(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200153 """Segment manager Tests"""
Filip Tehlarf6879862021-11-30 13:55:58 +0000154 error = self.vapi.cli("test segment-manager all")
155
156 if error:
157 self.logger.critical(error)
158 self.assertNotIn("failed", error)
159
160 def tearDown(self):
161 super(TestSegmentManagerTests, self).tearDown()
162
163
164@tag_run_solo
Florin Corasf682fac2019-04-18 20:50:50 -0700165class TestSvmFifoUnitTests(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200166 """SVM Fifo Unit Tests Case"""
Florin Corasf682fac2019-04-18 20:50:50 -0700167
168 @classmethod
169 def setUpClass(cls):
170 super(TestSvmFifoUnitTests, cls).setUpClass()
171
172 @classmethod
173 def tearDownClass(cls):
174 super(TestSvmFifoUnitTests, cls).tearDownClass()
175
176 def setUp(self):
177 super(TestSvmFifoUnitTests, self).setUp()
178
179 def test_svm_fifo(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200180 """SVM Fifo Unit Tests"""
Florin Corasf682fac2019-04-18 20:50:50 -0700181 error = self.vapi.cli("test svm fifo all")
182
183 if error:
184 self.logger.critical(error)
185 self.assertNotIn("failed", error)
186
187 def tearDown(self):
188 super(TestSvmFifoUnitTests, self).tearDown()
189
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200190
191if __name__ == "__main__":
Florin Coras3ea6ce22017-12-11 09:09:05 -0800192 unittest.main(testRunner=VppTestRunner)