Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 2 | |
| 3 | import unittest |
| 4 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 5 | from asfframework import ( |
| 6 | VppAsfTestCase, |
| 7 | VppTestRunner, |
| 8 | tag_fixme_vpp_workers, |
| 9 | tag_run_solo, |
| 10 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 11 | from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame^] | 12 | from config import config |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 13 | |
| 14 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 15 | @tag_fixme_vpp_workers |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame^] | 16 | @unittest.skipIf( |
| 17 | "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin" |
| 18 | ) |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 19 | class TestSession(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 20 | """Session Test Case""" |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 21 | |
| 22 | @classmethod |
| 23 | def setUpClass(cls): |
| 24 | super(TestSession, cls).setUpClass() |
| 25 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 26 | @classmethod |
| 27 | def tearDownClass(cls): |
| 28 | super(TestSession, cls).tearDownClass() |
| 29 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 30 | def setUp(self): |
| 31 | super(TestSession, self).setUp() |
| 32 | |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 33 | self.vapi.session_enable_disable(is_enable=1) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 34 | self.create_loopback_interfaces(2) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 35 | |
| 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 Skrzypczak | 51f1b26 | 2023-04-27 12:43:46 +0200 | [diff] [blame] | 50 | self.vapi.app_namespace_add_del_v4( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 51 | namespace_id="0", sw_if_index=self.loop0.sw_if_index |
| 52 | ) |
Nathan Skrzypczak | 51f1b26 | 2023-04-27 12:43:46 +0200 | [diff] [blame] | 53 | self.vapi.app_namespace_add_del_v4( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 54 | namespace_id="1", sw_if_index=self.loop1.sw_if_index |
| 55 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 56 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 57 | def tearDown(self): |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 58 | for i in self.lo_interfaces: |
| 59 | i.unconfig_ip4() |
| 60 | i.set_table_ip4(0) |
| 61 | i.admin_down() |
| 62 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 63 | super(TestSession, self).tearDown() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 64 | self.vapi.session_enable_disable(is_enable=1) |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 65 | |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 66 | def test_segment_manager_alloc(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 67 | """Session Segment Manager Multiple Segment Allocation""" |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 68 | |
| 69 | # Add inter-table routes |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 70 | 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 Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 83 | 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 88 | error = self.vapi.cli( |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 89 | "test echo server appns 0 fifo-size 64k " |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 90 | + "private-segment-size 1m uri " |
| 91 | + uri |
| 92 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 93 | if error: |
| 94 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 95 | self.assertNotIn("failed", error) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 96 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 97 | error = self.vapi.cli( |
| 98 | "test echo client nclients 100 appns 1 " |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 99 | + "fifo-size 64k syn-timeout 2 " |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 100 | + "private-segment-size 1m uri " |
| 101 | + uri |
| 102 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 103 | if error: |
| 104 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 105 | self.assertNotIn("failed", error) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 106 | |
Florin Coras | f8f516a | 2018-02-08 15:10:09 -0800 | [diff] [blame] | 107 | if self.vpp_dead: |
| 108 | self.assert_equal(0) |
| 109 | |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 110 | # Delete inter-table routes |
| 111 | ip_t01.remove_vpp_config() |
| 112 | ip_t10.remove_vpp_config() |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 113 | |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 114 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 115 | @tag_fixme_vpp_workers |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 116 | class TestSessionUnitTests(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 117 | """Session Unit Tests Case""" |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 118 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 119 | @classmethod |
| 120 | def setUpClass(cls): |
| 121 | super(TestSessionUnitTests, cls).setUpClass() |
| 122 | |
| 123 | @classmethod |
| 124 | def tearDownClass(cls): |
| 125 | super(TestSessionUnitTests, cls).tearDownClass() |
| 126 | |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 127 | def setUp(self): |
| 128 | super(TestSessionUnitTests, self).setUp() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 129 | self.vapi.session_enable_disable(is_enable=1) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 130 | |
| 131 | def test_session(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 132 | """Session Unit Tests""" |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 133 | error = self.vapi.cli("test session all") |
| 134 | |
| 135 | if error: |
| 136 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 137 | self.assertNotIn("failed", error) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 138 | |
| 139 | def tearDown(self): |
| 140 | super(TestSessionUnitTests, self).tearDown() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 141 | self.vapi.session_enable_disable(is_enable=0) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 142 | |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 143 | |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 144 | @tag_run_solo |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 145 | class TestSegmentManagerTests(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 146 | """SVM Fifo Unit Tests Case""" |
Filip Tehlar | f687986 | 2021-11-30 13:55:58 +0000 | [diff] [blame] | 147 | |
| 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 160 | """Segment manager Tests""" |
Filip Tehlar | f687986 | 2021-11-30 13:55:58 +0000 | [diff] [blame] | 161 | 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 Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 172 | class TestSvmFifoUnitTests(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 173 | """SVM Fifo Unit Tests Case""" |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 174 | |
| 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 187 | """SVM Fifo Unit Tests""" |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 188 | 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 197 | |
| 198 | if __name__ == "__main__": |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 199 | unittest.main(testRunner=VppTestRunner) |