blob: c39c52368a919ecbeb7c7699d0b7ad27510aa642 [file] [log] [blame]
Daniel Mellado3c0aeab2016-01-29 11:30:25 +00001# 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
13import copy
Federico Ressie570de62018-10-10 15:33:55 +020014import time
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000015
Federico Ressie570de62018-10-10 15:33:55 +020016from neutron_lib import constants
Hongbin Lu7681a5c2018-04-18 15:54:45 +000017from tempest.common import utils
Gleb Zimin7e1a8582023-11-20 13:26:48 +010018from tempest import config as tempestconf
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000019from tempest.lib.common.utils import data_utils
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000020from tempest.lib import decorators
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000021
Chandan Kumar667d3d32017-09-22 12:24:06 +053022from neutron_tempest_plugin.api import base
23from neutron_tempest_plugin.api import base_routers
Chandan Kumar667d3d32017-09-22 12:24:06 +053024from neutron_tempest_plugin import config
ZhaoBof5620692016-05-05 17:16:23 +080025
26CONF = config.CONF
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000027
28
29class TestTimeStamp(base.BaseAdminNetworkTest):
30
Jakub Libosvar1982aa12017-05-30 11:15:33 +000031 required_extensions = ["standard-attr-timestamp"]
32
Brian Haley6767cec2018-04-10 15:30:23 -040033 # attributes for subnetpool
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000034 min_prefixlen = '28'
35 max_prefixlen = '31'
36 _ip_version = 4
37 subnet_cidr = '10.11.12.0/31'
38 new_prefix = '10.11.15.0/24'
39 larger_prefix = '10.11.0.0/16'
40
41 @classmethod
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000042 def resource_setup(cls):
43 super(TestTimeStamp, cls).resource_setup()
44 prefixes = ['10.11.12.0/24']
45 cls._subnetpool_data = {'min_prefixlen': '29', 'prefixes': prefixes}
46
47 def _create_subnetpool(self, is_admin=False, **kwargs):
Chandan Kumarc125fd12017-11-15 19:41:01 +053048 name = data_utils.rand_name('subnetpool')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000049 subnetpool_data = copy.deepcopy(self._subnetpool_data)
50 for key in subnetpool_data.keys():
51 kwargs[key] = subnetpool_data[key]
52 return self.create_subnetpool(name=name, is_admin=is_admin, **kwargs)
53
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000054 @decorators.idempotent_id('462be770-b310-4df9-9c42-773217e4c8b1')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000055 def test_create_network_with_timestamp(self):
56 network = self.create_network()
57 # Verifies body contains timestamp fields
58 self.assertIsNotNone(network['created_at'])
59 self.assertIsNotNone(network['updated_at'])
60
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000061 @decorators.idempotent_id('4db5417a-e11c-474d-a361-af00ebef57c5')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000062 def test_update_network_with_timestamp(self):
63 network = self.create_network()
64 origin_updated_at = network['updated_at']
65 update_body = {'name': network['name'] + 'new'}
66 body = self.admin_client.update_network(network['id'],
67 **update_body)
68 updated_network = body['network']
69 new_updated_at = updated_network['updated_at']
70 self.assertEqual(network['created_at'], updated_network['created_at'])
71 # Verify that origin_updated_at is not same with new_updated_at
72 self.assertIsNot(origin_updated_at, new_updated_at)
73
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000074 @decorators.idempotent_id('2ac50ab2-7ebd-4e27-b3ce-a9e399faaea2')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000075 def test_show_networks_attribute_with_timestamp(self):
76 network = self.create_network()
77 body = self.client.show_network(network['id'])
78 show_net = body['network']
79 # verify the timestamp from creation and showed is same
80 self.assertEqual(network['created_at'],
81 show_net['created_at'])
82 self.assertEqual(network['updated_at'],
83 show_net['updated_at'])
84
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000085 @decorators.idempotent_id('8ee55186-454f-4b97-9f9f-eb2772ee891c')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000086 def test_create_subnet_with_timestamp(self):
87 network = self.create_network()
88 subnet = self.create_subnet(network)
89 # Verifies body contains timestamp fields
90 self.assertIsNotNone(subnet['created_at'])
91 self.assertIsNotNone(subnet['updated_at'])
92
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000093 @decorators.idempotent_id('a490215a-6f4c-4af9-9a4c-57c41f1c4fa1')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000094 def test_update_subnet_with_timestamp(self):
95 network = self.create_network()
96 subnet = self.create_subnet(network)
97 origin_updated_at = subnet['updated_at']
98 update_body = {'name': subnet['name'] + 'new'}
99 body = self.admin_client.update_subnet(subnet['id'],
100 **update_body)
101 updated_subnet = body['subnet']
102 new_updated_at = updated_subnet['updated_at']
103 self.assertEqual(subnet['created_at'], updated_subnet['created_at'])
104 # Verify that origin_updated_at is not same with new_updated_at
105 self.assertIsNot(origin_updated_at, new_updated_at)
106
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000107 @decorators.idempotent_id('1836a086-e7cf-4141-bf57-0cfe79e8051e')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000108 def test_show_subnet_attribute_with_timestamp(self):
109 network = self.create_network()
110 subnet = self.create_subnet(network)
111 body = self.client.show_subnet(subnet['id'])
112 show_subnet = body['subnet']
113 # verify the timestamp from creation and showed is same
114 self.assertEqual(subnet['created_at'],
115 show_subnet['created_at'])
116 self.assertEqual(subnet['updated_at'],
117 show_subnet['updated_at'])
118
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000119 @decorators.idempotent_id('e2450a7b-d84f-4600-a093-45e78597bbac')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000120 def test_create_port_with_timestamp(self):
121 network = self.create_network()
122 port = self.create_port(network)
123 # Verifies body contains timestamp fields
124 self.assertIsNotNone(port['created_at'])
125 self.assertIsNotNone(port['updated_at'])
126
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000127 @decorators.idempotent_id('4241e0d3-54b4-46ce-a9a7-093fc764161b')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000128 def test_update_port_with_timestamp(self):
129 network = self.create_network()
130 port = self.create_port(network)
131 origin_updated_at = port['updated_at']
132 update_body = {'name': port['name'] + 'new'}
133 body = self.admin_client.update_port(port['id'],
134 **update_body)
135 updated_port = body['port']
136 new_updated_at = updated_port['updated_at']
137 self.assertEqual(port['created_at'], updated_port['created_at'])
138 # Verify that origin_updated_at is not same with new_updated_at
139 self.assertIsNot(origin_updated_at, new_updated_at)
140
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000141 @decorators.idempotent_id('584c6723-40b6-4f26-81dd-f508f9d9fb51')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000142 def test_show_port_attribute_with_timestamp(self):
143 network = self.create_network()
144 port = self.create_port(network)
145 body = self.client.show_port(port['id'])
146 show_port = body['port']
147 # verify the timestamp from creation and showed is same
148 self.assertEqual(port['created_at'],
149 show_port['created_at'])
150 self.assertEqual(port['updated_at'],
151 show_port['updated_at'])
152
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000153 @decorators.idempotent_id('87a8b196-4b90-44f0-b7f3-d2057d7d658e')
Ilya Menkov327ec3a2020-05-22 15:16:32 +0400154 @utils.requires_ext(extension='default-subnetpools', service='network')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000155 def test_create_subnetpool_with_timestamp(self):
156 sp = self._create_subnetpool()
157 # Verifies body contains timestamp fields
158 self.assertIsNotNone(sp['created_at'])
159 self.assertIsNotNone(sp['updated_at'])
160
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000161 @decorators.idempotent_id('d48c7578-c3d2-4f9b-a7a1-be2008c770a0')
Ilya Menkov327ec3a2020-05-22 15:16:32 +0400162 @utils.requires_ext(extension='default-subnetpools', service='network')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000163 def test_update_subnetpool_with_timestamp(self):
164 sp = self._create_subnetpool()
165 origin_updated_at = sp['updated_at']
166 update_body = {'name': sp['name'] + 'new',
167 'min_prefixlen': self.min_prefixlen,
168 'max_prefixlen': self.max_prefixlen}
169 body = self.client.update_subnetpool(sp['id'], **update_body)
170 updated_sp = body['subnetpool']
171 new_updated_at = updated_sp['updated_at']
172 self.assertEqual(sp['created_at'], updated_sp['created_at'])
173 # Verify that origin_updated_at is not same with new_updated_at
174 self.assertIsNot(origin_updated_at, new_updated_at)
175
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000176 @decorators.idempotent_id('1d3970e6-bcf7-46cd-b7d7-0807759c73b4')
Ilya Menkov327ec3a2020-05-22 15:16:32 +0400177 @utils.requires_ext(extension='default-subnetpools', service='network')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000178 def test_show_subnetpool_attribute_with_timestamp(self):
179 sp = self._create_subnetpool()
180 body = self.client.show_subnetpool(sp['id'])
181 show_sp = body['subnetpool']
182 # verify the timestamp from creation and showed is same
183 self.assertEqual(sp['created_at'], show_sp['created_at'])
184 self.assertEqual(sp['updated_at'], show_sp['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800185
Hongbin Lu840c03c2018-04-03 19:34:58 +0000186 @decorators.idempotent_id('396a97dc-b66c-4c46-9171-c39eefe6936c')
Hongbin Lu7681a5c2018-04-18 15:54:45 +0000187 @utils.requires_ext(extension="standard-attr-segment", service="network")
Hongbin Lu840c03c2018-04-03 19:34:58 +0000188 def test_segment_with_timestamp(self):
189 network = self.create_network()
190 segment = self.admin_client.list_segments(
191 network_id=network['id'])['segments'][0]
192 # Verifies body contains timestamp fields
193 self.assertIsNotNone(segment['created_at'])
194 self.assertIsNotNone(segment['updated_at'])
195
196 body = self.admin_client.show_segment(segment['id'])
197 show_segment = body['segment']
198 # verify the timestamp from creation and showed is same
199 self.assertEqual(segment['created_at'], show_segment['created_at'])
200 self.assertEqual(segment['updated_at'], show_segment['updated_at'])
201
202 origin_updated_at = segment['updated_at']
203 update_body = {'name': str(segment['name']) + 'new'}
204 body = self.admin_client.update_segment(segment['id'], **update_body)
205 updated_segment = body['segment']
206 new_updated_at = updated_segment['updated_at']
207 self.assertEqual(segment['created_at'], updated_segment['created_at'])
208 # Verify that origin_updated_at is not same with new_updated_at
209 self.assertIsNot(origin_updated_at, new_updated_at)
210
ZhaoBof5620692016-05-05 17:16:23 +0800211
212class TestTimeStampWithL3(base_routers.BaseRouterTest):
ZhaoBof5620692016-05-05 17:16:23 +0800213
Jakub Libosvar1982aa12017-05-30 11:15:33 +0000214 required_extensions = ['standard-attr-timestamp']
ZhaoBof5620692016-05-05 17:16:23 +0800215
216 @classmethod
217 def resource_setup(cls):
218 super(TestTimeStampWithL3, cls).resource_setup()
219 cls.ext_net_id = CONF.network.public_network_id
220
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000221 @decorators.idempotent_id('433ba770-b310-4da9-5d42-733217a1c7b1')
ZhaoBof5620692016-05-05 17:16:23 +0800222 def test_create_router_with_timestamp(self):
223 router = self.create_router(router_name='test')
224 # Verifies body contains timestamp fields
225 self.assertIsNotNone(router['created_at'])
226 self.assertIsNotNone(router['updated_at'])
227
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000228 @decorators.idempotent_id('4a65417a-c11c-4b4d-a351-af01abcf57c6')
ZhaoBof5620692016-05-05 17:16:23 +0800229 def test_update_router_with_timestamp(self):
230 router = self.create_router(router_name='test')
231 origin_updated_at = router['updated_at']
232 update_body = {'name': router['name'] + 'new'}
233 body = self.client.update_router(router['id'], **update_body)
234 updated_router = body['router']
235 new_updated_at = updated_router['updated_at']
236 self.assertEqual(router['created_at'], updated_router['created_at'])
237 # Verify that origin_updated_at is not same with new_updated_at
238 self.assertIsNot(origin_updated_at, new_updated_at)
239
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000240 @decorators.idempotent_id('1ab50ac2-7cbd-4a17-b23e-a9e36cfa4ec2')
ZhaoBof5620692016-05-05 17:16:23 +0800241 def test_show_router_attribute_with_timestamp(self):
242 router = self.create_router(router_name='test')
243 body = self.client.show_router(router['id'])
244 show_router = body['router']
245 # verify the timestamp from creation and showed is same
246 self.assertEqual(router['created_at'],
247 show_router['created_at'])
Brian Haley060f8032017-04-04 14:10:12 -0400248 # 'updated_at' timestamp can change immediately after creation
249 # if environment is HA or DVR, so just make sure it's >=
250 self.assertGreaterEqual(show_router['updated_at'],
251 router['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800252
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000253 @decorators.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac')
ZhaoBof5620692016-05-05 17:16:23 +0800254 def test_create_floatingip_with_timestamp(self):
Federico Ressi3dfa94c2018-07-06 09:46:39 +0200255 fip = self.create_floatingip()
ZhaoBof5620692016-05-05 17:16:23 +0800256 # Verifies body contains timestamp fields
257 self.assertIsNotNone(fip['created_at'])
258 self.assertIsNotNone(fip['updated_at'])
259
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000260 @decorators.idempotent_id('a3ac215a-61ac-13f9-9d3c-57c51f11afa1')
ZhaoBof5620692016-05-05 17:16:23 +0800261 def test_update_floatingip_with_timestamp(self):
Federico Ressi3dfa94c2018-07-06 09:46:39 +0200262 fip = self.create_floatingip()
ZhaoBof5620692016-05-05 17:16:23 +0800263 origin_updated_at = fip['updated_at']
264 update_body = {'description': 'new'}
265 body = self.client.update_floatingip(fip['id'], **update_body)
266 updated_fip = body['floatingip']
267 new_updated_at = updated_fip['updated_at']
268 self.assertEqual(fip['created_at'], updated_fip['created_at'])
269 # Verify that origin_updated_at is not same with new_updated_at
270 self.assertIsNot(origin_updated_at, new_updated_at)
271
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000272 @decorators.idempotent_id('32a6a086-e1ef-413b-b13a-0cfe13ef051e')
ZhaoBof5620692016-05-05 17:16:23 +0800273 def test_show_floatingip_attribute_with_timestamp(self):
Federico Ressi3dfa94c2018-07-06 09:46:39 +0200274 fip = self.create_floatingip()
ZhaoBof5620692016-05-05 17:16:23 +0800275 body = self.client.show_floatingip(fip['id'])
276 show_fip = body['floatingip']
277 # verify the timestamp from creation and showed is same
278 self.assertEqual(fip['created_at'],
279 show_fip['created_at'])
280 self.assertEqual(fip['updated_at'],
281 show_fip['updated_at'])
282
283
Federico Ressie570de62018-10-10 15:33:55 +0200284class TestTimeStampWithSecurityGroup(base.BaseNetworkTest):
ZhaoBof5620692016-05-05 17:16:23 +0800285
Jakub Libosvar1982aa12017-05-30 11:15:33 +0000286 required_extensions = ['standard-attr-timestamp']
ZhaoBof5620692016-05-05 17:16:23 +0800287
288 @classmethod
289 def resource_setup(cls):
290 super(TestTimeStampWithSecurityGroup, cls).resource_setup()
291 cls.ext_net_id = CONF.network.public_network_id
292
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000293 @decorators.idempotent_id('a3150a7b-d31a-423a-abf3-45e71c97cbac')
ZhaoBof5620692016-05-05 17:16:23 +0800294 def test_create_sg_with_timestamp(self):
Federico Ressie570de62018-10-10 15:33:55 +0200295 security_group = self.create_security_group()
ZhaoBof5620692016-05-05 17:16:23 +0800296 # Verifies body contains timestamp fields
Federico Ressie570de62018-10-10 15:33:55 +0200297 self.assertIsNotNone(security_group['created_at'])
298 self.assertIsNotNone(security_group['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800299
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000300 @decorators.idempotent_id('432ae0d3-32b4-413e-a9b3-091ac76da31b')
ZhaoBof5620692016-05-05 17:16:23 +0800301 def test_update_sg_with_timestamp(self):
Federico Ressie570de62018-10-10 15:33:55 +0200302 security_group = self.create_security_group()
303
304 # Make sure update time will be different
305 time.sleep(2.)
306 updated_security_group = self.client.update_security_group(
307 security_group['id'], name=security_group['name'] + 'new')[
308 'security_group']
ibumarskovd1267dd2020-10-16 13:34:32 +0400309 # Workaround for PRODX-7986
Gleb Zimin7e1a8582023-11-20 13:26:48 +0100310 if tempestconf.is_tungstenfabric_backend_enabled():
ibumarskovd1267dd2020-10-16 13:34:32 +0400311 updated_security_group = self.client.show_security_group(
312 security_group['id'])['security_group']
Federico Ressie570de62018-10-10 15:33:55 +0200313
314 # Verify that created_at hasn't changed
315 self.assertEqual(security_group['created_at'],
316 updated_security_group['created_at'])
317 # Verify that updated_at has changed
318 self.assertNotEqual(security_group['updated_at'],
319 updated_security_group['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800320
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000321 @decorators.idempotent_id('521e6723-43d6-12a6-8c3d-f5042ad9fc32')
ZhaoBof5620692016-05-05 17:16:23 +0800322 def test_show_sg_attribute_with_timestamp(self):
Federico Ressie570de62018-10-10 15:33:55 +0200323 security_group = self.create_security_group()
324 observed_security_group = self.client.show_security_group(
325 security_group['id'])['security_group']
ZhaoBof5620692016-05-05 17:16:23 +0800326
Federico Ressie570de62018-10-10 15:33:55 +0200327 # Verify that created_at hasn't changed
328 self.assertEqual(security_group['created_at'],
329 observed_security_group['created_at'])
330 # Verify that updated_at hasn't changed
331 self.assertEqual(security_group['updated_at'],
332 observed_security_group['updated_at'])
333
334 def _create_security_group_rule(self):
335 security_group = self.create_security_group()
336 return self.create_security_group_rule(
337 security_group=security_group,
338 direction=constants.INGRESS_DIRECTION,
339 protocol=constants.PROTO_NAME_TCP,
340 port_range_min=77,
341 port_range_max=77)
ZhaoBof5620692016-05-05 17:16:23 +0800342
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000343 @decorators.idempotent_id('83e8bd32-43e0-a3f0-1af3-12a5733c653e')
ZhaoBof5620692016-05-05 17:16:23 +0800344 def test_create_sgrule_with_timestamp(self):
Federico Ressie570de62018-10-10 15:33:55 +0200345 security_group_rule = self._create_security_group_rule()
ZhaoBof5620692016-05-05 17:16:23 +0800346 # Verifies body contains timestamp fields
Federico Ressie570de62018-10-10 15:33:55 +0200347 self.assertIn('created_at', security_group_rule)
348 self.assertIn('updated_at', security_group_rule)
ZhaoBof5620692016-05-05 17:16:23 +0800349
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000350 @decorators.idempotent_id('143da0e6-ba17-43ad-b3d7-03aa759c3cb4')
ZhaoBof5620692016-05-05 17:16:23 +0800351 def test_show_sgrule_attribute_with_timestamp(self):
Federico Ressie570de62018-10-10 15:33:55 +0200352 security_group_rule = self._create_security_group_rule()
353
354 observed_security_group_rule = self.client.show_security_group_rule(
355 security_group_rule['id'])['security_group_rule']
356
357 # Verify the time stamp from creation and showed are equal
358 self.assertEqual(security_group_rule['created_at'],
359 observed_security_group_rule['created_at'])
360 self.assertEqual(security_group_rule['updated_at'],
361 observed_security_group_rule['updated_at'])