Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [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 | from tempest import test |
| 14 | |
| 15 | from neutron.tests.tempest.api import base |
| 16 | from neutron.tests.tempest.api import base_security_groups as bsg |
| 17 | from neutron.tests.tempest import config |
| 18 | |
| 19 | |
| 20 | class TestRevisions(base.BaseAdminNetworkTest, bsg.BaseSecGroupTest): |
| 21 | |
| 22 | @classmethod |
| 23 | @test.requires_ext(extension="revisions", service="network") |
| 24 | def skip_checks(cls): |
| 25 | super(TestRevisions, cls).skip_checks() |
| 26 | |
| 27 | @test.idempotent_id('4a26a4be-9c53-483c-bc50-b53f1db10ac6') |
| 28 | def test_update_network_bumps_revision(self): |
| 29 | net = self.create_network() |
| 30 | self.assertIn('revision', net) |
| 31 | updated = self.client.update_network(net['id'], name='newnet') |
| 32 | self.assertGreater(updated['network']['revision'], net['revision']) |
| 33 | |
| 34 | @test.idempotent_id('cac7ecde-12d5-4331-9a03-420899dea077') |
| 35 | def test_update_port_bumps_revision(self): |
| 36 | net = self.create_network() |
| 37 | port = self.create_port(net) |
| 38 | self.assertIn('revision', port) |
| 39 | updated = self.client.update_port(port['id'], name='newport') |
| 40 | self.assertGreater(updated['port']['revision'], port['revision']) |
| 41 | |
| 42 | @test.idempotent_id('c1c4fa41-8e89-44d0-9bfc-409f3b66dc57') |
| 43 | def test_update_subnet_bumps_revision(self): |
| 44 | net = self.create_network() |
| 45 | subnet = self.create_subnet(net) |
| 46 | self.assertIn('revision', subnet) |
| 47 | updated = self.client.update_subnet(subnet['id'], name='newsub') |
| 48 | self.assertGreater(updated['subnet']['revision'], subnet['revision']) |
| 49 | |
| 50 | @test.idempotent_id('e8c5d7db-2b8d-4615-a476-6e537437c4f2') |
| 51 | def test_update_subnetpool_bumps_revision(self): |
| 52 | sp = self.create_subnetpool('subnetpool', default_prefixlen=24, |
| 53 | prefixes=['10.0.0.0/8']) |
| 54 | self.assertIn('revision', sp) |
| 55 | updated = self.admin_client.update_subnetpool(sp['id'], name='sp2') |
| 56 | self.assertGreater(updated['subnetpool']['revision'], sp['revision']) |
| 57 | |
| 58 | @test.idempotent_id('6c256f71-c929-4200-b3dc-4e1843506be5') |
| 59 | @test.requires_ext(extension="security-group", service="network") |
| 60 | def test_update_sg_group_bumps_revision(self): |
| 61 | sg, name = self._create_security_group() |
| 62 | self.assertIn('revision', sg['security_group']) |
| 63 | update_body = self.client.update_security_group( |
| 64 | sg['security_group']['id'], name='new_sg_name') |
| 65 | self.assertGreater(update_body['security_group']['revision'], |
| 66 | sg['security_group']['revision']) |
| 67 | |
| 68 | @test.idempotent_id('6489632f-8550-4453-a674-c98849742967') |
| 69 | @test.requires_ext(extension="security-group", service="network") |
| 70 | def test_update_port_sg_binding_bumps_revision(self): |
| 71 | net = self.create_network() |
| 72 | port = self.create_port(net) |
| 73 | sg = self._create_security_group()[0] |
| 74 | self.client.update_port( |
| 75 | port['id'], security_groups=[sg['security_group']['id']]) |
| 76 | updated = self.client.show_port(port['id']) |
| 77 | self.client.update_port(port['id'], security_groups=[]) |
| 78 | # TODO(kevinbenton): these extra shows after after the update are |
| 79 | # to work around the fact that ML2 creates the result dict before |
| 80 | # commit happens if the port is unbound. The update response should |
| 81 | # be usable directly once that is fixed. |
| 82 | updated2 = self.client.show_port(port['id']) |
| 83 | self.assertGreater(updated['port']['revision'], port['revision']) |
| 84 | self.assertGreater(updated2['port']['revision'], |
| 85 | updated['port']['revision']) |
| 86 | |
| 87 | @test.idempotent_id('29c7ab2b-d1d8-425d-8cec-fcf632960f22') |
| 88 | @test.requires_ext(extension="security-group", service="network") |
| 89 | def test_update_sg_rule_bumps_sg_revision(self): |
| 90 | sg, name = self._create_security_group() |
| 91 | rule = self.client.create_security_group_rule( |
| 92 | security_group_id=sg['security_group']['id'], |
| 93 | protocol='tcp', direction='ingress', ethertype=self.ethertype, |
| 94 | port_range_min=60, port_range_max=70) |
| 95 | updated = self.client.show_security_group(sg['security_group']['id']) |
| 96 | self.assertGreater(updated['security_group']['revision'], |
| 97 | sg['security_group']['revision']) |
| 98 | self.client.delete_security_group_rule( |
| 99 | rule['security_group_rule']['id']) |
| 100 | updated2 = self.client.show_security_group(sg['security_group']['id']) |
| 101 | self.assertGreater(updated2['security_group']['revision'], |
| 102 | updated['security_group']['revision']) |
| 103 | |
| 104 | @test.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0') |
| 105 | @test.requires_ext(extension="router", service="network") |
| 106 | def test_update_router_bumps_revision(self): |
| 107 | subnet = self.create_subnet(self.create_network()) |
| 108 | router = self.create_router(router_name='test') |
| 109 | self.assertIn('revision', router) |
| 110 | rev1 = router['revision'] |
| 111 | router = self.client.update_router(router['id'], |
| 112 | name='test2')['router'] |
| 113 | self.assertGreater(router['revision'], rev1) |
| 114 | self.create_router_interface(router['id'], subnet['id']) |
| 115 | updated = self.client.show_router(router['id'])['router'] |
| 116 | self.assertGreater(updated['revision'], router['revision']) |
| 117 | |
| 118 | @test.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9') |
| 119 | @test.requires_ext(extension="router", service="network") |
| 120 | @test.requires_ext(extension="standard-attr-description", |
| 121 | service="network") |
| 122 | def test_update_floatingip_bumps_revision(self): |
| 123 | ext_id = config.CONF.network.public_network_id |
| 124 | network = self.create_network() |
| 125 | subnet = self.create_subnet(network) |
| 126 | router = self.create_router('test', external_network_id=ext_id) |
| 127 | self.create_router_interface(router['id'], subnet['id']) |
| 128 | port = self.create_port(network) |
| 129 | body = self.client.create_floatingip( |
| 130 | floating_network_id=ext_id, |
| 131 | port_id=port['id'], |
| 132 | description='d1' |
| 133 | )['floatingip'] |
| 134 | self.assertIn('revision', body) |
| 135 | b2 = self.client.update_floatingip(body['id'], description='d2') |
| 136 | self.assertGreater(b2['floatingip']['revision'], body['revision']) |