Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1 | # 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 | |
| 13 | import copy |
| 14 | |
| 15 | from tempest.lib.common.utils import data_utils |
| 16 | from tempest import test |
| 17 | |
| 18 | from neutron.tests.tempest.api import base |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 19 | from neutron.tests.tempest.api import base_routers |
| 20 | from neutron.tests.tempest.api import base_security_groups |
| 21 | from neutron.tests.tempest import config |
| 22 | |
| 23 | CONF = config.CONF |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 24 | |
| 25 | |
| 26 | class 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 |
Kevin Benton | 6243f43 | 2016-09-09 06:20:40 -0700 | [diff] [blame] | 37 | @test.requires_ext(extension="standard-attr-timestamp", service="network") |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 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']) |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 182 | |
| 183 | |
| 184 | class TestTimeStampWithL3(base_routers.BaseRouterTest): |
| 185 | @classmethod |
| 186 | def skip_checks(cls): |
| 187 | super(TestTimeStampWithL3, cls).skip_checks() |
| 188 | |
Kevin Benton | 6243f43 | 2016-09-09 06:20:40 -0700 | [diff] [blame] | 189 | if not test.is_extension_enabled('standard-attr-timestamp', 'network'): |
| 190 | raise cls.skipException("standard-attr-timestamp extension not " |
| 191 | "enabled") |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 192 | |
| 193 | @classmethod |
| 194 | def resource_setup(cls): |
| 195 | super(TestTimeStampWithL3, cls).resource_setup() |
| 196 | cls.ext_net_id = CONF.network.public_network_id |
| 197 | |
| 198 | @test.idempotent_id('433ba770-b310-4da9-5d42-733217a1c7b1') |
| 199 | def test_create_router_with_timestamp(self): |
| 200 | router = self.create_router(router_name='test') |
| 201 | # Verifies body contains timestamp fields |
| 202 | self.assertIsNotNone(router['created_at']) |
| 203 | self.assertIsNotNone(router['updated_at']) |
| 204 | |
| 205 | @test.idempotent_id('4a65417a-c11c-4b4d-a351-af01abcf57c6') |
| 206 | def test_update_router_with_timestamp(self): |
| 207 | router = self.create_router(router_name='test') |
| 208 | origin_updated_at = router['updated_at'] |
| 209 | update_body = {'name': router['name'] + 'new'} |
| 210 | body = self.client.update_router(router['id'], **update_body) |
| 211 | updated_router = body['router'] |
| 212 | new_updated_at = updated_router['updated_at'] |
| 213 | self.assertEqual(router['created_at'], updated_router['created_at']) |
| 214 | # Verify that origin_updated_at is not same with new_updated_at |
| 215 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 216 | |
| 217 | @test.idempotent_id('1ab50ac2-7cbd-4a17-b23e-a9e36cfa4ec2') |
| 218 | def test_show_router_attribute_with_timestamp(self): |
| 219 | router = self.create_router(router_name='test') |
| 220 | body = self.client.show_router(router['id']) |
| 221 | show_router = body['router'] |
| 222 | # verify the timestamp from creation and showed is same |
| 223 | self.assertEqual(router['created_at'], |
| 224 | show_router['created_at']) |
| 225 | self.assertEqual(router['updated_at'], |
| 226 | show_router['updated_at']) |
| 227 | |
| 228 | @test.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac') |
| 229 | def test_create_floatingip_with_timestamp(self): |
| 230 | fip = self.create_floatingip(self.ext_net_id) |
| 231 | # Verifies body contains timestamp fields |
| 232 | self.assertIsNotNone(fip['created_at']) |
| 233 | self.assertIsNotNone(fip['updated_at']) |
| 234 | |
| 235 | @test.idempotent_id('a3ac215a-61ac-13f9-9d3c-57c51f11afa1') |
| 236 | def test_update_floatingip_with_timestamp(self): |
| 237 | fip = self.create_floatingip(self.ext_net_id) |
| 238 | origin_updated_at = fip['updated_at'] |
| 239 | update_body = {'description': 'new'} |
| 240 | body = self.client.update_floatingip(fip['id'], **update_body) |
| 241 | updated_fip = body['floatingip'] |
| 242 | new_updated_at = updated_fip['updated_at'] |
| 243 | self.assertEqual(fip['created_at'], updated_fip['created_at']) |
| 244 | # Verify that origin_updated_at is not same with new_updated_at |
| 245 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 246 | |
| 247 | @test.idempotent_id('32a6a086-e1ef-413b-b13a-0cfe13ef051e') |
| 248 | def test_show_floatingip_attribute_with_timestamp(self): |
| 249 | fip = self.create_floatingip(self.ext_net_id) |
| 250 | body = self.client.show_floatingip(fip['id']) |
| 251 | show_fip = body['floatingip'] |
| 252 | # verify the timestamp from creation and showed is same |
| 253 | self.assertEqual(fip['created_at'], |
| 254 | show_fip['created_at']) |
| 255 | self.assertEqual(fip['updated_at'], |
| 256 | show_fip['updated_at']) |
| 257 | |
| 258 | |
| 259 | class TestTimeStampWithSecurityGroup(base_security_groups.BaseSecGroupTest): |
| 260 | @classmethod |
| 261 | def skip_checks(cls): |
| 262 | super(TestTimeStampWithSecurityGroup, cls).skip_checks() |
| 263 | |
Kevin Benton | 6243f43 | 2016-09-09 06:20:40 -0700 | [diff] [blame] | 264 | if not test.is_extension_enabled('standard-attr-timestamp', 'network'): |
| 265 | raise cls.skipException("standard-attr-timestamp extension not " |
| 266 | "enabled") |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 267 | |
| 268 | @classmethod |
| 269 | def resource_setup(cls): |
| 270 | super(TestTimeStampWithSecurityGroup, cls).resource_setup() |
| 271 | cls.ext_net_id = CONF.network.public_network_id |
| 272 | |
| 273 | @test.idempotent_id('a3150a7b-d31a-423a-abf3-45e71c97cbac') |
| 274 | def test_create_sg_with_timestamp(self): |
| 275 | sg, _ = self._create_security_group() |
| 276 | # Verifies body contains timestamp fields |
| 277 | self.assertIsNotNone(sg['security_group']['created_at']) |
| 278 | self.assertIsNotNone(sg['security_group']['updated_at']) |
| 279 | |
| 280 | @test.idempotent_id('432ae0d3-32b4-413e-a9b3-091ac76da31b') |
| 281 | def test_update_sg_with_timestamp(self): |
| 282 | sgc, _ = self._create_security_group() |
| 283 | sg = sgc['security_group'] |
| 284 | origin_updated_at = sg['updated_at'] |
| 285 | update_body = {'name': sg['name'] + 'new'} |
| 286 | body = self.client.update_security_group(sg['id'], **update_body) |
| 287 | updated_sg = body['security_group'] |
| 288 | new_updated_at = updated_sg['updated_at'] |
| 289 | self.assertEqual(sg['created_at'], updated_sg['created_at']) |
| 290 | # Verify that origin_updated_at is not same with new_updated_at |
| 291 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 292 | |
| 293 | @test.idempotent_id('521e6723-43d6-12a6-8c3d-f5042ad9fc32') |
| 294 | def test_show_sg_attribute_with_timestamp(self): |
| 295 | sg, _ = self._create_security_group() |
| 296 | body = self.client.show_security_group(sg['security_group']['id']) |
| 297 | show_sg = body['security_group'] |
| 298 | # verify the timestamp from creation and showed is same |
| 299 | self.assertEqual(sg['security_group']['created_at'], |
| 300 | show_sg['created_at']) |
| 301 | self.assertEqual(sg['security_group']['updated_at'], |
| 302 | show_sg['updated_at']) |
| 303 | |
| 304 | def _prepare_sgrule_test(self): |
| 305 | sg, _ = self._create_security_group() |
| 306 | sg_id = sg['security_group']['id'] |
| 307 | direction = 'ingress' |
| 308 | protocol = 'tcp' |
| 309 | port_range_min = 77 |
| 310 | port_range_max = 77 |
| 311 | rule_create_body = self.client.create_security_group_rule( |
| 312 | security_group_id=sg_id, |
| 313 | direction=direction, |
| 314 | ethertype=self.ethertype, |
| 315 | protocol=protocol, |
| 316 | port_range_min=port_range_min, |
| 317 | port_range_max=port_range_max, |
| 318 | remote_group_id=None, |
| 319 | remote_ip_prefix=None |
| 320 | ) |
| 321 | return rule_create_body['security_group_rule'] |
| 322 | |
| 323 | @test.idempotent_id('83e8bd32-43e0-a3f0-1af3-12a5733c653e') |
| 324 | def test_create_sgrule_with_timestamp(self): |
| 325 | sgrule = self._prepare_sgrule_test() |
| 326 | # Verifies body contains timestamp fields |
| 327 | self.assertIsNotNone(sgrule['created_at']) |
| 328 | self.assertIsNotNone(sgrule['updated_at']) |
| 329 | |
| 330 | @test.idempotent_id('143da0e6-ba17-43ad-b3d7-03aa759c3cb4') |
| 331 | def test_show_sgrule_attribute_with_timestamp(self): |
| 332 | sgrule = self._prepare_sgrule_test() |
| 333 | body = self.client.show_security_group_rule(sgrule['id']) |
| 334 | show_sgrule = body['security_group_rule'] |
| 335 | # verify the timestamp from creation and showed is same |
| 336 | self.assertEqual(sgrule['created_at'], show_sgrule['created_at']) |
| 337 | self.assertEqual(sgrule['updated_at'], show_sgrule['updated_at']) |