blob: 20d570391ece55ff0efd33caa7d64ac4542a3ce1 [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 +000017
Chandan Kumar667d3d32017-09-22 12:24:06 +053018from neutron_tempest_plugin.api import base
19from neutron_tempest_plugin.api import base_routers
20from neutron_tempest_plugin.api import base_security_groups
21from neutron_tempest_plugin import config
ZhaoBof5620692016-05-05 17:16:23 +080022
23CONF = config.CONF
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000024
25
26class TestTimeStamp(base.BaseAdminNetworkTest):
27
Jakub Libosvar1982aa12017-05-30 11:15:33 +000028 required_extensions = ["standard-attr-timestamp"]
29
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000030 ## attributes for subnetpool
31 min_prefixlen = '28'
32 max_prefixlen = '31'
33 _ip_version = 4
34 subnet_cidr = '10.11.12.0/31'
35 new_prefix = '10.11.15.0/24'
36 larger_prefix = '10.11.0.0/16'
37
38 @classmethod
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000039 def resource_setup(cls):
40 super(TestTimeStamp, cls).resource_setup()
41 prefixes = ['10.11.12.0/24']
42 cls._subnetpool_data = {'min_prefixlen': '29', 'prefixes': prefixes}
43
44 def _create_subnetpool(self, is_admin=False, **kwargs):
45 name = data_utils.rand_name('subnetpool-')
46 subnetpool_data = copy.deepcopy(self._subnetpool_data)
47 for key in subnetpool_data.keys():
48 kwargs[key] = subnetpool_data[key]
49 return self.create_subnetpool(name=name, is_admin=is_admin, **kwargs)
50
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000051 @decorators.idempotent_id('462be770-b310-4df9-9c42-773217e4c8b1')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000052 def test_create_network_with_timestamp(self):
53 network = self.create_network()
54 # Verifies body contains timestamp fields
55 self.assertIsNotNone(network['created_at'])
56 self.assertIsNotNone(network['updated_at'])
57
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000058 @decorators.idempotent_id('4db5417a-e11c-474d-a361-af00ebef57c5')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000059 def test_update_network_with_timestamp(self):
60 network = self.create_network()
61 origin_updated_at = network['updated_at']
62 update_body = {'name': network['name'] + 'new'}
63 body = self.admin_client.update_network(network['id'],
64 **update_body)
65 updated_network = body['network']
66 new_updated_at = updated_network['updated_at']
67 self.assertEqual(network['created_at'], updated_network['created_at'])
68 # Verify that origin_updated_at is not same with new_updated_at
69 self.assertIsNot(origin_updated_at, new_updated_at)
70
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000071 @decorators.idempotent_id('2ac50ab2-7ebd-4e27-b3ce-a9e399faaea2')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000072 def test_show_networks_attribute_with_timestamp(self):
73 network = self.create_network()
74 body = self.client.show_network(network['id'])
75 show_net = body['network']
76 # verify the timestamp from creation and showed is same
77 self.assertEqual(network['created_at'],
78 show_net['created_at'])
79 self.assertEqual(network['updated_at'],
80 show_net['updated_at'])
81
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000082 @decorators.idempotent_id('8ee55186-454f-4b97-9f9f-eb2772ee891c')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000083 def test_create_subnet_with_timestamp(self):
84 network = self.create_network()
85 subnet = self.create_subnet(network)
86 # Verifies body contains timestamp fields
87 self.assertIsNotNone(subnet['created_at'])
88 self.assertIsNotNone(subnet['updated_at'])
89
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000090 @decorators.idempotent_id('a490215a-6f4c-4af9-9a4c-57c41f1c4fa1')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000091 def test_update_subnet_with_timestamp(self):
92 network = self.create_network()
93 subnet = self.create_subnet(network)
94 origin_updated_at = subnet['updated_at']
95 update_body = {'name': subnet['name'] + 'new'}
96 body = self.admin_client.update_subnet(subnet['id'],
97 **update_body)
98 updated_subnet = body['subnet']
99 new_updated_at = updated_subnet['updated_at']
100 self.assertEqual(subnet['created_at'], updated_subnet['created_at'])
101 # Verify that origin_updated_at is not same with new_updated_at
102 self.assertIsNot(origin_updated_at, new_updated_at)
103
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000104 @decorators.idempotent_id('1836a086-e7cf-4141-bf57-0cfe79e8051e')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000105 def test_show_subnet_attribute_with_timestamp(self):
106 network = self.create_network()
107 subnet = self.create_subnet(network)
108 body = self.client.show_subnet(subnet['id'])
109 show_subnet = body['subnet']
110 # verify the timestamp from creation and showed is same
111 self.assertEqual(subnet['created_at'],
112 show_subnet['created_at'])
113 self.assertEqual(subnet['updated_at'],
114 show_subnet['updated_at'])
115
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000116 @decorators.idempotent_id('e2450a7b-d84f-4600-a093-45e78597bbac')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000117 def test_create_port_with_timestamp(self):
118 network = self.create_network()
119 port = self.create_port(network)
120 # Verifies body contains timestamp fields
121 self.assertIsNotNone(port['created_at'])
122 self.assertIsNotNone(port['updated_at'])
123
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000124 @decorators.idempotent_id('4241e0d3-54b4-46ce-a9a7-093fc764161b')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000125 def test_update_port_with_timestamp(self):
126 network = self.create_network()
127 port = self.create_port(network)
128 origin_updated_at = port['updated_at']
129 update_body = {'name': port['name'] + 'new'}
130 body = self.admin_client.update_port(port['id'],
131 **update_body)
132 updated_port = body['port']
133 new_updated_at = updated_port['updated_at']
134 self.assertEqual(port['created_at'], updated_port['created_at'])
135 # Verify that origin_updated_at is not same with new_updated_at
136 self.assertIsNot(origin_updated_at, new_updated_at)
137
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000138 @decorators.idempotent_id('584c6723-40b6-4f26-81dd-f508f9d9fb51')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000139 def test_show_port_attribute_with_timestamp(self):
140 network = self.create_network()
141 port = self.create_port(network)
142 body = self.client.show_port(port['id'])
143 show_port = body['port']
144 # verify the timestamp from creation and showed is same
145 self.assertEqual(port['created_at'],
146 show_port['created_at'])
147 self.assertEqual(port['updated_at'],
148 show_port['updated_at'])
149
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000150 @decorators.idempotent_id('87a8b196-4b90-44f0-b7f3-d2057d7d658e')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000151 def test_create_subnetpool_with_timestamp(self):
152 sp = self._create_subnetpool()
153 # Verifies body contains timestamp fields
154 self.assertIsNotNone(sp['created_at'])
155 self.assertIsNotNone(sp['updated_at'])
156
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000157 @decorators.idempotent_id('d48c7578-c3d2-4f9b-a7a1-be2008c770a0')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000158 def test_update_subnetpool_with_timestamp(self):
159 sp = self._create_subnetpool()
160 origin_updated_at = sp['updated_at']
161 update_body = {'name': sp['name'] + 'new',
162 'min_prefixlen': self.min_prefixlen,
163 'max_prefixlen': self.max_prefixlen}
164 body = self.client.update_subnetpool(sp['id'], **update_body)
165 updated_sp = body['subnetpool']
166 new_updated_at = updated_sp['updated_at']
167 self.assertEqual(sp['created_at'], updated_sp['created_at'])
168 # Verify that origin_updated_at is not same with new_updated_at
169 self.assertIsNot(origin_updated_at, new_updated_at)
170
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000171 @decorators.idempotent_id('1d3970e6-bcf7-46cd-b7d7-0807759c73b4')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000172 def test_show_subnetpool_attribute_with_timestamp(self):
173 sp = self._create_subnetpool()
174 body = self.client.show_subnetpool(sp['id'])
175 show_sp = body['subnetpool']
176 # verify the timestamp from creation and showed is same
177 self.assertEqual(sp['created_at'], show_sp['created_at'])
178 self.assertEqual(sp['updated_at'], show_sp['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800179
180
181class TestTimeStampWithL3(base_routers.BaseRouterTest):
ZhaoBof5620692016-05-05 17:16:23 +0800182
Jakub Libosvar1982aa12017-05-30 11:15:33 +0000183 required_extensions = ['standard-attr-timestamp']
ZhaoBof5620692016-05-05 17:16:23 +0800184
185 @classmethod
186 def resource_setup(cls):
187 super(TestTimeStampWithL3, cls).resource_setup()
188 cls.ext_net_id = CONF.network.public_network_id
189
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000190 @decorators.idempotent_id('433ba770-b310-4da9-5d42-733217a1c7b1')
ZhaoBof5620692016-05-05 17:16:23 +0800191 def test_create_router_with_timestamp(self):
192 router = self.create_router(router_name='test')
193 # Verifies body contains timestamp fields
194 self.assertIsNotNone(router['created_at'])
195 self.assertIsNotNone(router['updated_at'])
196
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000197 @decorators.idempotent_id('4a65417a-c11c-4b4d-a351-af01abcf57c6')
ZhaoBof5620692016-05-05 17:16:23 +0800198 def test_update_router_with_timestamp(self):
199 router = self.create_router(router_name='test')
200 origin_updated_at = router['updated_at']
201 update_body = {'name': router['name'] + 'new'}
202 body = self.client.update_router(router['id'], **update_body)
203 updated_router = body['router']
204 new_updated_at = updated_router['updated_at']
205 self.assertEqual(router['created_at'], updated_router['created_at'])
206 # Verify that origin_updated_at is not same with new_updated_at
207 self.assertIsNot(origin_updated_at, new_updated_at)
208
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000209 @decorators.idempotent_id('1ab50ac2-7cbd-4a17-b23e-a9e36cfa4ec2')
ZhaoBof5620692016-05-05 17:16:23 +0800210 def test_show_router_attribute_with_timestamp(self):
211 router = self.create_router(router_name='test')
212 body = self.client.show_router(router['id'])
213 show_router = body['router']
214 # verify the timestamp from creation and showed is same
215 self.assertEqual(router['created_at'],
216 show_router['created_at'])
Brian Haley060f8032017-04-04 14:10:12 -0400217 # 'updated_at' timestamp can change immediately after creation
218 # if environment is HA or DVR, so just make sure it's >=
219 self.assertGreaterEqual(show_router['updated_at'],
220 router['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800221
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000222 @decorators.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac')
ZhaoBof5620692016-05-05 17:16:23 +0800223 def test_create_floatingip_with_timestamp(self):
224 fip = self.create_floatingip(self.ext_net_id)
225 # Verifies body contains timestamp fields
226 self.assertIsNotNone(fip['created_at'])
227 self.assertIsNotNone(fip['updated_at'])
228
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000229 @decorators.idempotent_id('a3ac215a-61ac-13f9-9d3c-57c51f11afa1')
ZhaoBof5620692016-05-05 17:16:23 +0800230 def test_update_floatingip_with_timestamp(self):
231 fip = self.create_floatingip(self.ext_net_id)
232 origin_updated_at = fip['updated_at']
233 update_body = {'description': 'new'}
234 body = self.client.update_floatingip(fip['id'], **update_body)
235 updated_fip = body['floatingip']
236 new_updated_at = updated_fip['updated_at']
237 self.assertEqual(fip['created_at'], updated_fip['created_at'])
238 # Verify that origin_updated_at is not same with new_updated_at
239 self.assertIsNot(origin_updated_at, new_updated_at)
240
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000241 @decorators.idempotent_id('32a6a086-e1ef-413b-b13a-0cfe13ef051e')
ZhaoBof5620692016-05-05 17:16:23 +0800242 def test_show_floatingip_attribute_with_timestamp(self):
243 fip = self.create_floatingip(self.ext_net_id)
244 body = self.client.show_floatingip(fip['id'])
245 show_fip = body['floatingip']
246 # verify the timestamp from creation and showed is same
247 self.assertEqual(fip['created_at'],
248 show_fip['created_at'])
249 self.assertEqual(fip['updated_at'],
250 show_fip['updated_at'])
251
252
253class TestTimeStampWithSecurityGroup(base_security_groups.BaseSecGroupTest):
ZhaoBof5620692016-05-05 17:16:23 +0800254
Jakub Libosvar1982aa12017-05-30 11:15:33 +0000255 required_extensions = ['standard-attr-timestamp']
ZhaoBof5620692016-05-05 17:16:23 +0800256
257 @classmethod
258 def resource_setup(cls):
259 super(TestTimeStampWithSecurityGroup, cls).resource_setup()
260 cls.ext_net_id = CONF.network.public_network_id
261
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000262 @decorators.idempotent_id('a3150a7b-d31a-423a-abf3-45e71c97cbac')
ZhaoBof5620692016-05-05 17:16:23 +0800263 def test_create_sg_with_timestamp(self):
264 sg, _ = self._create_security_group()
265 # Verifies body contains timestamp fields
266 self.assertIsNotNone(sg['security_group']['created_at'])
267 self.assertIsNotNone(sg['security_group']['updated_at'])
268
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000269 @decorators.idempotent_id('432ae0d3-32b4-413e-a9b3-091ac76da31b')
ZhaoBof5620692016-05-05 17:16:23 +0800270 def test_update_sg_with_timestamp(self):
271 sgc, _ = self._create_security_group()
272 sg = sgc['security_group']
273 origin_updated_at = sg['updated_at']
274 update_body = {'name': sg['name'] + 'new'}
275 body = self.client.update_security_group(sg['id'], **update_body)
276 updated_sg = body['security_group']
277 new_updated_at = updated_sg['updated_at']
278 self.assertEqual(sg['created_at'], updated_sg['created_at'])
279 # Verify that origin_updated_at is not same with new_updated_at
280 self.assertIsNot(origin_updated_at, new_updated_at)
281
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000282 @decorators.idempotent_id('521e6723-43d6-12a6-8c3d-f5042ad9fc32')
ZhaoBof5620692016-05-05 17:16:23 +0800283 def test_show_sg_attribute_with_timestamp(self):
284 sg, _ = self._create_security_group()
285 body = self.client.show_security_group(sg['security_group']['id'])
286 show_sg = body['security_group']
287 # verify the timestamp from creation and showed is same
288 self.assertEqual(sg['security_group']['created_at'],
289 show_sg['created_at'])
290 self.assertEqual(sg['security_group']['updated_at'],
291 show_sg['updated_at'])
292
293 def _prepare_sgrule_test(self):
294 sg, _ = self._create_security_group()
295 sg_id = sg['security_group']['id']
296 direction = 'ingress'
297 protocol = 'tcp'
298 port_range_min = 77
299 port_range_max = 77
300 rule_create_body = self.client.create_security_group_rule(
301 security_group_id=sg_id,
302 direction=direction,
303 ethertype=self.ethertype,
304 protocol=protocol,
305 port_range_min=port_range_min,
306 port_range_max=port_range_max,
307 remote_group_id=None,
308 remote_ip_prefix=None
309 )
310 return rule_create_body['security_group_rule']
311
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000312 @decorators.idempotent_id('83e8bd32-43e0-a3f0-1af3-12a5733c653e')
ZhaoBof5620692016-05-05 17:16:23 +0800313 def test_create_sgrule_with_timestamp(self):
314 sgrule = self._prepare_sgrule_test()
315 # Verifies body contains timestamp fields
316 self.assertIsNotNone(sgrule['created_at'])
317 self.assertIsNotNone(sgrule['updated_at'])
318
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000319 @decorators.idempotent_id('143da0e6-ba17-43ad-b3d7-03aa759c3cb4')
ZhaoBof5620692016-05-05 17:16:23 +0800320 def test_show_sgrule_attribute_with_timestamp(self):
321 sgrule = self._prepare_sgrule_test()
322 body = self.client.show_security_group_rule(sgrule['id'])
323 show_sgrule = body['security_group_rule']
324 # verify the timestamp from creation and showed is same
325 self.assertEqual(sgrule['created_at'], show_sgrule['created_at'])
326 self.assertEqual(sgrule['updated_at'], show_sgrule['updated_at'])