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