blob: 64f59df57589712cd26a37c55b4b1fa7142634a4 [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
Florin Coras3ea6ce22017-12-11 09:09:05 -080012
13
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +000014@tag_fixme_vpp_workers
Dave Wallace8800f732023-08-31 00:47:44 -040015class TestSession(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020016 """Session Test Case"""
Florin Coras3ea6ce22017-12-11 09:09:05 -080017
18 @classmethod
19 def setUpClass(cls):
20 super(TestSession, cls).setUpClass()
21
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070022 @classmethod
23 def tearDownClass(cls):
24 super(TestSession, cls).tearDownClass()
25
Florin Coras3ea6ce22017-12-11 09:09:05 -080026 def setUp(self):
27 super(TestSession, self).setUp()
28
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010029 self.vapi.session_enable_disable(is_enable=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020030 self.create_loopback_interfaces(2)
Florin Corasa332c462018-01-31 06:52:17 -080031
32 table_id = 0
33
34 for i in self.lo_interfaces:
35 i.admin_up()
36
37 if table_id != 0:
38 tbl = VppIpTable(self, table_id)
39 tbl.add_vpp_config()
40
41 i.set_table_ip4(table_id)
42 i.config_ip4()
43 table_id += 1
44
45 # Configure namespaces
Nathan Skrzypczak51f1b262023-04-27 12:43:46 +020046 self.vapi.app_namespace_add_del_v4(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020047 namespace_id="0", sw_if_index=self.loop0.sw_if_index
48 )
Nathan Skrzypczak51f1b262023-04-27 12:43:46 +020049 self.vapi.app_namespace_add_del_v4(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020050 namespace_id="1", sw_if_index=self.loop1.sw_if_index
51 )
Florin Corasa332c462018-01-31 06:52:17 -080052
Florin Coras3ea6ce22017-12-11 09:09:05 -080053 def tearDown(self):
Florin Corasa332c462018-01-31 06:52:17 -080054 for i in self.lo_interfaces:
55 i.unconfig_ip4()
56 i.set_table_ip4(0)
57 i.admin_down()
58
Florin Coras3ea6ce22017-12-11 09:09:05 -080059 super(TestSession, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010060 self.vapi.session_enable_disable(is_enable=1)
Florin Coras3ea6ce22017-12-11 09:09:05 -080061
Florin Corasa332c462018-01-31 06:52:17 -080062 def test_segment_manager_alloc(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020063 """Session Segment Manager Multiple Segment Allocation"""
Florin Corasa332c462018-01-31 06:52:17 -080064
65 # Add inter-table routes
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020066 ip_t01 = VppIpRoute(
67 self,
68 self.loop1.local_ip4,
69 32,
70 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=1)],
71 )
72 ip_t10 = VppIpRoute(
73 self,
74 self.loop0.local_ip4,
75 32,
76 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=0)],
77 table_id=1,
78 )
Florin Corasa332c462018-01-31 06:52:17 -080079 ip_t01.add_vpp_config()
80 ip_t10.add_vpp_config()
81
82 # Start builtin server and client with small private segments
83 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020084 error = self.vapi.cli(
Filip Tehlarefe875e2023-09-04 14:17:52 +020085 "test echo server appns 0 fifo-size 64k "
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020086 + "private-segment-size 1m uri "
87 + uri
88 )
Florin Corasa332c462018-01-31 06:52:17 -080089 if error:
90 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080091 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080092
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020093 error = self.vapi.cli(
94 "test echo client nclients 100 appns 1 "
Filip Tehlarefe875e2023-09-04 14:17:52 +020095 + "fifo-size 64k syn-timeout 2 "
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020096 + "private-segment-size 1m uri "
97 + uri
98 )
Florin Corasa332c462018-01-31 06:52:17 -080099 if error:
100 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800101 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -0800102
Florin Corasf8f516a2018-02-08 15:10:09 -0800103 if self.vpp_dead:
104 self.assert_equal(0)
105
Florin Corasa332c462018-01-31 06:52:17 -0800106 # Delete inter-table routes
107 ip_t01.remove_vpp_config()
108 ip_t10.remove_vpp_config()
Florin Coras3ea6ce22017-12-11 09:09:05 -0800109
Florin Coras5665ced2018-10-25 18:03:45 -0700110
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +0000111@tag_fixme_vpp_workers
Dave Wallace8800f732023-08-31 00:47:44 -0400112class TestSessionUnitTests(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200113 """Session Unit Tests Case"""
Florin Coras5665ced2018-10-25 18:03:45 -0700114
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700115 @classmethod
116 def setUpClass(cls):
117 super(TestSessionUnitTests, cls).setUpClass()
118
119 @classmethod
120 def tearDownClass(cls):
121 super(TestSessionUnitTests, cls).tearDownClass()
122
Florin Coras5665ced2018-10-25 18:03:45 -0700123 def setUp(self):
124 super(TestSessionUnitTests, self).setUp()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100125 self.vapi.session_enable_disable(is_enable=1)
Florin Coras5665ced2018-10-25 18:03:45 -0700126
127 def test_session(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200128 """Session Unit Tests"""
Florin Coras5665ced2018-10-25 18:03:45 -0700129 error = self.vapi.cli("test session all")
130
131 if error:
132 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800133 self.assertNotIn("failed", error)
Florin Coras5665ced2018-10-25 18:03:45 -0700134
135 def tearDown(self):
136 super(TestSessionUnitTests, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100137 self.vapi.session_enable_disable(is_enable=0)
Florin Coras5665ced2018-10-25 18:03:45 -0700138
Florin Corasf682fac2019-04-18 20:50:50 -0700139
Andrew Yourtchenko06f32812021-01-14 10:19:08 +0000140@tag_run_solo
Dave Wallace8800f732023-08-31 00:47:44 -0400141class TestSegmentManagerTests(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200142 """SVM Fifo Unit Tests Case"""
Filip Tehlarf6879862021-11-30 13:55:58 +0000143
144 @classmethod
145 def setUpClass(cls):
146 super(TestSegmentManagerTests, cls).setUpClass()
147
148 @classmethod
149 def tearDownClass(cls):
150 super(TestSegmentManagerTests, cls).tearDownClass()
151
152 def setUp(self):
153 super(TestSegmentManagerTests, self).setUp()
154
155 def test_segment_manager(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200156 """Segment manager Tests"""
Filip Tehlarf6879862021-11-30 13:55:58 +0000157 error = self.vapi.cli("test segment-manager all")
158
159 if error:
160 self.logger.critical(error)
161 self.assertNotIn("failed", error)
162
163 def tearDown(self):
164 super(TestSegmentManagerTests, self).tearDown()
165
166
167@tag_run_solo
Dave Wallace8800f732023-08-31 00:47:44 -0400168class TestSvmFifoUnitTests(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200169 """SVM Fifo Unit Tests Case"""
Florin Corasf682fac2019-04-18 20:50:50 -0700170
171 @classmethod
172 def setUpClass(cls):
173 super(TestSvmFifoUnitTests, cls).setUpClass()
174
175 @classmethod
176 def tearDownClass(cls):
177 super(TestSvmFifoUnitTests, cls).tearDownClass()
178
179 def setUp(self):
180 super(TestSvmFifoUnitTests, self).setUp()
181
182 def test_svm_fifo(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200183 """SVM Fifo Unit Tests"""
Florin Corasf682fac2019-04-18 20:50:50 -0700184 error = self.vapi.cli("test svm fifo all")
185
186 if error:
187 self.logger.critical(error)
188 self.assertNotIn("failed", error)
189
190 def tearDown(self):
191 super(TestSvmFifoUnitTests, self).tearDown()
192
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200193
194if __name__ == "__main__":
Florin Coras3ea6ce22017-12-11 09:09:05 -0800195 unittest.main(testRunner=VppTestRunner)