blob: 290e162501dfae617ee9ba2d0098687a433a8131 [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
16from tempest import test
17
18from neutron.tests.tempest.api import base
ZhaoBof5620692016-05-05 17:16:23 +080019from neutron.tests.tempest.api import base_routers
20from neutron.tests.tempest.api import base_security_groups
21from neutron.tests.tempest import config
22
23CONF = config.CONF
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000024
25
26class TestTimeStamp(base.BaseAdminNetworkTest):
27
28 ## attributes for subnetpool
29 min_prefixlen = '28'
30 max_prefixlen = '31'
31 _ip_version = 4
32 subnet_cidr = '10.11.12.0/31'
33 new_prefix = '10.11.15.0/24'
34 larger_prefix = '10.11.0.0/16'
35
36 @classmethod
37 @test.requires_ext(extension="timestamp_core", service="network")
38 def skip_checks(cls):
39 super(TestTimeStamp, cls).skip_checks()
40
41 @classmethod
42 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):
48 name = data_utils.rand_name('subnetpool-')
49 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
54 @test.idempotent_id('462be770-b310-4df9-9c42-773217e4c8b1')
55 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
61 @test.idempotent_id('4db5417a-e11c-474d-a361-af00ebef57c5')
62 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
74 @test.idempotent_id('2ac50ab2-7ebd-4e27-b3ce-a9e399faaea2')
75 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
85 @test.idempotent_id('8ee55186-454f-4b97-9f9f-eb2772ee891c')
86 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
93 @test.idempotent_id('a490215a-6f4c-4af9-9a4c-57c41f1c4fa1')
94 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
107 @test.idempotent_id('1836a086-e7cf-4141-bf57-0cfe79e8051e')
108 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
119 @test.idempotent_id('e2450a7b-d84f-4600-a093-45e78597bbac')
120 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
127 @test.idempotent_id('4241e0d3-54b4-46ce-a9a7-093fc764161b')
128 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
141 @test.idempotent_id('584c6723-40b6-4f26-81dd-f508f9d9fb51')
142 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
153 @test.idempotent_id('87a8b196-4b90-44f0-b7f3-d2057d7d658e')
154 def test_create_subnetpool_with_timestamp(self):
155 sp = self._create_subnetpool()
156 # Verifies body contains timestamp fields
157 self.assertIsNotNone(sp['created_at'])
158 self.assertIsNotNone(sp['updated_at'])
159
160 @test.idempotent_id('d48c7578-c3d2-4f9b-a7a1-be2008c770a0')
161 def test_update_subnetpool_with_timestamp(self):
162 sp = self._create_subnetpool()
163 origin_updated_at = sp['updated_at']
164 update_body = {'name': sp['name'] + 'new',
165 'min_prefixlen': self.min_prefixlen,
166 'max_prefixlen': self.max_prefixlen}
167 body = self.client.update_subnetpool(sp['id'], **update_body)
168 updated_sp = body['subnetpool']
169 new_updated_at = updated_sp['updated_at']
170 self.assertEqual(sp['created_at'], updated_sp['created_at'])
171 # Verify that origin_updated_at is not same with new_updated_at
172 self.assertIsNot(origin_updated_at, new_updated_at)
173
174 @test.idempotent_id('1d3970e6-bcf7-46cd-b7d7-0807759c73b4')
175 def test_show_subnetpool_attribute_with_timestamp(self):
176 sp = self._create_subnetpool()
177 body = self.client.show_subnetpool(sp['id'])
178 show_sp = body['subnetpool']
179 # verify the timestamp from creation and showed is same
180 self.assertEqual(sp['created_at'], show_sp['created_at'])
181 self.assertEqual(sp['updated_at'], show_sp['updated_at'])
ZhaoBof5620692016-05-05 17:16:23 +0800182
183
184class TestTimeStampWithL3(base_routers.BaseRouterTest):
185 @classmethod
186 def skip_checks(cls):
187 super(TestTimeStampWithL3, cls).skip_checks()
188
189 if not test.is_extension_enabled('timestamp_ext', 'network'):
190 raise cls.skipException("timestamp_ext extension not enabled")
191
192 @classmethod
193 def resource_setup(cls):
194 super(TestTimeStampWithL3, cls).resource_setup()
195 cls.ext_net_id = CONF.network.public_network_id
196
197 @test.idempotent_id('433ba770-b310-4da9-5d42-733217a1c7b1')
198 def test_create_router_with_timestamp(self):
199 router = self.create_router(router_name='test')
200 # Verifies body contains timestamp fields
201 self.assertIsNotNone(router['created_at'])
202 self.assertIsNotNone(router['updated_at'])
203
204 @test.idempotent_id('4a65417a-c11c-4b4d-a351-af01abcf57c6')
205 def test_update_router_with_timestamp(self):
206 router = self.create_router(router_name='test')
207 origin_updated_at = router['updated_at']
208 update_body = {'name': router['name'] + 'new'}
209 body = self.client.update_router(router['id'], **update_body)
210 updated_router = body['router']
211 new_updated_at = updated_router['updated_at']
212 self.assertEqual(router['created_at'], updated_router['created_at'])
213 # Verify that origin_updated_at is not same with new_updated_at
214 self.assertIsNot(origin_updated_at, new_updated_at)
215
216 @test.idempotent_id('1ab50ac2-7cbd-4a17-b23e-a9e36cfa4ec2')
217 def test_show_router_attribute_with_timestamp(self):
218 router = self.create_router(router_name='test')
219 body = self.client.show_router(router['id'])
220 show_router = body['router']
221 # verify the timestamp from creation and showed is same
222 self.assertEqual(router['created_at'],
223 show_router['created_at'])
224 self.assertEqual(router['updated_at'],
225 show_router['updated_at'])
226
227 @test.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac')
228 def test_create_floatingip_with_timestamp(self):
229 fip = self.create_floatingip(self.ext_net_id)
230 # Verifies body contains timestamp fields
231 self.assertIsNotNone(fip['created_at'])
232 self.assertIsNotNone(fip['updated_at'])
233
234 @test.idempotent_id('a3ac215a-61ac-13f9-9d3c-57c51f11afa1')
235 def test_update_floatingip_with_timestamp(self):
236 fip = self.create_floatingip(self.ext_net_id)
237 origin_updated_at = fip['updated_at']
238 update_body = {'description': 'new'}
239 body = self.client.update_floatingip(fip['id'], **update_body)
240 updated_fip = body['floatingip']
241 new_updated_at = updated_fip['updated_at']
242 self.assertEqual(fip['created_at'], updated_fip['created_at'])
243 # Verify that origin_updated_at is not same with new_updated_at
244 self.assertIsNot(origin_updated_at, new_updated_at)
245
246 @test.idempotent_id('32a6a086-e1ef-413b-b13a-0cfe13ef051e')
247 def test_show_floatingip_attribute_with_timestamp(self):
248 fip = self.create_floatingip(self.ext_net_id)
249 body = self.client.show_floatingip(fip['id'])
250 show_fip = body['floatingip']
251 # verify the timestamp from creation and showed is same
252 self.assertEqual(fip['created_at'],
253 show_fip['created_at'])
254 self.assertEqual(fip['updated_at'],
255 show_fip['updated_at'])
256
257
258class TestTimeStampWithSecurityGroup(base_security_groups.BaseSecGroupTest):
259 @classmethod
260 def skip_checks(cls):
261 super(TestTimeStampWithSecurityGroup, cls).skip_checks()
262
263 if not test.is_extension_enabled('timestamp_ext', 'network'):
264 raise cls.skipException("timestamp_ext extension not enabled")
265
266 @classmethod
267 def resource_setup(cls):
268 super(TestTimeStampWithSecurityGroup, cls).resource_setup()
269 cls.ext_net_id = CONF.network.public_network_id
270
271 @test.idempotent_id('a3150a7b-d31a-423a-abf3-45e71c97cbac')
272 def test_create_sg_with_timestamp(self):
273 sg, _ = self._create_security_group()
274 # Verifies body contains timestamp fields
275 self.assertIsNotNone(sg['security_group']['created_at'])
276 self.assertIsNotNone(sg['security_group']['updated_at'])
277
278 @test.idempotent_id('432ae0d3-32b4-413e-a9b3-091ac76da31b')
279 def test_update_sg_with_timestamp(self):
280 sgc, _ = self._create_security_group()
281 sg = sgc['security_group']
282 origin_updated_at = sg['updated_at']
283 update_body = {'name': sg['name'] + 'new'}
284 body = self.client.update_security_group(sg['id'], **update_body)
285 updated_sg = body['security_group']
286 new_updated_at = updated_sg['updated_at']
287 self.assertEqual(sg['created_at'], updated_sg['created_at'])
288 # Verify that origin_updated_at is not same with new_updated_at
289 self.assertIsNot(origin_updated_at, new_updated_at)
290
291 @test.idempotent_id('521e6723-43d6-12a6-8c3d-f5042ad9fc32')
292 def test_show_sg_attribute_with_timestamp(self):
293 sg, _ = self._create_security_group()
294 body = self.client.show_security_group(sg['security_group']['id'])
295 show_sg = body['security_group']
296 # verify the timestamp from creation and showed is same
297 self.assertEqual(sg['security_group']['created_at'],
298 show_sg['created_at'])
299 self.assertEqual(sg['security_group']['updated_at'],
300 show_sg['updated_at'])
301
302 def _prepare_sgrule_test(self):
303 sg, _ = self._create_security_group()
304 sg_id = sg['security_group']['id']
305 direction = 'ingress'
306 protocol = 'tcp'
307 port_range_min = 77
308 port_range_max = 77
309 rule_create_body = self.client.create_security_group_rule(
310 security_group_id=sg_id,
311 direction=direction,
312 ethertype=self.ethertype,
313 protocol=protocol,
314 port_range_min=port_range_min,
315 port_range_max=port_range_max,
316 remote_group_id=None,
317 remote_ip_prefix=None
318 )
319 return rule_create_body['security_group_rule']
320
321 @test.idempotent_id('83e8bd32-43e0-a3f0-1af3-12a5733c653e')
322 def test_create_sgrule_with_timestamp(self):
323 sgrule = self._prepare_sgrule_test()
324 # Verifies body contains timestamp fields
325 self.assertIsNotNone(sgrule['created_at'])
326 self.assertIsNotNone(sgrule['updated_at'])
327
328 @test.idempotent_id('143da0e6-ba17-43ad-b3d7-03aa759c3cb4')
329 def test_show_sgrule_attribute_with_timestamp(self):
330 sgrule = self._prepare_sgrule_test()
331 body = self.client.show_security_group_rule(sgrule['id'])
332 show_sgrule = body['security_group_rule']
333 # verify the timestamp from creation and showed is same
334 self.assertEqual(sgrule['created_at'], show_sgrule['created_at'])
335 self.assertEqual(sgrule['updated_at'], show_sgrule['updated_at'])