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