blob: f5888f9729225aa1e9cc6f39472fa4a0b52d4b5c [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
14
Hongbin Lu7681a5c2018-04-18 15:54:45 +000015from tempest.common import utils
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000016from tempest.lib.common.utils import data_utils
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000017from tempest.lib import decorators
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000018
Chandan Kumar667d3d32017-09-22 12:24:06 +053019from neutron_tempest_plugin.api import base
20from neutron_tempest_plugin.api import base_routers
21from neutron_tempest_plugin.api import base_security_groups
22from neutron_tempest_plugin import config
ZhaoBof5620692016-05-05 17:16:23 +080023
24CONF = config.CONF
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000025
26
27class TestTimeStamp(base.BaseAdminNetworkTest):
28
Jakub Libosvar1982aa12017-05-30 11:15:33 +000029 required_extensions = ["standard-attr-timestamp"]
30
Brian Haley6767cec2018-04-10 15:30:23 -040031 # attributes for subnetpool
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000032 min_prefixlen = '28'
33 max_prefixlen = '31'
34 _ip_version = 4
35 subnet_cidr = '10.11.12.0/31'
36 new_prefix = '10.11.15.0/24'
37 larger_prefix = '10.11.0.0/16'
38
39 @classmethod
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000040 def resource_setup(cls):
41 super(TestTimeStamp, cls).resource_setup()
42 prefixes = ['10.11.12.0/24']
43 cls._subnetpool_data = {'min_prefixlen': '29', 'prefixes': prefixes}
44
45 def _create_subnetpool(self, is_admin=False, **kwargs):
Chandan Kumarc125fd12017-11-15 19:41:01 +053046 name = data_utils.rand_name('subnetpool')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000047 subnetpool_data = copy.deepcopy(self._subnetpool_data)
48 for key in subnetpool_data.keys():
49 kwargs[key] = subnetpool_data[key]
50 return self.create_subnetpool(name=name, is_admin=is_admin, **kwargs)
51
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000052 @decorators.idempotent_id('462be770-b310-4df9-9c42-773217e4c8b1')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000053 def test_create_network_with_timestamp(self):
54 network = self.create_network()
55 # Verifies body contains timestamp fields
56 self.assertIsNotNone(network['created_at'])
57 self.assertIsNotNone(network['updated_at'])
58
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000059 @decorators.idempotent_id('4db5417a-e11c-474d-a361-af00ebef57c5')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000060 def test_update_network_with_timestamp(self):
61 network = self.create_network()
62 origin_updated_at = network['updated_at']
63 update_body = {'name': network['name'] + 'new'}
64 body = self.admin_client.update_network(network['id'],
65 **update_body)
66 updated_network = body['network']
67 new_updated_at = updated_network['updated_at']
68 self.assertEqual(network['created_at'], updated_network['created_at'])
69 # Verify that origin_updated_at is not same with new_updated_at
70 self.assertIsNot(origin_updated_at, new_updated_at)
71
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000072 @decorators.idempotent_id('2ac50ab2-7ebd-4e27-b3ce-a9e399faaea2')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000073 def test_show_networks_attribute_with_timestamp(self):
74 network = self.create_network()
75 body = self.client.show_network(network['id'])
76 show_net = body['network']
77 # verify the timestamp from creation and showed is same
78 self.assertEqual(network['created_at'],
79 show_net['created_at'])
80 self.assertEqual(network['updated_at'],
81 show_net['updated_at'])
82
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000083 @decorators.idempotent_id('8ee55186-454f-4b97-9f9f-eb2772ee891c')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000084 def test_create_subnet_with_timestamp(self):
85 network = self.create_network()
86 subnet = self.create_subnet(network)
87 # Verifies body contains timestamp fields
88 self.assertIsNotNone(subnet['created_at'])
89 self.assertIsNotNone(subnet['updated_at'])
90
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000091 @decorators.idempotent_id('a490215a-6f4c-4af9-9a4c-57c41f1c4fa1')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000092 def test_update_subnet_with_timestamp(self):
93 network = self.create_network()
94 subnet = self.create_subnet(network)
95 origin_updated_at = subnet['updated_at']
96 update_body = {'name': subnet['name'] + 'new'}
97 body = self.admin_client.update_subnet(subnet['id'],
98 **update_body)
99 updated_subnet = body['subnet']
100 new_updated_at = updated_subnet['updated_at']
101 self.assertEqual(subnet['created_at'], updated_subnet['created_at'])
102 # Verify that origin_updated_at is not same with new_updated_at
103 self.assertIsNot(origin_updated_at, new_updated_at)
104
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000105 @decorators.idempotent_id('1836a086-e7cf-4141-bf57-0cfe79e8051e')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000106 def test_show_subnet_attribute_with_timestamp(self):
107 network = self.create_network()
108 subnet = self.create_subnet(network)
109 body = self.client.show_subnet(subnet['id'])
110 show_subnet = body['subnet']
111 # verify the timestamp from creation and showed is same
112 self.assertEqual(subnet['created_at'],
113 show_subnet['created_at'])
114 self.assertEqual(subnet['updated_at'],
115 show_subnet['updated_at'])
116
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000117 @decorators.idempotent_id('e2450a7b-d84f-4600-a093-45e78597bbac')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000118 def test_create_port_with_timestamp(self):
119 network = self.create_network()
120 port = self.create_port(network)
121 # Verifies body contains timestamp fields
122 self.assertIsNotNone(port['created_at'])
123 self.assertIsNotNone(port['updated_at'])
124
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000125 @decorators.idempotent_id('4241e0d3-54b4-46ce-a9a7-093fc764161b')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000126 def test_update_port_with_timestamp(self):
127 network = self.create_network()
128 port = self.create_port(network)
129 origin_updated_at = port['updated_at']
130 update_body = {'name': port['name'] + 'new'}
131 body = self.admin_client.update_port(port['id'],
132 **update_body)
133 updated_port = body['port']
134 new_updated_at = updated_port['updated_at']
135 self.assertEqual(port['created_at'], updated_port['created_at'])
136 # Verify that origin_updated_at is not same with new_updated_at
137 self.assertIsNot(origin_updated_at, new_updated_at)
138
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000139 @decorators.idempotent_id('584c6723-40b6-4f26-81dd-f508f9d9fb51')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000140 def test_show_port_attribute_with_timestamp(self):
141 network = self.create_network()
142 port = self.create_port(network)
143 body = self.client.show_port(port['id'])
144 show_port = body['port']
145 # verify the timestamp from creation and showed is same
146 self.assertEqual(port['created_at'],
147 show_port['created_at'])
148 self.assertEqual(port['updated_at'],
149 show_port['updated_at'])
150
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000151 @decorators.idempotent_id('87a8b196-4b90-44f0-b7f3-d2057d7d658e')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000152 def test_create_subnetpool_with_timestamp(self):
153 sp = self._create_subnetpool()
154 # Verifies body contains timestamp fields
155 self.assertIsNotNone(sp['created_at'])
156 self.assertIsNotNone(sp['updated_at'])
157
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000158 @decorators.idempotent_id('d48c7578-c3d2-4f9b-a7a1-be2008c770a0')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000159 def test_update_subnetpool_with_timestamp(self):
160 sp = self._create_subnetpool()
161 origin_updated_at = sp['updated_at']
162 update_body = {'name': sp['name'] + 'new',
163 'min_prefixlen': self.min_prefixlen,
164 'max_prefixlen': self.max_prefixlen}
165 body = self.client.update_subnetpool(sp['id'], **update_body)
166 updated_sp = body['subnetpool']
167 new_updated_at = updated_sp['updated_at']
168 self.assertEqual(sp['created_at'], updated_sp['created_at'])
169 # Verify that origin_updated_at is not same with new_updated_at
170 self.assertIsNot(origin_updated_at, new_updated_at)
171
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000172 @decorators.idempotent_id('1d3970e6-bcf7-46cd-b7d7-0807759c73b4')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000173 def test_show_subnetpool_attribute_with_timestamp(self):
174 sp = self._create_subnetpool()
175 body = self.client.show_subnetpool(sp['id'])
176 show_sp = body['subnetpool']
177 # verify the timestamp from creation and showed is same
178 self.assertEqual(sp['created_at'], show_sp['created_at'])
179 self.assertEqual(sp['updated_at'], show_sp['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800180
Hongbin Lu840c03c2018-04-03 19:34:58 +0000181 @decorators.idempotent_id('396a97dc-b66c-4c46-9171-c39eefe6936c')
Hongbin Lu7681a5c2018-04-18 15:54:45 +0000182 @utils.requires_ext(extension="standard-attr-segment", service="network")
Hongbin Lu840c03c2018-04-03 19:34:58 +0000183 def test_segment_with_timestamp(self):
184 network = self.create_network()
185 segment = self.admin_client.list_segments(
186 network_id=network['id'])['segments'][0]
187 # Verifies body contains timestamp fields
188 self.assertIsNotNone(segment['created_at'])
189 self.assertIsNotNone(segment['updated_at'])
190
191 body = self.admin_client.show_segment(segment['id'])
192 show_segment = body['segment']
193 # verify the timestamp from creation and showed is same
194 self.assertEqual(segment['created_at'], show_segment['created_at'])
195 self.assertEqual(segment['updated_at'], show_segment['updated_at'])
196
197 origin_updated_at = segment['updated_at']
198 update_body = {'name': str(segment['name']) + 'new'}
199 body = self.admin_client.update_segment(segment['id'], **update_body)
200 updated_segment = body['segment']
201 new_updated_at = updated_segment['updated_at']
202 self.assertEqual(segment['created_at'], updated_segment['created_at'])
203 # Verify that origin_updated_at is not same with new_updated_at
204 self.assertIsNot(origin_updated_at, new_updated_at)
205
ZhaoBof5620692016-05-05 17:16:23 +0800206
207class TestTimeStampWithL3(base_routers.BaseRouterTest):
ZhaoBof5620692016-05-05 17:16:23 +0800208
Jakub Libosvar1982aa12017-05-30 11:15:33 +0000209 required_extensions = ['standard-attr-timestamp']
ZhaoBof5620692016-05-05 17:16:23 +0800210
211 @classmethod
212 def resource_setup(cls):
213 super(TestTimeStampWithL3, cls).resource_setup()
214 cls.ext_net_id = CONF.network.public_network_id
215
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000216 @decorators.idempotent_id('433ba770-b310-4da9-5d42-733217a1c7b1')
ZhaoBof5620692016-05-05 17:16:23 +0800217 def test_create_router_with_timestamp(self):
218 router = self.create_router(router_name='test')
219 # Verifies body contains timestamp fields
220 self.assertIsNotNone(router['created_at'])
221 self.assertIsNotNone(router['updated_at'])
222
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000223 @decorators.idempotent_id('4a65417a-c11c-4b4d-a351-af01abcf57c6')
ZhaoBof5620692016-05-05 17:16:23 +0800224 def test_update_router_with_timestamp(self):
225 router = self.create_router(router_name='test')
226 origin_updated_at = router['updated_at']
227 update_body = {'name': router['name'] + 'new'}
228 body = self.client.update_router(router['id'], **update_body)
229 updated_router = body['router']
230 new_updated_at = updated_router['updated_at']
231 self.assertEqual(router['created_at'], updated_router['created_at'])
232 # Verify that origin_updated_at is not same with new_updated_at
233 self.assertIsNot(origin_updated_at, new_updated_at)
234
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000235 @decorators.idempotent_id('1ab50ac2-7cbd-4a17-b23e-a9e36cfa4ec2')
ZhaoBof5620692016-05-05 17:16:23 +0800236 def test_show_router_attribute_with_timestamp(self):
237 router = self.create_router(router_name='test')
238 body = self.client.show_router(router['id'])
239 show_router = body['router']
240 # verify the timestamp from creation and showed is same
241 self.assertEqual(router['created_at'],
242 show_router['created_at'])
Brian Haley060f8032017-04-04 14:10:12 -0400243 # 'updated_at' timestamp can change immediately after creation
244 # if environment is HA or DVR, so just make sure it's >=
245 self.assertGreaterEqual(show_router['updated_at'],
246 router['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800247
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000248 @decorators.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac')
ZhaoBof5620692016-05-05 17:16:23 +0800249 def test_create_floatingip_with_timestamp(self):
Federico Ressi3dfa94c2018-07-06 09:46:39 +0200250 fip = self.create_floatingip()
ZhaoBof5620692016-05-05 17:16:23 +0800251 # Verifies body contains timestamp fields
252 self.assertIsNotNone(fip['created_at'])
253 self.assertIsNotNone(fip['updated_at'])
254
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000255 @decorators.idempotent_id('a3ac215a-61ac-13f9-9d3c-57c51f11afa1')
ZhaoBof5620692016-05-05 17:16:23 +0800256 def test_update_floatingip_with_timestamp(self):
Federico Ressi3dfa94c2018-07-06 09:46:39 +0200257 fip = self.create_floatingip()
ZhaoBof5620692016-05-05 17:16:23 +0800258 origin_updated_at = fip['updated_at']
259 update_body = {'description': 'new'}
260 body = self.client.update_floatingip(fip['id'], **update_body)
261 updated_fip = body['floatingip']
262 new_updated_at = updated_fip['updated_at']
263 self.assertEqual(fip['created_at'], updated_fip['created_at'])
264 # Verify that origin_updated_at is not same with new_updated_at
265 self.assertIsNot(origin_updated_at, new_updated_at)
266
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000267 @decorators.idempotent_id('32a6a086-e1ef-413b-b13a-0cfe13ef051e')
ZhaoBof5620692016-05-05 17:16:23 +0800268 def test_show_floatingip_attribute_with_timestamp(self):
Federico Ressi3dfa94c2018-07-06 09:46:39 +0200269 fip = self.create_floatingip()
ZhaoBof5620692016-05-05 17:16:23 +0800270 body = self.client.show_floatingip(fip['id'])
271 show_fip = body['floatingip']
272 # verify the timestamp from creation and showed is same
273 self.assertEqual(fip['created_at'],
274 show_fip['created_at'])
275 self.assertEqual(fip['updated_at'],
276 show_fip['updated_at'])
277
278
279class TestTimeStampWithSecurityGroup(base_security_groups.BaseSecGroupTest):
ZhaoBof5620692016-05-05 17:16:23 +0800280
Jakub Libosvar1982aa12017-05-30 11:15:33 +0000281 required_extensions = ['standard-attr-timestamp']
ZhaoBof5620692016-05-05 17:16:23 +0800282
283 @classmethod
284 def resource_setup(cls):
285 super(TestTimeStampWithSecurityGroup, cls).resource_setup()
286 cls.ext_net_id = CONF.network.public_network_id
287
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000288 @decorators.idempotent_id('a3150a7b-d31a-423a-abf3-45e71c97cbac')
ZhaoBof5620692016-05-05 17:16:23 +0800289 def test_create_sg_with_timestamp(self):
290 sg, _ = self._create_security_group()
291 # Verifies body contains timestamp fields
292 self.assertIsNotNone(sg['security_group']['created_at'])
293 self.assertIsNotNone(sg['security_group']['updated_at'])
294
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000295 @decorators.idempotent_id('432ae0d3-32b4-413e-a9b3-091ac76da31b')
ZhaoBof5620692016-05-05 17:16:23 +0800296 def test_update_sg_with_timestamp(self):
297 sgc, _ = self._create_security_group()
298 sg = sgc['security_group']
299 origin_updated_at = sg['updated_at']
300 update_body = {'name': sg['name'] + 'new'}
301 body = self.client.update_security_group(sg['id'], **update_body)
302 updated_sg = body['security_group']
303 new_updated_at = updated_sg['updated_at']
304 self.assertEqual(sg['created_at'], updated_sg['created_at'])
305 # Verify that origin_updated_at is not same with new_updated_at
306 self.assertIsNot(origin_updated_at, new_updated_at)
307
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000308 @decorators.idempotent_id('521e6723-43d6-12a6-8c3d-f5042ad9fc32')
ZhaoBof5620692016-05-05 17:16:23 +0800309 def test_show_sg_attribute_with_timestamp(self):
310 sg, _ = self._create_security_group()
311 body = self.client.show_security_group(sg['security_group']['id'])
312 show_sg = body['security_group']
313 # verify the timestamp from creation and showed is same
314 self.assertEqual(sg['security_group']['created_at'],
315 show_sg['created_at'])
316 self.assertEqual(sg['security_group']['updated_at'],
317 show_sg['updated_at'])
318
319 def _prepare_sgrule_test(self):
320 sg, _ = self._create_security_group()
321 sg_id = sg['security_group']['id']
322 direction = 'ingress'
323 protocol = 'tcp'
324 port_range_min = 77
325 port_range_max = 77
326 rule_create_body = self.client.create_security_group_rule(
327 security_group_id=sg_id,
328 direction=direction,
329 ethertype=self.ethertype,
330 protocol=protocol,
331 port_range_min=port_range_min,
332 port_range_max=port_range_max,
333 remote_group_id=None,
334 remote_ip_prefix=None
335 )
336 return rule_create_body['security_group_rule']
337
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000338 @decorators.idempotent_id('83e8bd32-43e0-a3f0-1af3-12a5733c653e')
ZhaoBof5620692016-05-05 17:16:23 +0800339 def test_create_sgrule_with_timestamp(self):
340 sgrule = self._prepare_sgrule_test()
341 # Verifies body contains timestamp fields
342 self.assertIsNotNone(sgrule['created_at'])
343 self.assertIsNotNone(sgrule['updated_at'])
344
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000345 @decorators.idempotent_id('143da0e6-ba17-43ad-b3d7-03aa759c3cb4')
ZhaoBof5620692016-05-05 17:16:23 +0800346 def test_show_sgrule_attribute_with_timestamp(self):
347 sgrule = self._prepare_sgrule_test()
348 body = self.client.show_security_group_rule(sgrule['id'])
349 show_sgrule = body['security_group_rule']
350 # verify the timestamp from creation and showed is same
351 self.assertEqual(sgrule['created_at'], show_sgrule['created_at'])
352 self.assertEqual(sgrule['updated_at'], show_sgrule['updated_at'])