blob: 184ec4fba542e5721d31e29610683725bfff666e [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
Dave Wallace8800f732023-08-31 00:47:44 -04005from asfframework import (
6 VppAsfTestCase,
7 VppTestRunner,
8 tag_fixme_vpp_workers,
9 tag_run_solo,
10)
Florin Corasa332c462018-01-31 06:52:17 -080011from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
Dmitry Valter34fa0ce2024-03-11 10:38:46 +000012from config import config
Florin Coras3ea6ce22017-12-11 09:09:05 -080013
14
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +000015@tag_fixme_vpp_workers
Dmitry Valter34fa0ce2024-03-11 10:38:46 +000016@unittest.skipIf(
17 "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
18)
Dave Wallace8800f732023-08-31 00:47:44 -040019class TestSession(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020020 """Session Test Case"""
Florin Coras3ea6ce22017-12-11 09:09:05 -080021
22 @classmethod
23 def setUpClass(cls):
24 super(TestSession, cls).setUpClass()
25
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070026 @classmethod
27 def tearDownClass(cls):
28 super(TestSession, cls).tearDownClass()
29
Florin Coras3ea6ce22017-12-11 09:09:05 -080030 def setUp(self):
31 super(TestSession, self).setUp()
32
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010033 self.vapi.session_enable_disable(is_enable=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020034 self.create_loopback_interfaces(2)
Florin Corasa332c462018-01-31 06:52:17 -080035
36 table_id = 0
37
38 for i in self.lo_interfaces:
39 i.admin_up()
40
41 if table_id != 0:
42 tbl = VppIpTable(self, table_id)
43 tbl.add_vpp_config()
44
45 i.set_table_ip4(table_id)
46 i.config_ip4()
47 table_id += 1
48
49 # Configure namespaces
Nathan Skrzypczak51f1b262023-04-27 12:43:46 +020050 self.vapi.app_namespace_add_del_v4(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020051 namespace_id="0", sw_if_index=self.loop0.sw_if_index
52 )
Nathan Skrzypczak51f1b262023-04-27 12:43:46 +020053 self.vapi.app_namespace_add_del_v4(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020054 namespace_id="1", sw_if_index=self.loop1.sw_if_index
55 )
Florin Corasa332c462018-01-31 06:52:17 -080056
Florin Coras3ea6ce22017-12-11 09:09:05 -080057 def tearDown(self):
Florin Corasa332c462018-01-31 06:52:17 -080058 for i in self.lo_interfaces:
59 i.unconfig_ip4()
60 i.set_table_ip4(0)
61 i.admin_down()
62
Steven Luong67bae202024-07-08 11:21:23 -070063 # Unconfigure namespaces - remove our locks to the vrf tables
64 self.vapi.app_namespace_add_del_v4(
65 is_add=0, namespace_id="0", sw_if_index=self.loop0.sw_if_index
66 )
67 self.vapi.app_namespace_add_del_v4(
68 is_add=0, namespace_id="1", sw_if_index=self.loop1.sw_if_index
69 )
70
Florin Coras3ea6ce22017-12-11 09:09:05 -080071 super(TestSession, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010072 self.vapi.session_enable_disable(is_enable=1)
Florin Coras3ea6ce22017-12-11 09:09:05 -080073
Florin Corasa332c462018-01-31 06:52:17 -080074 def test_segment_manager_alloc(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020075 """Session Segment Manager Multiple Segment Allocation"""
Florin Corasa332c462018-01-31 06:52:17 -080076
77 # Add inter-table routes
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020078 ip_t01 = VppIpRoute(
79 self,
80 self.loop1.local_ip4,
81 32,
82 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=1)],
83 )
84 ip_t10 = VppIpRoute(
85 self,
86 self.loop0.local_ip4,
87 32,
88 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=0)],
89 table_id=1,
90 )
Florin Corasa332c462018-01-31 06:52:17 -080091 ip_t01.add_vpp_config()
92 ip_t10.add_vpp_config()
93
94 # Start builtin server and client with small private segments
95 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020096 error = self.vapi.cli(
Filip Tehlarefe875e2023-09-04 14:17:52 +020097 "test echo server appns 0 fifo-size 64k "
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020098 + "private-segment-size 1m uri "
99 + uri
100 )
Florin Corasa332c462018-01-31 06:52:17 -0800101 if error:
102 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800103 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -0800104
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200105 error = self.vapi.cli(
106 "test echo client nclients 100 appns 1 "
Filip Tehlarefe875e2023-09-04 14:17:52 +0200107 + "fifo-size 64k syn-timeout 2 "
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200108 + "private-segment-size 1m uri "
109 + uri
110 )
Florin Corasa332c462018-01-31 06:52:17 -0800111 if error:
112 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800113 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -0800114
Florin Corasf8f516a2018-02-08 15:10:09 -0800115 if self.vpp_dead:
116 self.assert_equal(0)
117
Florin Corasa332c462018-01-31 06:52:17 -0800118 # Delete inter-table routes
119 ip_t01.remove_vpp_config()
120 ip_t10.remove_vpp_config()
Florin Coras3ea6ce22017-12-11 09:09:05 -0800121
Florin Coras5665ced2018-10-25 18:03:45 -0700122
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +0000123@tag_fixme_vpp_workers
Dave Wallace8800f732023-08-31 00:47:44 -0400124class TestSessionUnitTests(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200125 """Session Unit Tests Case"""
Florin Coras5665ced2018-10-25 18:03:45 -0700126
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700127 @classmethod
128 def setUpClass(cls):
129 super(TestSessionUnitTests, cls).setUpClass()
130
131 @classmethod
132 def tearDownClass(cls):
133 super(TestSessionUnitTests, cls).tearDownClass()
134
Florin Coras5665ced2018-10-25 18:03:45 -0700135 def setUp(self):
136 super(TestSessionUnitTests, self).setUp()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100137 self.vapi.session_enable_disable(is_enable=1)
Florin Coras5665ced2018-10-25 18:03:45 -0700138
139 def test_session(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200140 """Session Unit Tests"""
Florin Coras5665ced2018-10-25 18:03:45 -0700141 error = self.vapi.cli("test session all")
142
143 if error:
144 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800145 self.assertNotIn("failed", error)
Florin Coras5665ced2018-10-25 18:03:45 -0700146
147 def tearDown(self):
148 super(TestSessionUnitTests, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100149 self.vapi.session_enable_disable(is_enable=0)
Florin Coras5665ced2018-10-25 18:03:45 -0700150
Florin Corasf682fac2019-04-18 20:50:50 -0700151
Andrew Yourtchenko06f32812021-01-14 10:19:08 +0000152@tag_run_solo
Dave Wallace8800f732023-08-31 00:47:44 -0400153class TestSegmentManagerTests(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200154 """SVM Fifo Unit Tests Case"""
Filip Tehlarf6879862021-11-30 13:55:58 +0000155
156 @classmethod
157 def setUpClass(cls):
158 super(TestSegmentManagerTests, cls).setUpClass()
159
160 @classmethod
161 def tearDownClass(cls):
162 super(TestSegmentManagerTests, cls).tearDownClass()
163
164 def setUp(self):
165 super(TestSegmentManagerTests, self).setUp()
166
167 def test_segment_manager(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200168 """Segment manager Tests"""
Filip Tehlarf6879862021-11-30 13:55:58 +0000169 error = self.vapi.cli("test segment-manager all")
170
171 if error:
172 self.logger.critical(error)
173 self.assertNotIn("failed", error)
174
175 def tearDown(self):
176 super(TestSegmentManagerTests, self).tearDown()
177
178
179@tag_run_solo
Dave Wallace8800f732023-08-31 00:47:44 -0400180class TestSvmFifoUnitTests(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200181 """SVM Fifo Unit Tests Case"""
Florin Corasf682fac2019-04-18 20:50:50 -0700182
183 @classmethod
184 def setUpClass(cls):
185 super(TestSvmFifoUnitTests, cls).setUpClass()
186
187 @classmethod
188 def tearDownClass(cls):
189 super(TestSvmFifoUnitTests, cls).tearDownClass()
190
191 def setUp(self):
192 super(TestSvmFifoUnitTests, self).setUp()
193
194 def test_svm_fifo(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200195 """SVM Fifo Unit Tests"""
Florin Corasf682fac2019-04-18 20:50:50 -0700196 error = self.vapi.cli("test svm fifo all")
197
198 if error:
199 self.logger.critical(error)
200 self.assertNotIn("failed", error)
201
202 def tearDown(self):
203 super(TestSvmFifoUnitTests, self).tearDown()
204
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200205
206if __name__ == "__main__":
Florin Coras3ea6ce22017-12-11 09:09:05 -0800207 unittest.main(testRunner=VppTestRunner)