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 |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 12 | |
| 13 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 14 | @tag_fixme_vpp_workers |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 15 | class TestSession(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 16 | """Session Test Case""" |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 17 | |
| 18 | @classmethod |
| 19 | def setUpClass(cls): |
| 20 | super(TestSession, cls).setUpClass() |
| 21 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 22 | @classmethod |
| 23 | def tearDownClass(cls): |
| 24 | super(TestSession, cls).tearDownClass() |
| 25 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 26 | def setUp(self): |
| 27 | super(TestSession, self).setUp() |
| 28 | |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 29 | self.vapi.session_enable_disable(is_enable=1) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 30 | self.create_loopback_interfaces(2) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 31 | |
| 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 Skrzypczak | 51f1b26 | 2023-04-27 12:43:46 +0200 | [diff] [blame] | 46 | self.vapi.app_namespace_add_del_v4( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 47 | namespace_id="0", sw_if_index=self.loop0.sw_if_index |
| 48 | ) |
Nathan Skrzypczak | 51f1b26 | 2023-04-27 12:43:46 +0200 | [diff] [blame] | 49 | self.vapi.app_namespace_add_del_v4( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 50 | namespace_id="1", sw_if_index=self.loop1.sw_if_index |
| 51 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 52 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 53 | def tearDown(self): |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 54 | for i in self.lo_interfaces: |
| 55 | i.unconfig_ip4() |
| 56 | i.set_table_ip4(0) |
| 57 | i.admin_down() |
| 58 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 59 | super(TestSession, self).tearDown() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 60 | self.vapi.session_enable_disable(is_enable=1) |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 61 | |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 62 | def test_segment_manager_alloc(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 63 | """Session Segment Manager Multiple Segment Allocation""" |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 64 | |
| 65 | # Add inter-table routes |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 66 | 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 Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 79 | 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 84 | error = self.vapi.cli( |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 85 | "test echo server appns 0 fifo-size 64k " |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 86 | + "private-segment-size 1m uri " |
| 87 | + uri |
| 88 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 89 | if error: |
| 90 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 91 | self.assertNotIn("failed", error) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 92 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 93 | error = self.vapi.cli( |
| 94 | "test echo client nclients 100 appns 1 " |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 95 | + "fifo-size 64k syn-timeout 2 " |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 96 | + "private-segment-size 1m uri " |
| 97 | + uri |
| 98 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 99 | if error: |
| 100 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 101 | self.assertNotIn("failed", error) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 102 | |
Florin Coras | f8f516a | 2018-02-08 15:10:09 -0800 | [diff] [blame] | 103 | if self.vpp_dead: |
| 104 | self.assert_equal(0) |
| 105 | |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 106 | # Delete inter-table routes |
| 107 | ip_t01.remove_vpp_config() |
| 108 | ip_t10.remove_vpp_config() |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 109 | |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 110 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 111 | @tag_fixme_vpp_workers |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 112 | class TestSessionUnitTests(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 113 | """Session Unit Tests Case""" |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 114 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 115 | @classmethod |
| 116 | def setUpClass(cls): |
| 117 | super(TestSessionUnitTests, cls).setUpClass() |
| 118 | |
| 119 | @classmethod |
| 120 | def tearDownClass(cls): |
| 121 | super(TestSessionUnitTests, cls).tearDownClass() |
| 122 | |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 123 | def setUp(self): |
| 124 | super(TestSessionUnitTests, self).setUp() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 125 | self.vapi.session_enable_disable(is_enable=1) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 126 | |
| 127 | def test_session(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 128 | """Session Unit Tests""" |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 129 | error = self.vapi.cli("test session all") |
| 130 | |
| 131 | if error: |
| 132 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 133 | self.assertNotIn("failed", error) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 134 | |
| 135 | def tearDown(self): |
| 136 | super(TestSessionUnitTests, self).tearDown() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 137 | self.vapi.session_enable_disable(is_enable=0) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 138 | |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 139 | |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 140 | @tag_run_solo |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 141 | class TestSegmentManagerTests(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 142 | """SVM Fifo Unit Tests Case""" |
Filip Tehlar | f687986 | 2021-11-30 13:55:58 +0000 | [diff] [blame] | 143 | |
| 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 156 | """Segment manager Tests""" |
Filip Tehlar | f687986 | 2021-11-30 13:55:58 +0000 | [diff] [blame] | 157 | 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 Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 168 | class TestSvmFifoUnitTests(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 169 | """SVM Fifo Unit Tests Case""" |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 170 | |
| 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 183 | """SVM Fifo Unit Tests""" |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 184 | 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 193 | |
| 194 | if __name__ == "__main__": |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 195 | unittest.main(testRunner=VppTestRunner) |