blob: 741773d6989ec31cca7d6feea62201b06f53ec4f [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
Florin Coras3ea6ce22017-12-11 09:09:05 -080063 super(TestSession, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010064 self.vapi.session_enable_disable(is_enable=1)
Florin Coras3ea6ce22017-12-11 09:09:05 -080065
Florin Corasa332c462018-01-31 06:52:17 -080066 def test_segment_manager_alloc(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020067 """Session Segment Manager Multiple Segment Allocation"""
Florin Corasa332c462018-01-31 06:52:17 -080068
69 # Add inter-table routes
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020070 ip_t01 = VppIpRoute(
71 self,
72 self.loop1.local_ip4,
73 32,
74 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=1)],
75 )
76 ip_t10 = VppIpRoute(
77 self,
78 self.loop0.local_ip4,
79 32,
80 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=0)],
81 table_id=1,
82 )
Florin Corasa332c462018-01-31 06:52:17 -080083 ip_t01.add_vpp_config()
84 ip_t10.add_vpp_config()
85
86 # Start builtin server and client with small private segments
87 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020088 error = self.vapi.cli(
Filip Tehlarefe875e2023-09-04 14:17:52 +020089 "test echo server appns 0 fifo-size 64k "
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020090 + "private-segment-size 1m uri "
91 + uri
92 )
Florin Corasa332c462018-01-31 06:52:17 -080093 if error:
94 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080095 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080096
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020097 error = self.vapi.cli(
98 "test echo client nclients 100 appns 1 "
Filip Tehlarefe875e2023-09-04 14:17:52 +020099 + "fifo-size 64k syn-timeout 2 "
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200100 + "private-segment-size 1m uri "
101 + uri
102 )
Florin Corasa332c462018-01-31 06:52:17 -0800103 if error:
104 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800105 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -0800106
Florin Corasf8f516a2018-02-08 15:10:09 -0800107 if self.vpp_dead:
108 self.assert_equal(0)
109
Florin Corasa332c462018-01-31 06:52:17 -0800110 # Delete inter-table routes
111 ip_t01.remove_vpp_config()
112 ip_t10.remove_vpp_config()
Florin Coras3ea6ce22017-12-11 09:09:05 -0800113
Florin Coras5665ced2018-10-25 18:03:45 -0700114
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +0000115@tag_fixme_vpp_workers
Dave Wallace8800f732023-08-31 00:47:44 -0400116class TestSessionUnitTests(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200117 """Session Unit Tests Case"""
Florin Coras5665ced2018-10-25 18:03:45 -0700118
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700119 @classmethod
120 def setUpClass(cls):
121 super(TestSessionUnitTests, cls).setUpClass()
122
123 @classmethod
124 def tearDownClass(cls):
125 super(TestSessionUnitTests, cls).tearDownClass()
126
Florin Coras5665ced2018-10-25 18:03:45 -0700127 def setUp(self):
128 super(TestSessionUnitTests, self).setUp()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100129 self.vapi.session_enable_disable(is_enable=1)
Florin Coras5665ced2018-10-25 18:03:45 -0700130
131 def test_session(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200132 """Session Unit Tests"""
Florin Coras5665ced2018-10-25 18:03:45 -0700133 error = self.vapi.cli("test session all")
134
135 if error:
136 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800137 self.assertNotIn("failed", error)
Florin Coras5665ced2018-10-25 18:03:45 -0700138
139 def tearDown(self):
140 super(TestSessionUnitTests, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100141 self.vapi.session_enable_disable(is_enable=0)
Florin Coras5665ced2018-10-25 18:03:45 -0700142
Florin Corasf682fac2019-04-18 20:50:50 -0700143
Andrew Yourtchenko06f32812021-01-14 10:19:08 +0000144@tag_run_solo
Dave Wallace8800f732023-08-31 00:47:44 -0400145class TestSegmentManagerTests(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200146 """SVM Fifo Unit Tests Case"""
Filip Tehlarf6879862021-11-30 13:55:58 +0000147
148 @classmethod
149 def setUpClass(cls):
150 super(TestSegmentManagerTests, cls).setUpClass()
151
152 @classmethod
153 def tearDownClass(cls):
154 super(TestSegmentManagerTests, cls).tearDownClass()
155
156 def setUp(self):
157 super(TestSegmentManagerTests, self).setUp()
158
159 def test_segment_manager(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200160 """Segment manager Tests"""
Filip Tehlarf6879862021-11-30 13:55:58 +0000161 error = self.vapi.cli("test segment-manager all")
162
163 if error:
164 self.logger.critical(error)
165 self.assertNotIn("failed", error)
166
167 def tearDown(self):
168 super(TestSegmentManagerTests, self).tearDown()
169
170
171@tag_run_solo
Dave Wallace8800f732023-08-31 00:47:44 -0400172class TestSvmFifoUnitTests(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200173 """SVM Fifo Unit Tests Case"""
Florin Corasf682fac2019-04-18 20:50:50 -0700174
175 @classmethod
176 def setUpClass(cls):
177 super(TestSvmFifoUnitTests, cls).setUpClass()
178
179 @classmethod
180 def tearDownClass(cls):
181 super(TestSvmFifoUnitTests, cls).tearDownClass()
182
183 def setUp(self):
184 super(TestSvmFifoUnitTests, self).setUp()
185
186 def test_svm_fifo(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200187 """SVM Fifo Unit Tests"""
Florin Corasf682fac2019-04-18 20:50:50 -0700188 error = self.vapi.cli("test svm fifo all")
189
190 if error:
191 self.logger.critical(error)
192 self.assertNotIn("failed", error)
193
194 def tearDown(self):
195 super(TestSvmFifoUnitTests, self).tearDown()
196
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200197
198if __name__ == "__main__":
Florin Coras3ea6ce22017-12-11 09:09:05 -0800199 unittest.main(testRunner=VppTestRunner)