blob: 8b57b2dba3319b7b2dbb2046fe499fa760b9636a [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
15from tempest.lib.common.utils import data_utils
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000016from tempest.lib import decorators
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000017from tempest import test
18
19from neutron.tests.tempest.api import base
ZhaoBof5620692016-05-05 17:16:23 +080020from neutron.tests.tempest.api import base_routers
21from neutron.tests.tempest.api import base_security_groups
22from neutron.tests.tempest import config
23
24CONF = config.CONF
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000025
26
27class TestTimeStamp(base.BaseAdminNetworkTest):
28
29 ## attributes for subnetpool
30 min_prefixlen = '28'
31 max_prefixlen = '31'
32 _ip_version = 4
33 subnet_cidr = '10.11.12.0/31'
34 new_prefix = '10.11.15.0/24'
35 larger_prefix = '10.11.0.0/16'
36
37 @classmethod
Kevin Benton6243f432016-09-09 06:20:40 -070038 @test.requires_ext(extension="standard-attr-timestamp", service="network")
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000039 def skip_checks(cls):
40 super(TestTimeStamp, cls).skip_checks()
41
42 @classmethod
43 def resource_setup(cls):
44 super(TestTimeStamp, cls).resource_setup()
45 prefixes = ['10.11.12.0/24']
46 cls._subnetpool_data = {'min_prefixlen': '29', 'prefixes': prefixes}
47
48 def _create_subnetpool(self, is_admin=False, **kwargs):
49 name = data_utils.rand_name('subnetpool-')
50 subnetpool_data = copy.deepcopy(self._subnetpool_data)
51 for key in subnetpool_data.keys():
52 kwargs[key] = subnetpool_data[key]
53 return self.create_subnetpool(name=name, is_admin=is_admin, **kwargs)
54
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000055 @decorators.idempotent_id('462be770-b310-4df9-9c42-773217e4c8b1')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000056 def test_create_network_with_timestamp(self):
57 network = self.create_network()
58 # Verifies body contains timestamp fields
59 self.assertIsNotNone(network['created_at'])
60 self.assertIsNotNone(network['updated_at'])
61
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000062 @decorators.idempotent_id('4db5417a-e11c-474d-a361-af00ebef57c5')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000063 def test_update_network_with_timestamp(self):
64 network = self.create_network()
65 origin_updated_at = network['updated_at']
66 update_body = {'name': network['name'] + 'new'}
67 body = self.admin_client.update_network(network['id'],
68 **update_body)
69 updated_network = body['network']
70 new_updated_at = updated_network['updated_at']
71 self.assertEqual(network['created_at'], updated_network['created_at'])
72 # Verify that origin_updated_at is not same with new_updated_at
73 self.assertIsNot(origin_updated_at, new_updated_at)
74
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000075 @decorators.idempotent_id('2ac50ab2-7ebd-4e27-b3ce-a9e399faaea2')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000076 def test_show_networks_attribute_with_timestamp(self):
77 network = self.create_network()
78 body = self.client.show_network(network['id'])
79 show_net = body['network']
80 # verify the timestamp from creation and showed is same
81 self.assertEqual(network['created_at'],
82 show_net['created_at'])
83 self.assertEqual(network['updated_at'],
84 show_net['updated_at'])
85
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000086 @decorators.idempotent_id('8ee55186-454f-4b97-9f9f-eb2772ee891c')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000087 def test_create_subnet_with_timestamp(self):
88 network = self.create_network()
89 subnet = self.create_subnet(network)
90 # Verifies body contains timestamp fields
91 self.assertIsNotNone(subnet['created_at'])
92 self.assertIsNotNone(subnet['updated_at'])
93
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000094 @decorators.idempotent_id('a490215a-6f4c-4af9-9a4c-57c41f1c4fa1')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000095 def test_update_subnet_with_timestamp(self):
96 network = self.create_network()
97 subnet = self.create_subnet(network)
98 origin_updated_at = subnet['updated_at']
99 update_body = {'name': subnet['name'] + 'new'}
100 body = self.admin_client.update_subnet(subnet['id'],
101 **update_body)
102 updated_subnet = body['subnet']
103 new_updated_at = updated_subnet['updated_at']
104 self.assertEqual(subnet['created_at'], updated_subnet['created_at'])
105 # Verify that origin_updated_at is not same with new_updated_at
106 self.assertIsNot(origin_updated_at, new_updated_at)
107
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000108 @decorators.idempotent_id('1836a086-e7cf-4141-bf57-0cfe79e8051e')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000109 def test_show_subnet_attribute_with_timestamp(self):
110 network = self.create_network()
111 subnet = self.create_subnet(network)
112 body = self.client.show_subnet(subnet['id'])
113 show_subnet = body['subnet']
114 # verify the timestamp from creation and showed is same
115 self.assertEqual(subnet['created_at'],
116 show_subnet['created_at'])
117 self.assertEqual(subnet['updated_at'],
118 show_subnet['updated_at'])
119
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000120 @decorators.idempotent_id('e2450a7b-d84f-4600-a093-45e78597bbac')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000121 def test_create_port_with_timestamp(self):
122 network = self.create_network()
123 port = self.create_port(network)
124 # Verifies body contains timestamp fields
125 self.assertIsNotNone(port['created_at'])
126 self.assertIsNotNone(port['updated_at'])
127
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000128 @decorators.idempotent_id('4241e0d3-54b4-46ce-a9a7-093fc764161b')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000129 def test_update_port_with_timestamp(self):
130 network = self.create_network()
131 port = self.create_port(network)
132 origin_updated_at = port['updated_at']
133 update_body = {'name': port['name'] + 'new'}
134 body = self.admin_client.update_port(port['id'],
135 **update_body)
136 updated_port = body['port']
137 new_updated_at = updated_port['updated_at']
138 self.assertEqual(port['created_at'], updated_port['created_at'])
139 # Verify that origin_updated_at is not same with new_updated_at
140 self.assertIsNot(origin_updated_at, new_updated_at)
141
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000142 @decorators.idempotent_id('584c6723-40b6-4f26-81dd-f508f9d9fb51')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000143 def test_show_port_attribute_with_timestamp(self):
144 network = self.create_network()
145 port = self.create_port(network)
146 body = self.client.show_port(port['id'])
147 show_port = body['port']
148 # verify the timestamp from creation and showed is same
149 self.assertEqual(port['created_at'],
150 show_port['created_at'])
151 self.assertEqual(port['updated_at'],
152 show_port['updated_at'])
153
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000154 @decorators.idempotent_id('87a8b196-4b90-44f0-b7f3-d2057d7d658e')
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')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000162 def test_update_subnetpool_with_timestamp(self):
163 sp = self._create_subnetpool()
164 origin_updated_at = sp['updated_at']
165 update_body = {'name': sp['name'] + 'new',
166 'min_prefixlen': self.min_prefixlen,
167 'max_prefixlen': self.max_prefixlen}
168 body = self.client.update_subnetpool(sp['id'], **update_body)
169 updated_sp = body['subnetpool']
170 new_updated_at = updated_sp['updated_at']
171 self.assertEqual(sp['created_at'], updated_sp['created_at'])
172 # Verify that origin_updated_at is not same with new_updated_at
173 self.assertIsNot(origin_updated_at, new_updated_at)
174
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000175 @decorators.idempotent_id('1d3970e6-bcf7-46cd-b7d7-0807759c73b4')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000176 def test_show_subnetpool_attribute_with_timestamp(self):
177 sp = self._create_subnetpool()
178 body = self.client.show_subnetpool(sp['id'])
179 show_sp = body['subnetpool']
180 # verify the timestamp from creation and showed is same
181 self.assertEqual(sp['created_at'], show_sp['created_at'])
182 self.assertEqual(sp['updated_at'], show_sp['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800183
184
185class TestTimeStampWithL3(base_routers.BaseRouterTest):
186 @classmethod
187 def skip_checks(cls):
188 super(TestTimeStampWithL3, cls).skip_checks()
189
Kevin Benton6243f432016-09-09 06:20:40 -0700190 if not test.is_extension_enabled('standard-attr-timestamp', 'network'):
191 raise cls.skipException("standard-attr-timestamp extension not "
192 "enabled")
ZhaoBof5620692016-05-05 17:16:23 +0800193
194 @classmethod
195 def resource_setup(cls):
196 super(TestTimeStampWithL3, cls).resource_setup()
197 cls.ext_net_id = CONF.network.public_network_id
198
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000199 @decorators.idempotent_id('433ba770-b310-4da9-5d42-733217a1c7b1')
ZhaoBof5620692016-05-05 17:16:23 +0800200 def test_create_router_with_timestamp(self):
201 router = self.create_router(router_name='test')
202 # Verifies body contains timestamp fields
203 self.assertIsNotNone(router['created_at'])
204 self.assertIsNotNone(router['updated_at'])
205
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000206 @decorators.idempotent_id('4a65417a-c11c-4b4d-a351-af01abcf57c6')
ZhaoBof5620692016-05-05 17:16:23 +0800207 def test_update_router_with_timestamp(self):
208 router = self.create_router(router_name='test')
209 origin_updated_at = router['updated_at']
210 update_body = {'name': router['name'] + 'new'}
211 body = self.client.update_router(router['id'], **update_body)
212 updated_router = body['router']
213 new_updated_at = updated_router['updated_at']
214 self.assertEqual(router['created_at'], updated_router['created_at'])
215 # Verify that origin_updated_at is not same with new_updated_at
216 self.assertIsNot(origin_updated_at, new_updated_at)
217
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000218 @decorators.idempotent_id('1ab50ac2-7cbd-4a17-b23e-a9e36cfa4ec2')
ZhaoBof5620692016-05-05 17:16:23 +0800219 def test_show_router_attribute_with_timestamp(self):
220 router = self.create_router(router_name='test')
221 body = self.client.show_router(router['id'])
222 show_router = body['router']
223 # verify the timestamp from creation and showed is same
224 self.assertEqual(router['created_at'],
225 show_router['created_at'])
Brian Haley060f8032017-04-04 14:10:12 -0400226 # 'updated_at' timestamp can change immediately after creation
227 # if environment is HA or DVR, so just make sure it's >=
228 self.assertGreaterEqual(show_router['updated_at'],
229 router['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800230
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000231 @decorators.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac')
ZhaoBof5620692016-05-05 17:16:23 +0800232 def test_create_floatingip_with_timestamp(self):
233 fip = self.create_floatingip(self.ext_net_id)
234 # Verifies body contains timestamp fields
235 self.assertIsNotNone(fip['created_at'])
236 self.assertIsNotNone(fip['updated_at'])
237
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000238 @decorators.idempotent_id('a3ac215a-61ac-13f9-9d3c-57c51f11afa1')
ZhaoBof5620692016-05-05 17:16:23 +0800239 def test_update_floatingip_with_timestamp(self):
240 fip = self.create_floatingip(self.ext_net_id)
241 origin_updated_at = fip['updated_at']
242 update_body = {'description': 'new'}
243 body = self.client.update_floatingip(fip['id'], **update_body)
244 updated_fip = body['floatingip']
245 new_updated_at = updated_fip['updated_at']
246 self.assertEqual(fip['created_at'], updated_fip['created_at'])
247 # Verify that origin_updated_at is not same with new_updated_at
248 self.assertIsNot(origin_updated_at, new_updated_at)
249
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000250 @decorators.idempotent_id('32a6a086-e1ef-413b-b13a-0cfe13ef051e')
ZhaoBof5620692016-05-05 17:16:23 +0800251 def test_show_floatingip_attribute_with_timestamp(self):
252 fip = self.create_floatingip(self.ext_net_id)
253 body = self.client.show_floatingip(fip['id'])
254 show_fip = body['floatingip']
255 # verify the timestamp from creation and showed is same
256 self.assertEqual(fip['created_at'],
257 show_fip['created_at'])
258 self.assertEqual(fip['updated_at'],
259 show_fip['updated_at'])
260
261
262class TestTimeStampWithSecurityGroup(base_security_groups.BaseSecGroupTest):
263 @classmethod
264 def skip_checks(cls):
265 super(TestTimeStampWithSecurityGroup, cls).skip_checks()
266
Kevin Benton6243f432016-09-09 06:20:40 -0700267 if not test.is_extension_enabled('standard-attr-timestamp', 'network'):
268 raise cls.skipException("standard-attr-timestamp extension not "
269 "enabled")
ZhaoBof5620692016-05-05 17:16:23 +0800270
271 @classmethod
272 def resource_setup(cls):
273 super(TestTimeStampWithSecurityGroup, cls).resource_setup()
274 cls.ext_net_id = CONF.network.public_network_id
275
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000276 @decorators.idempotent_id('a3150a7b-d31a-423a-abf3-45e71c97cbac')
ZhaoBof5620692016-05-05 17:16:23 +0800277 def test_create_sg_with_timestamp(self):
278 sg, _ = self._create_security_group()
279 # Verifies body contains timestamp fields
280 self.assertIsNotNone(sg['security_group']['created_at'])
281 self.assertIsNotNone(sg['security_group']['updated_at'])
282
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000283 @decorators.idempotent_id('432ae0d3-32b4-413e-a9b3-091ac76da31b')
ZhaoBof5620692016-05-05 17:16:23 +0800284 def test_update_sg_with_timestamp(self):
285 sgc, _ = self._create_security_group()
286 sg = sgc['security_group']
287 origin_updated_at = sg['updated_at']
288 update_body = {'name': sg['name'] + 'new'}
289 body = self.client.update_security_group(sg['id'], **update_body)
290 updated_sg = body['security_group']
291 new_updated_at = updated_sg['updated_at']
292 self.assertEqual(sg['created_at'], updated_sg['created_at'])
293 # Verify that origin_updated_at is not same with new_updated_at
294 self.assertIsNot(origin_updated_at, new_updated_at)
295
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000296 @decorators.idempotent_id('521e6723-43d6-12a6-8c3d-f5042ad9fc32')
ZhaoBof5620692016-05-05 17:16:23 +0800297 def test_show_sg_attribute_with_timestamp(self):
298 sg, _ = self._create_security_group()
299 body = self.client.show_security_group(sg['security_group']['id'])
300 show_sg = body['security_group']
301 # verify the timestamp from creation and showed is same
302 self.assertEqual(sg['security_group']['created_at'],
303 show_sg['created_at'])
304 self.assertEqual(sg['security_group']['updated_at'],
305 show_sg['updated_at'])
306
307 def _prepare_sgrule_test(self):
308 sg, _ = self._create_security_group()
309 sg_id = sg['security_group']['id']
310 direction = 'ingress'
311 protocol = 'tcp'
312 port_range_min = 77
313 port_range_max = 77
314 rule_create_body = self.client.create_security_group_rule(
315 security_group_id=sg_id,
316 direction=direction,
317 ethertype=self.ethertype,
318 protocol=protocol,
319 port_range_min=port_range_min,
320 port_range_max=port_range_max,
321 remote_group_id=None,
322 remote_ip_prefix=None
323 )
324 return rule_create_body['security_group_rule']
325
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000326 @decorators.idempotent_id('83e8bd32-43e0-a3f0-1af3-12a5733c653e')
ZhaoBof5620692016-05-05 17:16:23 +0800327 def test_create_sgrule_with_timestamp(self):
328 sgrule = self._prepare_sgrule_test()
329 # Verifies body contains timestamp fields
330 self.assertIsNotNone(sgrule['created_at'])
331 self.assertIsNotNone(sgrule['updated_at'])
332
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000333 @decorators.idempotent_id('143da0e6-ba17-43ad-b3d7-03aa759c3cb4')
ZhaoBof5620692016-05-05 17:16:23 +0800334 def test_show_sgrule_attribute_with_timestamp(self):
335 sgrule = self._prepare_sgrule_test()
336 body = self.client.show_security_group_rule(sgrule['id'])
337 show_sgrule = body['security_group_rule']
338 # verify the timestamp from creation and showed is same
339 self.assertEqual(sgrule['created_at'], show_sgrule['created_at'])
340 self.assertEqual(sgrule['updated_at'], show_sgrule['updated_at'])