Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | # not use this file except in compliance with the License. You may obtain |
| 3 | # a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | # License for the specific language governing permissions and limitations |
| 11 | # under the License. |
| 12 | |
Slawek Kaplonski | 2e68c7a | 2021-04-23 14:00:35 +0200 | [diff] [blame] | 13 | import netaddr |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 14 | from tempest.lib import decorators |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 15 | |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 16 | from neutron_tempest_plugin.api import base |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 17 | |
| 18 | |
| 19 | class SubnetsSearchCriteriaTest(base.BaseSearchCriteriaTest): |
| 20 | |
| 21 | resource = 'subnet' |
| 22 | |
| 23 | list_kwargs = {'shared': False} |
| 24 | |
| 25 | @classmethod |
| 26 | def resource_setup(cls): |
| 27 | super(SubnetsSearchCriteriaTest, cls).resource_setup() |
| 28 | net = cls.create_network(network_name='subnet-search-test-net') |
| 29 | for name in cls.resource_names: |
| 30 | cls.create_subnet(net, name=name) |
| 31 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 32 | @decorators.idempotent_id('d2d61995-5dd5-4b93-bce7-3edefdb79563') |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 33 | def test_list_sorts_asc(self): |
| 34 | self._test_list_sorts_asc() |
| 35 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 36 | @decorators.idempotent_id('c3c6b0af-c4ac-4da0-b568-8d08ae550604') |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 37 | def test_list_sorts_desc(self): |
| 38 | self._test_list_sorts_desc() |
| 39 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 40 | @decorators.idempotent_id('b93063b3-f713-406e-bf93-e5738e09153c') |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 41 | def test_list_pagination(self): |
| 42 | self._test_list_pagination() |
| 43 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 44 | @decorators.idempotent_id('2ddd9aa6-de28-410f-9cbc-ce752893c407') |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 45 | def test_list_pagination_with_marker(self): |
| 46 | self._test_list_pagination_with_marker() |
| 47 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 48 | @decorators.idempotent_id('351183ef-6ed9-4d71-a9f2-a5ac049bd7ea') |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 49 | def test_list_pagination_with_href_links(self): |
| 50 | self._test_list_pagination_with_href_links() |
| 51 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 52 | @decorators.idempotent_id('dfaa20ca-6d84-4f26-962f-2fee4d247cd9') |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 53 | def test_list_pagination_page_reverse_asc(self): |
| 54 | self._test_list_pagination_page_reverse_asc() |
| 55 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 56 | @decorators.idempotent_id('40552213-3e12-4d6a-86f3-dda92f3de88c') |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 57 | def test_list_pagination_page_reverse_desc(self): |
| 58 | self._test_list_pagination_page_reverse_desc() |
| 59 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 60 | @decorators.idempotent_id('3cea9053-a731-4480-93ee-19b2c28a9ce4') |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 61 | def test_list_pagination_page_reverse_with_href_links(self): |
| 62 | self._test_list_pagination_page_reverse_with_href_links() |
| 63 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 64 | @decorators.idempotent_id('d851937c-9821-4b46-9d18-43e9077ecac0') |
Ihar Hrachyshka | 3cf4e7f | 2016-06-14 11:40:19 +0200 | [diff] [blame] | 65 | def test_list_no_pagination_limit_0(self): |
| 66 | self._test_list_no_pagination_limit_0() |
Victor Morales | 1be97b4 | 2016-09-05 08:50:06 -0500 | [diff] [blame] | 67 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 68 | @decorators.idempotent_id('c0f9280b-9d81-4728-a967-6be22659d4c8') |
Victor Morales | 1be97b4 | 2016-09-05 08:50:06 -0500 | [diff] [blame] | 69 | def test_list_validation_filters(self): |
Hongbin Lu | 54f5592 | 2018-07-12 19:05:39 +0000 | [diff] [blame] | 70 | self._test_list_validation_filters(self.list_kwargs) |
| 71 | self._test_list_validation_filters({ |
| 72 | 'unknown_filter': 'value'}, filter_is_valid=False) |
Slawek Kaplonski | 2e68c7a | 2021-04-23 14:00:35 +0200 | [diff] [blame] | 73 | |
| 74 | |
| 75 | class SubnetServiceTypeTestJSON(base.BaseNetworkTest): |
| 76 | |
Slawek Kaplonski | a5cdede | 2021-06-23 09:37:04 +0200 | [diff] [blame^] | 77 | required_extensions = ['subnet-service-types'] |
Slawek Kaplonski | 2e68c7a | 2021-04-23 14:00:35 +0200 | [diff] [blame] | 78 | |
| 79 | @classmethod |
| 80 | def resource_setup(cls): |
| 81 | super(SubnetServiceTypeTestJSON, cls).resource_setup() |
| 82 | cls.network = cls.create_network() |
| 83 | |
| 84 | @decorators.idempotent_id('7e0edb66-1bb2-4473-ab83-d039cddced0d') |
| 85 | def test_allocate_ips_are_from_correct_subnet(self): |
| 86 | cidr_1 = netaddr.IPNetwork('192.168.1.0/24') |
| 87 | cidr_2 = netaddr.IPNetwork('192.168.2.0/24') |
| 88 | |
| 89 | self.create_subnet(self.network, |
| 90 | service_types=['test:type_1'], |
| 91 | cidr=str(cidr_1)) |
| 92 | self.create_subnet(self.network, |
| 93 | service_types=['test:type_2'], |
| 94 | cidr=str(cidr_2)) |
| 95 | port_type_1 = self.create_port(self.network, |
| 96 | device_owner="test:type_1") |
| 97 | port_type_2 = self.create_port(self.network, |
| 98 | device_owner="test:type_2") |
| 99 | |
| 100 | self.assertEqual(1, len(port_type_1['fixed_ips'])) |
| 101 | self.assertEqual(1, len(port_type_2['fixed_ips'])) |
| 102 | self.assertIn( |
| 103 | netaddr.IPAddress(port_type_1['fixed_ips'][0]['ip_address']), |
| 104 | cidr_1) |
| 105 | self.assertIn( |
| 106 | netaddr.IPAddress(port_type_2['fixed_ips'][0]['ip_address']), |
| 107 | cidr_2) |