blob: f7a38a473ab25814ca47ee3b419aaceb727d7391 [file] [log] [blame]
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +02001# 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 Kaplonski2e68c7a2021-04-23 14:00:35 +020013import netaddr
Rodolfo Alonso Hernandez0da38af2024-03-05 00:03:27 +000014from tempest.common import utils as tutils
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000015from tempest.lib import decorators
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020016
Chandan Kumar667d3d32017-09-22 12:24:06 +053017from neutron_tempest_plugin.api import base
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020018
19
20class SubnetsSearchCriteriaTest(base.BaseSearchCriteriaTest):
21
22 resource = 'subnet'
23
24 list_kwargs = {'shared': False}
25
26 @classmethod
27 def resource_setup(cls):
Rodolfo Alonso Hernandez0da38af2024-03-05 00:03:27 +000028 if tutils.is_extension_enabled('subnet-external-network', 'network'):
29 cls.list_kwargs['router:external'] = False
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020030 super(SubnetsSearchCriteriaTest, cls).resource_setup()
31 net = cls.create_network(network_name='subnet-search-test-net')
32 for name in cls.resource_names:
33 cls.create_subnet(net, name=name)
34
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000035 @decorators.idempotent_id('d2d61995-5dd5-4b93-bce7-3edefdb79563')
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020036 def test_list_sorts_asc(self):
37 self._test_list_sorts_asc()
38
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000039 @decorators.idempotent_id('c3c6b0af-c4ac-4da0-b568-8d08ae550604')
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020040 def test_list_sorts_desc(self):
41 self._test_list_sorts_desc()
42
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000043 @decorators.idempotent_id('b93063b3-f713-406e-bf93-e5738e09153c')
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020044 def test_list_pagination(self):
45 self._test_list_pagination()
46
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000047 @decorators.idempotent_id('2ddd9aa6-de28-410f-9cbc-ce752893c407')
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020048 def test_list_pagination_with_marker(self):
49 self._test_list_pagination_with_marker()
50
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000051 @decorators.idempotent_id('351183ef-6ed9-4d71-a9f2-a5ac049bd7ea')
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020052 def test_list_pagination_with_href_links(self):
53 self._test_list_pagination_with_href_links()
54
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000055 @decorators.idempotent_id('dfaa20ca-6d84-4f26-962f-2fee4d247cd9')
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020056 def test_list_pagination_page_reverse_asc(self):
57 self._test_list_pagination_page_reverse_asc()
58
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000059 @decorators.idempotent_id('40552213-3e12-4d6a-86f3-dda92f3de88c')
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020060 def test_list_pagination_page_reverse_desc(self):
61 self._test_list_pagination_page_reverse_desc()
62
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000063 @decorators.idempotent_id('3cea9053-a731-4480-93ee-19b2c28a9ce4')
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020064 def test_list_pagination_page_reverse_with_href_links(self):
65 self._test_list_pagination_page_reverse_with_href_links()
66
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000067 @decorators.idempotent_id('d851937c-9821-4b46-9d18-43e9077ecac0')
Ihar Hrachyshka3cf4e7f2016-06-14 11:40:19 +020068 def test_list_no_pagination_limit_0(self):
69 self._test_list_no_pagination_limit_0()
Victor Morales1be97b42016-09-05 08:50:06 -050070
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000071 @decorators.idempotent_id('c0f9280b-9d81-4728-a967-6be22659d4c8')
Victor Morales1be97b42016-09-05 08:50:06 -050072 def test_list_validation_filters(self):
Hongbin Lu54f55922018-07-12 19:05:39 +000073 self._test_list_validation_filters(self.list_kwargs)
74 self._test_list_validation_filters({
75 'unknown_filter': 'value'}, filter_is_valid=False)
Slawek Kaplonski2e68c7a2021-04-23 14:00:35 +020076
77
78class SubnetServiceTypeTestJSON(base.BaseNetworkTest):
79
Slawek Kaplonskia5cdede2021-06-23 09:37:04 +020080 required_extensions = ['subnet-service-types']
Slawek Kaplonski2e68c7a2021-04-23 14:00:35 +020081
82 @classmethod
83 def resource_setup(cls):
84 super(SubnetServiceTypeTestJSON, cls).resource_setup()
85 cls.network = cls.create_network()
86
87 @decorators.idempotent_id('7e0edb66-1bb2-4473-ab83-d039cddced0d')
88 def test_allocate_ips_are_from_correct_subnet(self):
89 cidr_1 = netaddr.IPNetwork('192.168.1.0/24')
90 cidr_2 = netaddr.IPNetwork('192.168.2.0/24')
91
Slawek Kaplonski9115c8e2021-07-06 13:50:17 +020092 # NOTE(slaweq): service_type "network:distributed" is needed for
93 # ML2/OVN backend. It's needed because OVN driver creates additional
94 # port for metadata service in each subnet with enabled dhcp and such
95 # port needs to have allocated IP address from the subnet also.
96 self.create_subnet(
97 self.network,
98 service_types=['test:type_1', 'network:distributed'],
99 cidr=str(cidr_1))
100 self.create_subnet(
101 self.network,
102 service_types=['test:type_2', 'network:distributed'],
103 cidr=str(cidr_2))
Slawek Kaplonski2e68c7a2021-04-23 14:00:35 +0200104 port_type_1 = self.create_port(self.network,
105 device_owner="test:type_1")
106 port_type_2 = self.create_port(self.network,
107 device_owner="test:type_2")
108
109 self.assertEqual(1, len(port_type_1['fixed_ips']))
110 self.assertEqual(1, len(port_type_2['fixed_ips']))
111 self.assertIn(
112 netaddr.IPAddress(port_type_1['fixed_ips'][0]['ip_address']),
113 cidr_1)
114 self.assertIn(
115 netaddr.IPAddress(port_type_2['fixed_ips'][0]['ip_address']),
116 cidr_2)