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): |
| 13 | """ Session Test Case """ |
| 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 |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 43 | self.vapi.app_namespace_add_del(namespace_id="0", |
Ole Troan | e1ade68 | 2019-03-04 23:55:43 +0100 | [diff] [blame] | 44 | sw_if_index=self.loop0.sw_if_index) |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 45 | self.vapi.app_namespace_add_del(namespace_id="1", |
Ole Troan | e1ade68 | 2019-03-04 23:55:43 +0100 | [diff] [blame] | 46 | sw_if_index=self.loop1.sw_if_index) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 47 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 48 | def tearDown(self): |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 49 | for i in self.lo_interfaces: |
| 50 | i.unconfig_ip4() |
| 51 | i.set_table_ip4(0) |
| 52 | i.admin_down() |
| 53 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 54 | super(TestSession, self).tearDown() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 55 | self.vapi.session_enable_disable(is_enable=1) |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 56 | |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 57 | def test_segment_manager_alloc(self): |
| 58 | """ Session Segment Manager Multiple Segment Allocation """ |
| 59 | |
| 60 | # Add inter-table routes |
| 61 | ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32, |
| 62 | [VppRoutePath("0.0.0.0", |
| 63 | 0xffffffff, |
| 64 | nh_table_id=1)]) |
| 65 | ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32, |
| 66 | [VppRoutePath("0.0.0.0", |
| 67 | 0xffffffff, |
| 68 | nh_table_id=0)], table_id=1) |
| 69 | ip_t01.add_vpp_config() |
| 70 | ip_t10.add_vpp_config() |
| 71 | |
| 72 | # Start builtin server and client with small private segments |
| 73 | uri = "tcp://" + self.loop0.local_ip4 + "/1234" |
| 74 | error = self.vapi.cli("test echo server appns 0 fifo-size 64 " + |
| 75 | "private-segment-size 1m uri " + uri) |
| 76 | if error: |
| 77 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 78 | self.assertNotIn("failed", error) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 79 | |
| 80 | error = self.vapi.cli("test echo client nclients 100 appns 1 " + |
| 81 | "no-output fifo-size 64 syn-timeout 2 " + |
| 82 | "private-segment-size 1m uri " + uri) |
| 83 | if error: |
| 84 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 85 | self.assertNotIn("failed", error) |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 86 | |
Florin Coras | f8f516a | 2018-02-08 15:10:09 -0800 | [diff] [blame] | 87 | if self.vpp_dead: |
| 88 | self.assert_equal(0) |
| 89 | |
Florin Coras | a332c46 | 2018-01-31 06:52:17 -0800 | [diff] [blame] | 90 | # Delete inter-table routes |
| 91 | ip_t01.remove_vpp_config() |
| 92 | ip_t10.remove_vpp_config() |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 93 | |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 94 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame^] | 95 | @tag_fixme_vpp_workers |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 96 | class TestSessionUnitTests(VppTestCase): |
| 97 | """ Session Unit Tests Case """ |
| 98 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 99 | @classmethod |
| 100 | def setUpClass(cls): |
| 101 | super(TestSessionUnitTests, cls).setUpClass() |
| 102 | |
| 103 | @classmethod |
| 104 | def tearDownClass(cls): |
| 105 | super(TestSessionUnitTests, cls).tearDownClass() |
| 106 | |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 107 | def setUp(self): |
| 108 | super(TestSessionUnitTests, self).setUp() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 109 | self.vapi.session_enable_disable(is_enable=1) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 110 | |
| 111 | def test_session(self): |
| 112 | """ Session Unit Tests """ |
| 113 | error = self.vapi.cli("test session all") |
| 114 | |
| 115 | if error: |
| 116 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 117 | self.assertNotIn("failed", error) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 118 | |
| 119 | def tearDown(self): |
| 120 | super(TestSessionUnitTests, self).tearDown() |
Jakub Grajciar | 6a2794e | 2020-11-24 11:22:01 +0100 | [diff] [blame] | 121 | self.vapi.session_enable_disable(is_enable=0) |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 122 | |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 123 | |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 124 | @tag_run_solo |
Florin Coras | f682fac | 2019-04-18 20:50:50 -0700 | [diff] [blame] | 125 | class TestSvmFifoUnitTests(VppTestCase): |
| 126 | """ SVM Fifo Unit Tests Case """ |
| 127 | |
| 128 | @classmethod |
| 129 | def setUpClass(cls): |
| 130 | super(TestSvmFifoUnitTests, cls).setUpClass() |
| 131 | |
| 132 | @classmethod |
| 133 | def tearDownClass(cls): |
| 134 | super(TestSvmFifoUnitTests, cls).tearDownClass() |
| 135 | |
| 136 | def setUp(self): |
| 137 | super(TestSvmFifoUnitTests, self).setUp() |
| 138 | |
| 139 | def test_svm_fifo(self): |
| 140 | """ SVM Fifo Unit Tests """ |
| 141 | error = self.vapi.cli("test svm fifo all") |
| 142 | |
| 143 | if error: |
| 144 | self.logger.critical(error) |
| 145 | self.assertNotIn("failed", error) |
| 146 | |
| 147 | def tearDown(self): |
| 148 | super(TestSvmFifoUnitTests, self).tearDown() |
| 149 | |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 150 | if __name__ == '__main__': |
| 151 | unittest.main(testRunner=VppTestRunner) |