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 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 5 | from framework import tag_fixme_vpp_workers |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 6 | from framework import VppTestCase, VppTestRunner |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 7 | from framework import tag_run_solo |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 8 | from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 9 | |
| 10 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 11 | @tag_fixme_vpp_workers |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 12 | class TestSession(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 13 | """Session Test Case""" |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 14 | |
| 15 | @classmethod |
| 16 | def setUpClass(cls): |
| 17 | super(TestSession, cls).setUpClass() |
| 18 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 19 | @classmethod |
| 20 | def tearDownClass(cls): |
| 21 | super(TestSession, cls).tearDownClass() |
| 22 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 23 | def setUp(self): |
| 24 | super(TestSession, self).setUp() |
| 25 | |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 26 | self.vapi.session_enable_disable(is_enable=1) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 27 | self.create_loopback_interfaces(2) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 28 | |
| 29 | table_id = 0 |
| 30 | |
| 31 | for i in self.lo_interfaces: |
| 32 | i.admin_up() |
| 33 | |
| 34 | if table_id != 0: |
| 35 | tbl = VppIpTable(self, table_id) |
| 36 | tbl.add_vpp_config() |
| 37 | |
| 38 | i.set_table_ip4(table_id) |
| 39 | i.config_ip4() |
| 40 | table_id += 1 |
| 41 | |
| 42 | # Configure namespaces |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 43 | self.vapi.app_namespace_add_del( |
| 44 | namespace_id="0", sw_if_index=self.loop0.sw_if_index |
| 45 | ) |
| 46 | self.vapi.app_namespace_add_del( |
| 47 | namespace_id="1", sw_if_index=self.loop1.sw_if_index |
| 48 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 49 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 50 | def tearDown(self): |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 51 | for i in self.lo_interfaces: |
| 52 | i.unconfig_ip4() |
| 53 | i.set_table_ip4(0) |
| 54 | i.admin_down() |
| 55 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 56 | super(TestSession, self).tearDown() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 57 | self.vapi.session_enable_disable(is_enable=1) |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 58 | |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 59 | def test_segment_manager_alloc(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 60 | """Session Segment Manager Multiple Segment Allocation""" |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 61 | |
| 62 | # Add inter-table routes |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 63 | ip_t01 = VppIpRoute( |
| 64 | self, |
| 65 | self.loop1.local_ip4, |
| 66 | 32, |
| 67 | [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=1)], |
| 68 | ) |
| 69 | ip_t10 = VppIpRoute( |
| 70 | self, |
| 71 | self.loop0.local_ip4, |
| 72 | 32, |
| 73 | [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=0)], |
| 74 | table_id=1, |
| 75 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 76 | ip_t01.add_vpp_config() |
| 77 | ip_t10.add_vpp_config() |
| 78 | |
| 79 | # Start builtin server and client with small private segments |
| 80 | uri = "tcp://" + self.loop0.local_ip4 + "/1234" |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 81 | error = self.vapi.cli( |
| 82 | "test echo server appns 0 fifo-size 64 " |
| 83 | + "private-segment-size 1m uri " |
| 84 | + uri |
| 85 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 86 | if error: |
| 87 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 88 | self.assertNotIn("failed", error) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 89 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 90 | error = self.vapi.cli( |
| 91 | "test echo client nclients 100 appns 1 " |
| 92 | + "no-output fifo-size 64 syn-timeout 2 " |
| 93 | + "private-segment-size 1m uri " |
| 94 | + uri |
| 95 | ) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 96 | if error: |
| 97 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 98 | self.assertNotIn("failed", error) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 99 | |
Florin Coras | f8f516a | 2018-02-08 15:10:09 -0800 | [diff] [blame] | 100 | if self.vpp_dead: |
| 101 | self.assert_equal(0) |
| 102 | |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 103 | # Delete inter-table routes |
| 104 | ip_t01.remove_vpp_config() |
| 105 | ip_t10.remove_vpp_config() |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 106 | |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 107 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 108 | @tag_fixme_vpp_workers |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 109 | class TestSessionUnitTests(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 110 | """Session Unit Tests Case""" |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 111 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 112 | @classmethod |
| 113 | def setUpClass(cls): |
| 114 | super(TestSessionUnitTests, cls).setUpClass() |
| 115 | |
| 116 | @classmethod |
| 117 | def tearDownClass(cls): |
| 118 | super(TestSessionUnitTests, cls).tearDownClass() |
| 119 | |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 120 | def setUp(self): |
| 121 | super(TestSessionUnitTests, self).setUp() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 122 | self.vapi.session_enable_disable(is_enable=1) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 123 | |
| 124 | def test_session(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 125 | """Session Unit Tests""" |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 126 | error = self.vapi.cli("test session all") |
| 127 | |
| 128 | if error: |
| 129 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 130 | self.assertNotIn("failed", error) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 131 | |
| 132 | def tearDown(self): |
| 133 | super(TestSessionUnitTests, self).tearDown() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 134 | self.vapi.session_enable_disable(is_enable=0) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 135 | |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 136 | |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 137 | @tag_run_solo |
Filip Tehlar | f687986 | 2021-11-30 13:55:58 +0000 | [diff] [blame] | 138 | class TestSegmentManagerTests(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 139 | """SVM Fifo Unit Tests Case""" |
Filip Tehlar | f687986 | 2021-11-30 13:55:58 +0000 | [diff] [blame] | 140 | |
| 141 | @classmethod |
| 142 | def setUpClass(cls): |
| 143 | super(TestSegmentManagerTests, cls).setUpClass() |
| 144 | |
| 145 | @classmethod |
| 146 | def tearDownClass(cls): |
| 147 | super(TestSegmentManagerTests, cls).tearDownClass() |
| 148 | |
| 149 | def setUp(self): |
| 150 | super(TestSegmentManagerTests, self).setUp() |
| 151 | |
| 152 | def test_segment_manager(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 153 | """Segment manager Tests""" |
Filip Tehlar | f687986 | 2021-11-30 13:55:58 +0000 | [diff] [blame] | 154 | error = self.vapi.cli("test segment-manager all") |
| 155 | |
| 156 | if error: |
| 157 | self.logger.critical(error) |
| 158 | self.assertNotIn("failed", error) |
| 159 | |
| 160 | def tearDown(self): |
| 161 | super(TestSegmentManagerTests, self).tearDown() |
| 162 | |
| 163 | |
| 164 | @tag_run_solo |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 165 | class TestSvmFifoUnitTests(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 166 | """SVM Fifo Unit Tests Case""" |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 167 | |
| 168 | @classmethod |
| 169 | def setUpClass(cls): |
| 170 | super(TestSvmFifoUnitTests, cls).setUpClass() |
| 171 | |
| 172 | @classmethod |
| 173 | def tearDownClass(cls): |
| 174 | super(TestSvmFifoUnitTests, cls).tearDownClass() |
| 175 | |
| 176 | def setUp(self): |
| 177 | super(TestSvmFifoUnitTests, self).setUp() |
| 178 | |
| 179 | def test_svm_fifo(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 180 | """SVM Fifo Unit Tests""" |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 181 | error = self.vapi.cli("test svm fifo all") |
| 182 | |
| 183 | if error: |
| 184 | self.logger.critical(error) |
| 185 | self.assertNotIn("failed", error) |
| 186 | |
| 187 | def tearDown(self): |
| 188 | super(TestSvmFifoUnitTests, self).tearDown() |
| 189 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 190 | |
| 191 | if __name__ == "__main__": |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 192 | unittest.main(testRunner=VppTestRunner) |