blob: 1d860ca940c8c41c922831306ce30c3d90452191 [file] [log] [blame]
Kevin Benton183b7be2016-03-24 22:14:58 -07001# 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 Bentona2ceb2d2016-09-22 17:52:25 -070013import netaddr
14
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000015from tempest.lib import decorators
Kevin Benton2d745ae2016-12-11 18:24:01 -080016from tempest.lib import exceptions
Kevin Benton183b7be2016-03-24 22:14:58 -070017from tempest import test
18
Chandan Kumar667d3d32017-09-22 12:24:06 +053019from neutron_tempest_plugin.api import base
20from neutron_tempest_plugin.api import base_security_groups as bsg
21from neutron_tempest_plugin import config
Kevin Benton183b7be2016-03-24 22:14:58 -070022
23
24class TestRevisions(base.BaseAdminNetworkTest, bsg.BaseSecGroupTest):
25
Jakub Libosvar1982aa12017-05-30 11:15:33 +000026 required_extensions = ['standard-attr-revisions']
Kevin Benton183b7be2016-03-24 22:14:58 -070027
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000028 @decorators.idempotent_id('4a26a4be-9c53-483c-bc50-b53f1db10ac6')
Kevin Benton183b7be2016-03-24 22:14:58 -070029 def test_update_network_bumps_revision(self):
30 net = self.create_network()
Prateek Aroraebc25142017-03-27 11:30:47 -040031 self.addCleanup(self.client.delete_network, net['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070032 self.assertIn('revision_number', net)
Kevin Benton183b7be2016-03-24 22:14:58 -070033 updated = self.client.update_network(net['id'], name='newnet')
Kevin Benton2f067902016-09-02 17:14:37 -070034 self.assertGreater(updated['network']['revision_number'],
35 net['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070036
Kevin Benton2d745ae2016-12-11 18:24:01 -080037 @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ńskic0caa2e2017-02-25 10:11:32 +000066 @decorators.idempotent_id('cac7ecde-12d5-4331-9a03-420899dea077')
Kevin Benton183b7be2016-03-24 22:14:58 -070067 def test_update_port_bumps_revision(self):
68 net = self.create_network()
Prateek Aroraebc25142017-03-27 11:30:47 -040069 self.addCleanup(self.client.delete_network, net['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -070070 port = self.create_port(net)
Prateek Aroraebc25142017-03-27 11:30:47 -040071 self.addCleanup(self.client.delete_port, port['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070072 self.assertIn('revision_number', port)
Kevin Benton183b7be2016-03-24 22:14:58 -070073 updated = self.client.update_port(port['id'], name='newport')
Kevin Benton2f067902016-09-02 17:14:37 -070074 self.assertGreater(updated['port']['revision_number'],
75 port['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070076
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000077 @decorators.idempotent_id('c1c4fa41-8e89-44d0-9bfc-409f3b66dc57')
Kevin Benton183b7be2016-03-24 22:14:58 -070078 def test_update_subnet_bumps_revision(self):
79 net = self.create_network()
Prateek Aroraebc25142017-03-27 11:30:47 -040080 self.addCleanup(self.client.delete_network, net['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -070081 subnet = self.create_subnet(net)
Prateek Aroraebc25142017-03-27 11:30:47 -040082 self.addCleanup(self.client.delete_subnet, subnet['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070083 self.assertIn('revision_number', subnet)
Kevin Benton183b7be2016-03-24 22:14:58 -070084 updated = self.client.update_subnet(subnet['id'], name='newsub')
Kevin Benton2f067902016-09-02 17:14:37 -070085 self.assertGreater(updated['subnet']['revision_number'],
86 subnet['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070087
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000088 @decorators.idempotent_id('e8c5d7db-2b8d-4615-a476-6e537437c4f2')
Kevin Benton183b7be2016-03-24 22:14:58 -070089 def test_update_subnetpool_bumps_revision(self):
90 sp = self.create_subnetpool('subnetpool', default_prefixlen=24,
91 prefixes=['10.0.0.0/8'])
Prateek Aroraebc25142017-03-27 11:30:47 -040092 self.addCleanup(self.client.delete_subnetpool, sp['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070093 self.assertIn('revision_number', sp)
Kevin Benton183b7be2016-03-24 22:14:58 -070094 updated = self.admin_client.update_subnetpool(sp['id'], name='sp2')
Kevin Benton2f067902016-09-02 17:14:37 -070095 self.assertGreater(updated['subnetpool']['revision_number'],
96 sp['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070097
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000098 @decorators.idempotent_id('e8c5d7db-2b8d-4567-a326-6e123437c4d1')
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070099 def test_update_subnet_bumps_network_revision(self):
100 net = self.create_network()
Prateek Aroraebc25142017-03-27 11:30:47 -0400101 self.addCleanup(self.client.delete_network, net['id'])
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +0700102 subnet = self.create_subnet(net)
103 updated = self.client.show_network(net['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700104 self.assertGreater(updated['network']['revision_number'],
105 net['revision_number'])
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +0700106 self.client.delete_subnet(subnet['id'])
107 updated2 = self.client.show_network(net['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700108 self.assertGreater(updated2['network']['revision_number'],
109 updated['network']['revision_number'])
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +0700110
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000111 @decorators.idempotent_id('6c256f71-c929-4200-b3dc-4e1843506be5')
Kevin Benton183b7be2016-03-24 22:14:58 -0700112 @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 Benton2f067902016-09-02 17:14:37 -0700115 self.assertIn('revision_number', sg['security_group'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700116 update_body = self.client.update_security_group(
117 sg['security_group']['id'], name='new_sg_name')
Kevin Benton2f067902016-09-02 17:14:37 -0700118 self.assertGreater(update_body['security_group']['revision_number'],
119 sg['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700120
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000121 @decorators.idempotent_id('6489632f-8550-4453-a674-c98849742967')
Kevin Benton183b7be2016-03-24 22:14:58 -0700122 @test.requires_ext(extension="security-group", service="network")
123 def test_update_port_sg_binding_bumps_revision(self):
124 net = self.create_network()
Prateek Aroraebc25142017-03-27 11:30:47 -0400125 self.addCleanup(self.client.delete_network, net['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700126 port = self.create_port(net)
Prateek Aroraebc25142017-03-27 11:30:47 -0400127 self.addCleanup(self.client.delete_port, port['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700128 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 Bentona2bd97b2016-09-19 20:05:25 -0700132 updated2 = self.client.update_port(port['id'], security_groups=[])
Kevin Benton2f067902016-09-02 17:14:37 -0700133 self.assertGreater(updated['port']['revision_number'],
134 port['revision_number'])
135 self.assertGreater(updated2['port']['revision_number'],
136 updated['port']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700137
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000138 @decorators.idempotent_id('29c7ab2b-d1d8-425d-8cec-fcf632960f22')
Kevin Benton183b7be2016-03-24 22:14:58 -0700139 @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 Benton2f067902016-09-02 17:14:37 -0700147 self.assertGreater(updated['security_group']['revision_number'],
148 sg['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700149 self.client.delete_security_group_rule(
150 rule['security_group_rule']['id'])
151 updated2 = self.client.show_security_group(sg['security_group']['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700152 self.assertGreater(updated2['security_group']['revision_number'],
153 updated['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700154
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000155 @decorators.idempotent_id('db70c285-0365-4fac-9f55-2a0ad8cf55a8')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700156 @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 Aroraebc25142017-03-27 11:30:47 -0400159 self.addCleanup(self.client.delete_network, net['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700160 port = self.create_port(net)
Prateek Aroraebc25142017-03-27 11:30:47 -0400161 self.addCleanup(self.client.delete_port, port['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700162 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ńskic0caa2e2017-02-25 10:11:32 +0000171 @decorators.idempotent_id('a21ec3b4-3569-4b77-bf29-4177edaa2df5')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700172 @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 Aroraebc25142017-03-27 11:30:47 -0400175 self.addCleanup(self.client.delete_network, net['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700176 port = self.create_port(net)
Prateek Aroraebc25142017-03-27 11:30:47 -0400177 self.addCleanup(self.client.delete_port, port['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700178 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ńskic0caa2e2017-02-25 10:11:32 +0000188 @decorators.idempotent_id('40ba648f-f374-4c29-a5b7-489dd5a38a4e')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700189 @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 Aroraebc25142017-03-27 11:30:47 -0400192 self.addCleanup(self.client.delete_network, net['id'])
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700193 updated = self.client.update_network(net['id'], dns_domain='exa.test.')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700194 self.assertGreater(updated['network']['revision_number'],
195 net['revision_number'])
196 port = self.create_port(net)
Prateek Aroraebc25142017-03-27 11:30:47 -0400197 self.addCleanup(self.client.delete_port, port['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700198 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ńskic0caa2e2017-02-25 10:11:32 +0000207 @decorators.idempotent_id('8482324f-cf59-4d73-b98e-d37119255300')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700208 @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 Aroraebc25142017-03-27 11:30:47 -0400211 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 Bentona2ceb2d2016-09-22 17:52:25 -0700215 subgateway = netaddr.IPAddress(subnet['gateway_ip'])
216 router = self.create_router(router_name='test')
Prateek Aroraebc25142017-03-27 11:30:47 -0400217 self.addCleanup(self.client.delete_router, router['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700218 self.create_router_interface(router['id'], subnet['id'])
Prateek Aroraebc25142017-03-27 11:30:47 -0400219 self.addCleanup(
220 self.client.remove_router_interface_with_subnet_id,
221 router['id'],
222 subnet['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700223 router = self.client.show_router(router['id'])['router']
Omer Ansond1586832016-10-10 22:46:32 +0300224 updated = self.client.update_extra_routes(
225 router['id'], str(subgateway + 1), '2.0.0.0/24')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700226 self.assertGreater(updated['router']['revision_number'],
227 router['revision_number'])
Omer Ansond1586832016-10-10 22:46:32 +0300228 updated2 = self.client.delete_extra_routes(router['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700229 self.assertGreater(updated2['router']['revision_number'],
230 updated['router']['revision_number'])
231
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000232 @decorators.idempotent_id('6bd18702-e25a-4b4b-8c0c-680113533511')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700233 @test.requires_ext(extension="subnet-service-types", service="network")
234 def test_update_subnet_service_types_bumps_revisions(self):
Prateek Aroraebc25142017-03-27 11:30:47 -0400235 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 Bentona2ceb2d2016-09-22 17:52:25 -0700239 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ńskic0caa2e2017-02-25 10:11:32 +0000248 @decorators.idempotent_id('9c83105c-9973-45ff-9ca2-e66d64700abe')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700249 @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 Aroraebc25142017-03-27 11:30:47 -0400252 self.addCleanup(self.client.delete_network, net['id'])
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700253 updated = self.client.update_network(net['id'],
254 port_security_enabled=True)
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700255 self.assertGreater(updated['network']['revision_number'],
256 net['revision_number'])
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700257 updated2 = self.client.update_network(net['id'],
258 port_security_enabled=False)
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700259 self.assertGreater(updated2['network']['revision_number'],
260 updated['network']['revision_number'])
261 port = self.create_port(net, port_security_enabled=False)
Prateek Aroraebc25142017-03-27 11:30:47 -0400262 self.addCleanup(self.client.delete_port, port['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700263 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ńskic0caa2e2017-02-25 10:11:32 +0000272 @decorators.idempotent_id('68d5ac3a-11a1-4847-8e2e-5843c043d89b')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700273 @test.requires_ext(extension="binding", service="network")
274 def test_portbinding_bumps_revision(self):
Prateek Aroraebc25142017-03-27 11:30:47 -0400275 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 Bentona2ceb2d2016-09-22 17:52:25 -0700279 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ńskic0caa2e2017-02-25 10:11:32 +0000286 @decorators.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0')
Kevin Benton183b7be2016-03-24 22:14:58 -0700287 @test.requires_ext(extension="router", service="network")
288 def test_update_router_bumps_revision(self):
Prateek Aroraebc25142017-03-27 11:30:47 -0400289 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 Benton183b7be2016-03-24 22:14:58 -0700293 router = self.create_router(router_name='test')
Prateek Aroraebc25142017-03-27 11:30:47 -0400294 self.addCleanup(self.client.delete_router, router['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700295 self.assertIn('revision_number', router)
296 rev1 = router['revision_number']
Kevin Benton183b7be2016-03-24 22:14:58 -0700297 router = self.client.update_router(router['id'],
298 name='test2')['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700299 self.assertGreater(router['revision_number'], rev1)
Kevin Benton183b7be2016-03-24 22:14:58 -0700300 self.create_router_interface(router['id'], subnet['id'])
Prateek Aroraebc25142017-03-27 11:30:47 -0400301 self.addCleanup(
302 self.client.remove_router_interface_with_subnet_id,
303 router['id'],
304 subnet['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700305 updated = self.client.show_router(router['id'])['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700306 self.assertGreater(updated['revision_number'],
307 router['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700308
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000309 @decorators.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9')
Kevin Benton183b7be2016-03-24 22:14:58 -0700310 @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 Aroraebc25142017-03-27 11:30:47 -0400315 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 Benton183b7be2016-03-24 22:14:58 -0700319 router = self.create_router('test', external_network_id=ext_id)
Prateek Aroraebc25142017-03-27 11:30:47 -0400320 self.addCleanup(self.client.delete_router, router['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700321 self.create_router_interface(router['id'], subnet['id'])
Prateek Aroraebc25142017-03-27 11:30:47 -0400322 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 Benton183b7be2016-03-24 22:14:58 -0700328 body = self.client.create_floatingip(
329 floating_network_id=ext_id,
330 port_id=port['id'],
331 description='d1'
332 )['floatingip']
Itzik Browna3926d92017-02-12 02:49:29 +0200333 self.floating_ips.append(body)
Kevin Benton2f067902016-09-02 17:14:37 -0700334 self.assertIn('revision_number', body)
Kevin Benton183b7be2016-03-24 22:14:58 -0700335 b2 = self.client.update_floatingip(body['id'], description='d2')
Kevin Benton2f067902016-09-02 17:14:37 -0700336 self.assertGreater(b2['floatingip']['revision_number'],
337 body['revision_number'])
LIU Yulong39e5f102016-05-05 14:52:26 +0800338 # disassociate
339 self.client.update_floatingip(b2['floatingip']['id'], port_id=None)
Lujinba9a4922016-11-21 18:19:04 +0900340
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000341 @decorators.idempotent_id('afb6486c-41b5-483e-a500-3c506f4deb49')
Lujinba9a4922016-11-21 18:19:04 +0900342 @test.requires_ext(extension="router", service="network")
Brian Haley5ae5a2e2017-05-05 11:32:07 -0400343 @test.requires_ext(extension="l3-ha", service="network")
Lujinba9a4922016-11-21 18:19:04 +0900344 def test_update_router_extra_attributes_bumps_revision(self):
Brian Haley5ae5a2e2017-05-05 11:32:07 -0400345 # 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 Aroraebc25142017-03-27 11:30:47 -0400351 self.addCleanup(self.client.delete_router, router['id'])
Lujinba9a4922016-11-21 18:19:04 +0900352 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 Haley5ae5a2e2017-05-05 11:32:07 -0400357 self.admin_client.update_router(router['id'], ha=True)['router']
Lujinba9a4922016-11-21 18:19:04 +0900358 updated = self.client.show_router(router['id'])['router']
359 self.assertGreater(updated['revision_number'],
360 router['revision_number'])
361
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000362 @decorators.idempotent_id('90743b00-b0e2-40e4-9524-1c884fe3ef23')
Kevin Benton3e305972016-12-28 02:05:29 -0800363 @test.requires_ext(extension="external-net", service="network")
Lujinba9a4922016-11-21 18:19:04 +0900364 @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 Aroraebc25142017-03-27 11:30:47 -0400369 self.addCleanup(self.client.delete_network, net['id'])
Lujinba9a4922016-11-21 18:19:04 +0900370 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ńskic0caa2e2017-02-25 10:11:32 +0000376 @decorators.idempotent_id('5af6450a-0f61-49c3-b628-38db77c7b856')
Lujinba9a4922016-11-21 18:19:04 +0900377 @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 Aroraebc25142017-03-27 11:30:47 -0400380 net = self.create_network()
381 self.addCleanup(self.client.delete_network, net['id'])
382 port = self.create_port(net)
Lujinba9a4922016-11-21 18:19:04 +0900383 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ńskic0caa2e2017-02-25 10:11:32 +0000389 @decorators.idempotent_id('817da343-c6e4-445c-9519-a621f124dfbe')
Lujinba9a4922016-11-21 18:19:04 +0900390 @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'])