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 | |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 13 | import netaddr |
| 14 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 15 | from tempest.lib import decorators |
Kevin Benton | 2d745ae | 2016-12-11 18:24:01 -0800 | [diff] [blame] | 16 | from tempest.lib import exceptions |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 17 | from tempest import test |
| 18 | |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 19 | from neutron_tempest_plugin.api import base |
| 20 | from neutron_tempest_plugin.api import base_security_groups as bsg |
| 21 | from neutron_tempest_plugin import config |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 22 | |
| 23 | |
| 24 | class TestRevisions(base.BaseAdminNetworkTest, bsg.BaseSecGroupTest): |
| 25 | |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 26 | required_extensions = ['standard-attr-revisions'] |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 27 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 28 | @decorators.idempotent_id('4a26a4be-9c53-483c-bc50-b53f1db10ac6') |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 29 | def test_update_network_bumps_revision(self): |
| 30 | net = self.create_network() |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 31 | self.addCleanup(self.client.delete_network, net['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 32 | self.assertIn('revision_number', net) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 33 | updated = self.client.update_network(net['id'], name='newnet') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 34 | self.assertGreater(updated['network']['revision_number'], |
| 35 | net['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 36 | |
Kevin Benton | 2d745ae | 2016-12-11 18:24:01 -0800 | [diff] [blame] | 37 | @decorators.idempotent_id('4a26a4be-9c53-483c-bc50-b11111113333') |
| 38 | def test_update_network_constrained_by_revision(self): |
| 39 | net = self.create_network() |
| 40 | current = net['revision_number'] |
| 41 | stale = current - 1 |
| 42 | # using a stale number should fail |
| 43 | self.assertRaises( |
| 44 | exceptions.PreconditionFailed, |
| 45 | self.client.update_network, |
| 46 | net['id'], name='newnet', |
| 47 | headers={'If-Match': 'revision_number=%s' % stale} |
| 48 | ) |
| 49 | |
| 50 | # using current should pass. in case something is updating the network |
| 51 | # on the server at the same time, we have to re-read and update to be |
| 52 | # safe |
| 53 | for i in range(100): |
| 54 | current = (self.client.show_network(net['id']) |
| 55 | ['network']['revision_number']) |
| 56 | try: |
| 57 | self.client.update_network( |
| 58 | net['id'], name='newnet', |
| 59 | headers={'If-Match': 'revision_number=%s' % current}) |
| 60 | except exceptions.UnexpectedResponseCode: |
| 61 | continue |
| 62 | break |
| 63 | else: |
| 64 | self.fail("Failed to update network after 100 tries.") |
| 65 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 66 | @decorators.idempotent_id('cac7ecde-12d5-4331-9a03-420899dea077') |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 67 | def test_update_port_bumps_revision(self): |
| 68 | net = self.create_network() |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 69 | self.addCleanup(self.client.delete_network, net['id']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 70 | port = self.create_port(net) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 71 | self.addCleanup(self.client.delete_port, port['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 72 | self.assertIn('revision_number', port) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 73 | updated = self.client.update_port(port['id'], name='newport') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 74 | self.assertGreater(updated['port']['revision_number'], |
| 75 | port['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 76 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 77 | @decorators.idempotent_id('c1c4fa41-8e89-44d0-9bfc-409f3b66dc57') |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 78 | def test_update_subnet_bumps_revision(self): |
| 79 | net = self.create_network() |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 80 | self.addCleanup(self.client.delete_network, net['id']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 81 | subnet = self.create_subnet(net) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 82 | self.addCleanup(self.client.delete_subnet, subnet['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 83 | self.assertIn('revision_number', subnet) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 84 | updated = self.client.update_subnet(subnet['id'], name='newsub') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 85 | self.assertGreater(updated['subnet']['revision_number'], |
| 86 | subnet['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 87 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 88 | @decorators.idempotent_id('e8c5d7db-2b8d-4615-a476-6e537437c4f2') |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 89 | def test_update_subnetpool_bumps_revision(self): |
| 90 | sp = self.create_subnetpool('subnetpool', default_prefixlen=24, |
| 91 | prefixes=['10.0.0.0/8']) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 92 | self.addCleanup(self.client.delete_subnetpool, sp['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 93 | self.assertIn('revision_number', sp) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 94 | updated = self.admin_client.update_subnetpool(sp['id'], name='sp2') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 95 | self.assertGreater(updated['subnetpool']['revision_number'], |
| 96 | sp['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 97 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 98 | @decorators.idempotent_id('e8c5d7db-2b8d-4567-a326-6e123437c4d1') |
Nam Nguyen Hoai | 2984b6d | 2016-08-05 09:46:43 +0700 | [diff] [blame] | 99 | def test_update_subnet_bumps_network_revision(self): |
| 100 | net = self.create_network() |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 101 | self.addCleanup(self.client.delete_network, net['id']) |
Nam Nguyen Hoai | 2984b6d | 2016-08-05 09:46:43 +0700 | [diff] [blame] | 102 | subnet = self.create_subnet(net) |
| 103 | updated = self.client.show_network(net['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 104 | self.assertGreater(updated['network']['revision_number'], |
| 105 | net['revision_number']) |
Nam Nguyen Hoai | 2984b6d | 2016-08-05 09:46:43 +0700 | [diff] [blame] | 106 | self.client.delete_subnet(subnet['id']) |
| 107 | updated2 = self.client.show_network(net['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 108 | self.assertGreater(updated2['network']['revision_number'], |
| 109 | updated['network']['revision_number']) |
Nam Nguyen Hoai | 2984b6d | 2016-08-05 09:46:43 +0700 | [diff] [blame] | 110 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 111 | @decorators.idempotent_id('6c256f71-c929-4200-b3dc-4e1843506be5') |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 112 | @test.requires_ext(extension="security-group", service="network") |
| 113 | def test_update_sg_group_bumps_revision(self): |
| 114 | sg, name = self._create_security_group() |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 115 | self.assertIn('revision_number', sg['security_group']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 116 | update_body = self.client.update_security_group( |
| 117 | sg['security_group']['id'], name='new_sg_name') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 118 | self.assertGreater(update_body['security_group']['revision_number'], |
| 119 | sg['security_group']['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 120 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 121 | @decorators.idempotent_id('6489632f-8550-4453-a674-c98849742967') |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 122 | @test.requires_ext(extension="security-group", service="network") |
| 123 | def test_update_port_sg_binding_bumps_revision(self): |
| 124 | net = self.create_network() |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 125 | self.addCleanup(self.client.delete_network, net['id']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 126 | port = self.create_port(net) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 127 | self.addCleanup(self.client.delete_port, port['id']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 128 | sg = self._create_security_group()[0] |
| 129 | self.client.update_port( |
| 130 | port['id'], security_groups=[sg['security_group']['id']]) |
| 131 | updated = self.client.show_port(port['id']) |
Kevin Benton | a2bd97b | 2016-09-19 20:05:25 -0700 | [diff] [blame] | 132 | updated2 = self.client.update_port(port['id'], security_groups=[]) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 133 | self.assertGreater(updated['port']['revision_number'], |
| 134 | port['revision_number']) |
| 135 | self.assertGreater(updated2['port']['revision_number'], |
| 136 | updated['port']['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 137 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 138 | @decorators.idempotent_id('29c7ab2b-d1d8-425d-8cec-fcf632960f22') |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 139 | @test.requires_ext(extension="security-group", service="network") |
| 140 | def test_update_sg_rule_bumps_sg_revision(self): |
| 141 | sg, name = self._create_security_group() |
| 142 | rule = self.client.create_security_group_rule( |
| 143 | security_group_id=sg['security_group']['id'], |
| 144 | protocol='tcp', direction='ingress', ethertype=self.ethertype, |
| 145 | port_range_min=60, port_range_max=70) |
| 146 | updated = self.client.show_security_group(sg['security_group']['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 147 | self.assertGreater(updated['security_group']['revision_number'], |
| 148 | sg['security_group']['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 149 | self.client.delete_security_group_rule( |
| 150 | rule['security_group_rule']['id']) |
| 151 | updated2 = self.client.show_security_group(sg['security_group']['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 152 | self.assertGreater(updated2['security_group']['revision_number'], |
| 153 | updated['security_group']['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 154 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 155 | @decorators.idempotent_id('db70c285-0365-4fac-9f55-2a0ad8cf55a8') |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 156 | @test.requires_ext(extension="allowed-address-pairs", service="network") |
| 157 | def test_update_allowed_address_pairs_bumps_revision(self): |
| 158 | net = self.create_network() |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 159 | self.addCleanup(self.client.delete_network, net['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 160 | port = self.create_port(net) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 161 | self.addCleanup(self.client.delete_port, port['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 162 | updated = self.client.update_port( |
| 163 | port['id'], allowed_address_pairs=[{'ip_address': '1.1.1.1/32'}]) |
| 164 | self.assertGreater(updated['port']['revision_number'], |
| 165 | port['revision_number']) |
| 166 | updated2 = self.client.update_port( |
| 167 | port['id'], allowed_address_pairs=[]) |
| 168 | self.assertGreater(updated2['port']['revision_number'], |
| 169 | updated['port']['revision_number']) |
| 170 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 171 | @decorators.idempotent_id('a21ec3b4-3569-4b77-bf29-4177edaa2df5') |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 172 | @test.requires_ext(extension="extra_dhcp_opt", service="network") |
| 173 | def test_update_extra_dhcp_opt_bumps_revision(self): |
| 174 | net = self.create_network() |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 175 | self.addCleanup(self.client.delete_network, net['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 176 | port = self.create_port(net) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 177 | self.addCleanup(self.client.delete_port, port['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 178 | opts = [{'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'}] |
| 179 | updated = self.client.update_port(port['id'], extra_dhcp_opts=opts) |
| 180 | self.assertGreater(updated['port']['revision_number'], |
| 181 | port['revision_number']) |
| 182 | opts[0]['opt_value'] = 'pxelinux.77' |
| 183 | updated2 = self.client.update_port( |
| 184 | port['id'], extra_dhcp_opts=opts) |
| 185 | self.assertGreater(updated2['port']['revision_number'], |
| 186 | updated['port']['revision_number']) |
| 187 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 188 | @decorators.idempotent_id('40ba648f-f374-4c29-a5b7-489dd5a38a4e') |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 189 | @test.requires_ext(extension="dns-integration", service="network") |
| 190 | def test_update_dns_domain_bumps_revision(self): |
| 191 | net = self.create_network(dns_domain='example.test.') |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 192 | self.addCleanup(self.client.delete_network, net['id']) |
Kevin Benton | f46e7a2 | 2016-09-24 23:07:45 -0700 | [diff] [blame] | 193 | updated = self.client.update_network(net['id'], dns_domain='exa.test.') |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 194 | self.assertGreater(updated['network']['revision_number'], |
| 195 | net['revision_number']) |
| 196 | port = self.create_port(net) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 197 | self.addCleanup(self.client.delete_port, port['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 198 | updated = self.client.update_port(port['id'], dns_name='port1') |
| 199 | if not updated['port']['dns_name']: |
| 200 | self.skipTest("Server does not have DNS domain configured.") |
| 201 | self.assertGreater(updated['port']['revision_number'], |
| 202 | port['revision_number']) |
| 203 | updated2 = self.client.update_port(port['id'], dns_name='') |
| 204 | self.assertGreater(updated2['port']['revision_number'], |
| 205 | updated['port']['revision_number']) |
| 206 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 207 | @decorators.idempotent_id('8482324f-cf59-4d73-b98e-d37119255300') |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 208 | @test.requires_ext(extension="router", service="network") |
| 209 | @test.requires_ext(extension="extraroute", service="network") |
| 210 | def test_update_router_extra_routes_bumps_revision(self): |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 211 | net = self.create_network() |
| 212 | self.addCleanup(self.client.delete_network, net['id']) |
| 213 | subnet = self.create_subnet(net) |
| 214 | self.addCleanup(self.client.delete_subnet, subnet['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 215 | subgateway = netaddr.IPAddress(subnet['gateway_ip']) |
| 216 | router = self.create_router(router_name='test') |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 217 | self.addCleanup(self.client.delete_router, router['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 218 | self.create_router_interface(router['id'], subnet['id']) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 219 | self.addCleanup( |
| 220 | self.client.remove_router_interface_with_subnet_id, |
| 221 | router['id'], |
| 222 | subnet['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 223 | router = self.client.show_router(router['id'])['router'] |
Omer Anson | d158683 | 2016-10-10 22:46:32 +0300 | [diff] [blame] | 224 | updated = self.client.update_extra_routes( |
| 225 | router['id'], str(subgateway + 1), '2.0.0.0/24') |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 226 | self.assertGreater(updated['router']['revision_number'], |
| 227 | router['revision_number']) |
Omer Anson | d158683 | 2016-10-10 22:46:32 +0300 | [diff] [blame] | 228 | updated2 = self.client.delete_extra_routes(router['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 229 | self.assertGreater(updated2['router']['revision_number'], |
| 230 | updated['router']['revision_number']) |
| 231 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 232 | @decorators.idempotent_id('6bd18702-e25a-4b4b-8c0c-680113533511') |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 233 | @test.requires_ext(extension="subnet-service-types", service="network") |
| 234 | def test_update_subnet_service_types_bumps_revisions(self): |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 235 | net = self.create_network() |
| 236 | self.addCleanup(self.client.delete_network, net['id']) |
| 237 | subnet = self.create_subnet(net) |
| 238 | self.addCleanup(self.client.delete_subnet, subnet['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 239 | updated = self.client.update_subnet( |
| 240 | subnet['id'], service_types=['compute:']) |
| 241 | self.assertGreater(updated['subnet']['revision_number'], |
| 242 | subnet['revision_number']) |
| 243 | updated2 = self.client.update_subnet( |
| 244 | subnet['id'], service_types=[]) |
| 245 | self.assertGreater(updated2['subnet']['revision_number'], |
| 246 | updated['subnet']['revision_number']) |
| 247 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 248 | @decorators.idempotent_id('9c83105c-9973-45ff-9ca2-e66d64700abe') |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 249 | @test.requires_ext(extension="port-security", service="network") |
| 250 | def test_update_port_security_bumps_revisions(self): |
| 251 | net = self.create_network(port_security_enabled=False) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 252 | self.addCleanup(self.client.delete_network, net['id']) |
Kevin Benton | f46e7a2 | 2016-09-24 23:07:45 -0700 | [diff] [blame] | 253 | updated = self.client.update_network(net['id'], |
| 254 | port_security_enabled=True) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 255 | self.assertGreater(updated['network']['revision_number'], |
| 256 | net['revision_number']) |
Kevin Benton | f46e7a2 | 2016-09-24 23:07:45 -0700 | [diff] [blame] | 257 | updated2 = self.client.update_network(net['id'], |
| 258 | port_security_enabled=False) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 259 | self.assertGreater(updated2['network']['revision_number'], |
| 260 | updated['network']['revision_number']) |
| 261 | port = self.create_port(net, port_security_enabled=False) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 262 | self.addCleanup(self.client.delete_port, port['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 263 | updated = self.client.update_port(port['id'], |
| 264 | port_security_enabled=True) |
| 265 | self.assertGreater(updated['port']['revision_number'], |
| 266 | port['revision_number']) |
| 267 | updated2 = self.client.update_port(port['id'], |
| 268 | port_security_enabled=False) |
| 269 | self.assertGreater(updated2['port']['revision_number'], |
| 270 | updated['port']['revision_number']) |
| 271 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 272 | @decorators.idempotent_id('68d5ac3a-11a1-4847-8e2e-5843c043d89b') |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 273 | @test.requires_ext(extension="binding", service="network") |
| 274 | def test_portbinding_bumps_revision(self): |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 275 | net = self.create_network() |
| 276 | self.addCleanup(self.client.delete_network, net['id']) |
| 277 | port = self.create_port(net) |
| 278 | self.addCleanup(self.client.delete_port, port['id']) |
Kevin Benton | a2ceb2d | 2016-09-22 17:52:25 -0700 | [diff] [blame] | 279 | port = self.admin_client.update_port( |
| 280 | port['id'], **{'binding:host_id': 'badhost1'})['port'] |
| 281 | updated = self.admin_client.update_port( |
| 282 | port['id'], **{'binding:host_id': 'badhost2'})['port'] |
| 283 | self.assertGreater(updated['revision_number'], |
| 284 | port['revision_number']) |
| 285 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 286 | @decorators.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0') |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 287 | @test.requires_ext(extension="router", service="network") |
| 288 | def test_update_router_bumps_revision(self): |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 289 | net = self.create_network() |
| 290 | self.addCleanup(self.client.delete_network, net['id']) |
| 291 | subnet = self.create_subnet(net) |
| 292 | self.addCleanup(self.client.delete_subnet, subnet['id']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 293 | router = self.create_router(router_name='test') |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 294 | self.addCleanup(self.client.delete_router, router['id']) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 295 | self.assertIn('revision_number', router) |
| 296 | rev1 = router['revision_number'] |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 297 | router = self.client.update_router(router['id'], |
| 298 | name='test2')['router'] |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 299 | self.assertGreater(router['revision_number'], rev1) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 300 | self.create_router_interface(router['id'], subnet['id']) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 301 | self.addCleanup( |
| 302 | self.client.remove_router_interface_with_subnet_id, |
| 303 | router['id'], |
| 304 | subnet['id']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 305 | updated = self.client.show_router(router['id'])['router'] |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 306 | self.assertGreater(updated['revision_number'], |
| 307 | router['revision_number']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 308 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 309 | @decorators.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9') |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 310 | @test.requires_ext(extension="router", service="network") |
| 311 | @test.requires_ext(extension="standard-attr-description", |
| 312 | service="network") |
| 313 | def test_update_floatingip_bumps_revision(self): |
| 314 | ext_id = config.CONF.network.public_network_id |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 315 | net = self.create_network() |
| 316 | self.addCleanup(self.client.delete_network, net['id']) |
| 317 | subnet = self.create_subnet(net) |
| 318 | self.addCleanup(self.client.delete_subnet, subnet['id']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 319 | router = self.create_router('test', external_network_id=ext_id) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 320 | self.addCleanup(self.client.delete_router, router['id']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 321 | self.create_router_interface(router['id'], subnet['id']) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 322 | self.addCleanup( |
| 323 | self.client.remove_router_interface_with_subnet_id, |
| 324 | router['id'], |
| 325 | subnet['id']) |
| 326 | port = self.create_port(net) |
| 327 | self.addCleanup(self.client.delete_port, port['id']) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 328 | body = self.client.create_floatingip( |
| 329 | floating_network_id=ext_id, |
| 330 | port_id=port['id'], |
| 331 | description='d1' |
| 332 | )['floatingip'] |
Itzik Brown | a3926d9 | 2017-02-12 02:49:29 +0200 | [diff] [blame] | 333 | self.floating_ips.append(body) |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 334 | self.assertIn('revision_number', body) |
Kevin Benton | 183b7be | 2016-03-24 22:14:58 -0700 | [diff] [blame] | 335 | b2 = self.client.update_floatingip(body['id'], description='d2') |
Kevin Benton | 2f06790 | 2016-09-02 17:14:37 -0700 | [diff] [blame] | 336 | self.assertGreater(b2['floatingip']['revision_number'], |
| 337 | body['revision_number']) |
LIU Yulong | 39e5f10 | 2016-05-05 14:52:26 +0800 | [diff] [blame] | 338 | # disassociate |
| 339 | self.client.update_floatingip(b2['floatingip']['id'], port_id=None) |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 340 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 341 | @decorators.idempotent_id('afb6486c-41b5-483e-a500-3c506f4deb49') |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 342 | @test.requires_ext(extension="router", service="network") |
Brian Haley | 5ae5a2e | 2017-05-05 11:32:07 -0400 | [diff] [blame] | 343 | @test.requires_ext(extension="l3-ha", service="network") |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 344 | def test_update_router_extra_attributes_bumps_revision(self): |
Brian Haley | 5ae5a2e | 2017-05-05 11:32:07 -0400 | [diff] [blame] | 345 | # updates from CVR to CVR-HA are supported on every release, |
| 346 | # but only the admin can forcibly create a non-HA router |
| 347 | router_args = {'tenant_id': self.client.tenant_id, |
| 348 | 'ha': False} |
| 349 | router = self.admin_client.create_router('r1', True, |
| 350 | **router_args)['router'] |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 351 | self.addCleanup(self.client.delete_router, router['id']) |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 352 | self.assertIn('revision_number', router) |
| 353 | rev1 = router['revision_number'] |
| 354 | router = self.admin_client.update_router( |
| 355 | router['id'], admin_state_up=False)['router'] |
| 356 | self.assertGreater(router['revision_number'], rev1) |
Brian Haley | 5ae5a2e | 2017-05-05 11:32:07 -0400 | [diff] [blame] | 357 | self.admin_client.update_router(router['id'], ha=True)['router'] |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 358 | updated = self.client.show_router(router['id'])['router'] |
| 359 | self.assertGreater(updated['revision_number'], |
| 360 | router['revision_number']) |
| 361 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 362 | @decorators.idempotent_id('90743b00-b0e2-40e4-9524-1c884fe3ef23') |
Kevin Benton | 3e30597 | 2016-12-28 02:05:29 -0800 | [diff] [blame] | 363 | @test.requires_ext(extension="external-net", service="network") |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 364 | @test.requires_ext(extension="auto-allocated-topology", service="network") |
| 365 | @test.requires_ext(extension="subnet_allocation", service="network") |
| 366 | @test.requires_ext(extension="router", service="network") |
| 367 | def test_update_external_network_bumps_revision(self): |
| 368 | net = self.create_network() |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 369 | self.addCleanup(self.client.delete_network, net['id']) |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 370 | self.assertIn('revision_number', net) |
| 371 | updated = self.admin_client.update_network(net['id'], |
| 372 | **{'router:external': True}) |
| 373 | self.assertGreater(updated['network']['revision_number'], |
| 374 | net['revision_number']) |
| 375 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 376 | @decorators.idempotent_id('5af6450a-0f61-49c3-b628-38db77c7b856') |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 377 | @test.requires_ext(extension="qos", service="network") |
| 378 | def test_update_qos_port_policy_binding_bumps_revision(self): |
| 379 | policy = self.create_qos_policy(name='port-policy', shared=False) |
Prateek Arora | ebc2514 | 2017-03-27 11:30:47 -0400 | [diff] [blame] | 380 | net = self.create_network() |
| 381 | self.addCleanup(self.client.delete_network, net['id']) |
| 382 | port = self.create_port(net) |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 383 | self.addCleanup(self.client.delete_port, port['id']) |
| 384 | updated = self.admin_client.update_port( |
| 385 | port['id'], qos_policy_id=policy['id']) |
| 386 | self.assertGreater(updated['port']['revision_number'], |
| 387 | port['revision_number']) |
| 388 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 389 | @decorators.idempotent_id('817da343-c6e4-445c-9519-a621f124dfbe') |
Lujin | ba9a492 | 2016-11-21 18:19:04 +0900 | [diff] [blame] | 390 | @test.requires_ext(extension="qos", service="network") |
| 391 | def test_update_qos_network_policy_binding_bumps_revision(self): |
| 392 | policy = self.create_qos_policy(name='network-policy', shared=False) |
| 393 | network = self.create_network() |
| 394 | self.addCleanup(self.client.delete_network, network['id']) |
| 395 | updated = self.admin_client.update_network( |
| 396 | network['id'], qos_policy_id=policy['id']) |
| 397 | self.assertGreater(updated['network']['revision_number'], |
| 398 | network['revision_number']) |