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 |
Kevin Benton | b944fcb | 2016-09-02 00:26:42 -0600 | [diff] [blame] | 23 | @test.requires_ext(extension="standard-attr-revisions", service="network") |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 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() |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 30 | self.assertIn('revision_number', net) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 31 | updated = self.client.update_network(net['id'], name='newnet') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 32 | self.assertGreater(updated['network']['revision_number'], |
| 33 | net['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 34 | |
| 35 | @test.idempotent_id('cac7ecde-12d5-4331-9a03-420899dea077') |
| 36 | def test_update_port_bumps_revision(self): |
| 37 | net = self.create_network() |
| 38 | port = self.create_port(net) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 39 | self.assertIn('revision_number', port) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 40 | updated = self.client.update_port(port['id'], name='newport') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 41 | self.assertGreater(updated['port']['revision_number'], |
| 42 | port['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 43 | |
| 44 | @test.idempotent_id('c1c4fa41-8e89-44d0-9bfc-409f3b66dc57') |
| 45 | def test_update_subnet_bumps_revision(self): |
| 46 | net = self.create_network() |
| 47 | subnet = self.create_subnet(net) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 48 | self.assertIn('revision_number', subnet) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 49 | updated = self.client.update_subnet(subnet['id'], name='newsub') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 50 | self.assertGreater(updated['subnet']['revision_number'], |
| 51 | subnet['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 52 | |
| 53 | @test.idempotent_id('e8c5d7db-2b8d-4615-a476-6e537437c4f2') |
| 54 | def test_update_subnetpool_bumps_revision(self): |
| 55 | sp = self.create_subnetpool('subnetpool', default_prefixlen=24, |
| 56 | prefixes=['10.0.0.0/8']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 57 | self.assertIn('revision_number', sp) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 58 | updated = self.admin_client.update_subnetpool(sp['id'], name='sp2') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 59 | self.assertGreater(updated['subnetpool']['revision_number'], |
| 60 | sp['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 61 | |
Nam Nguyen Hoai | 2984b6d | 2016-08-05 09:46:43 +0700 | [diff] [blame] | 62 | @test.idempotent_id('e8c5d7db-2b8d-4567-a326-6e123437c4d1') |
| 63 | def test_update_subnet_bumps_network_revision(self): |
| 64 | net = self.create_network() |
| 65 | subnet = self.create_subnet(net) |
| 66 | updated = self.client.show_network(net['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 67 | self.assertGreater(updated['network']['revision_number'], |
| 68 | net['revision_number']) |
Nam Nguyen Hoai | 2984b6d | 2016-08-05 09:46:43 +0700 | [diff] [blame] | 69 | self.client.delete_subnet(subnet['id']) |
| 70 | updated2 = self.client.show_network(net['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 71 | self.assertGreater(updated2['network']['revision_number'], |
| 72 | updated['network']['revision_number']) |
Nam Nguyen Hoai | 2984b6d | 2016-08-05 09:46:43 +0700 | [diff] [blame] | 73 | |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 74 | @test.idempotent_id('6c256f71-c929-4200-b3dc-4e1843506be5') |
| 75 | @test.requires_ext(extension="security-group", service="network") |
| 76 | def test_update_sg_group_bumps_revision(self): |
| 77 | sg, name = self._create_security_group() |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 78 | self.assertIn('revision_number', sg['security_group']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 79 | update_body = self.client.update_security_group( |
| 80 | sg['security_group']['id'], name='new_sg_name') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 81 | self.assertGreater(update_body['security_group']['revision_number'], |
| 82 | sg['security_group']['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 83 | |
| 84 | @test.idempotent_id('6489632f-8550-4453-a674-c98849742967') |
| 85 | @test.requires_ext(extension="security-group", service="network") |
| 86 | def test_update_port_sg_binding_bumps_revision(self): |
| 87 | net = self.create_network() |
| 88 | port = self.create_port(net) |
| 89 | sg = self._create_security_group()[0] |
| 90 | self.client.update_port( |
| 91 | port['id'], security_groups=[sg['security_group']['id']]) |
| 92 | updated = self.client.show_port(port['id']) |
| 93 | self.client.update_port(port['id'], security_groups=[]) |
| 94 | # TODO(kevinbenton): these extra shows after after the update are |
| 95 | # to work around the fact that ML2 creates the result dict before |
| 96 | # commit happens if the port is unbound. The update response should |
| 97 | # be usable directly once that is fixed. |
| 98 | updated2 = self.client.show_port(port['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 99 | self.assertGreater(updated['port']['revision_number'], |
| 100 | port['revision_number']) |
| 101 | self.assertGreater(updated2['port']['revision_number'], |
| 102 | updated['port']['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 103 | |
| 104 | @test.idempotent_id('29c7ab2b-d1d8-425d-8cec-fcf632960f22') |
| 105 | @test.requires_ext(extension="security-group", service="network") |
| 106 | def test_update_sg_rule_bumps_sg_revision(self): |
| 107 | sg, name = self._create_security_group() |
| 108 | rule = self.client.create_security_group_rule( |
| 109 | security_group_id=sg['security_group']['id'], |
| 110 | protocol='tcp', direction='ingress', ethertype=self.ethertype, |
| 111 | port_range_min=60, port_range_max=70) |
| 112 | updated = self.client.show_security_group(sg['security_group']['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 113 | self.assertGreater(updated['security_group']['revision_number'], |
| 114 | sg['security_group']['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 115 | self.client.delete_security_group_rule( |
| 116 | rule['security_group_rule']['id']) |
| 117 | updated2 = self.client.show_security_group(sg['security_group']['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 118 | self.assertGreater(updated2['security_group']['revision_number'], |
| 119 | updated['security_group']['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 120 | |
| 121 | @test.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0') |
| 122 | @test.requires_ext(extension="router", service="network") |
| 123 | def test_update_router_bumps_revision(self): |
| 124 | subnet = self.create_subnet(self.create_network()) |
| 125 | router = self.create_router(router_name='test') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 126 | self.assertIn('revision_number', router) |
| 127 | rev1 = router['revision_number'] |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 128 | router = self.client.update_router(router['id'], |
| 129 | name='test2')['router'] |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 130 | self.assertGreater(router['revision_number'], rev1) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 131 | self.create_router_interface(router['id'], subnet['id']) |
| 132 | updated = self.client.show_router(router['id'])['router'] |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 133 | self.assertGreater(updated['revision_number'], |
| 134 | router['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 135 | |
| 136 | @test.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9') |
| 137 | @test.requires_ext(extension="router", service="network") |
| 138 | @test.requires_ext(extension="standard-attr-description", |
| 139 | service="network") |
| 140 | def test_update_floatingip_bumps_revision(self): |
| 141 | ext_id = config.CONF.network.public_network_id |
| 142 | network = self.create_network() |
| 143 | subnet = self.create_subnet(network) |
| 144 | router = self.create_router('test', external_network_id=ext_id) |
| 145 | self.create_router_interface(router['id'], subnet['id']) |
| 146 | port = self.create_port(network) |
| 147 | body = self.client.create_floatingip( |
| 148 | floating_network_id=ext_id, |
| 149 | port_id=port['id'], |
| 150 | description='d1' |
| 151 | )['floatingip'] |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 152 | self.assertIn('revision_number', body) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 153 | b2 = self.client.update_floatingip(body['id'], description='d2') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 154 | self.assertGreater(b2['floatingip']['revision_number'], |
| 155 | body['revision_number']) |
LIU Yulong | 39e5f10 | 2016-05-05 14:52:26 +0800 | [diff] [blame] | 156 | # disassociate |
| 157 | self.client.update_floatingip(b2['floatingip']['id'], port_id=None) |