blob: 0d590f6344b2f4a2fab40cc6c3315f0cd47d5b6d [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
Federico Ressie570de62018-10-10 15:33:55 +020015from neutron_lib import constants
Chandan Kumarc125fd12017-11-15 19:41:01 +053016from tempest.common import utils
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000017from tempest.lib import decorators
Kevin Benton2d745ae2016-12-11 18:24:01 -080018from tempest.lib import exceptions
Kevin Benton183b7be2016-03-24 22:14:58 -070019
Chandan Kumar667d3d32017-09-22 12:24:06 +053020from neutron_tempest_plugin.api import base
Chandan Kumar667d3d32017-09-22 12:24:06 +053021from neutron_tempest_plugin import config
Kevin Benton183b7be2016-03-24 22:14:58 -070022
23
Federico Ressie570de62018-10-10 15:33:55 +020024class TestRevisions(base.BaseAdminNetworkTest):
Kevin Benton183b7be2016-03-24 22:14:58 -070025
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')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530112 @utils.requires_ext(extension="security-group", service="network")
Kevin Benton183b7be2016-03-24 22:14:58 -0700113 def test_update_sg_group_bumps_revision(self):
Federico Ressie570de62018-10-10 15:33:55 +0200114 security_group = self.create_security_group()
115 self.assertIn('revision_number', security_group)
116 updated_security_group = self.client.update_security_group(
117 security_group['id'], name='new_sg_name')['security_group']
118 self.assertGreater(updated_security_group['revision_number'],
119 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')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530122 @utils.requires_ext(extension="security-group", service="network")
Kevin Benton183b7be2016-03-24 22:14:58 -0700123 def test_update_port_sg_binding_bumps_revision(self):
Federico Ressie570de62018-10-10 15:33:55 +0200124 network = self.create_network()
125 port = self.create_port(network)
126
127 security_group = self.create_security_group()
128 updated_port = self.client.update_port(
129 port['id'], security_groups=[security_group['id']])['port']
130 self.assertGreater(updated_port['revision_number'],
Kevin Benton2f067902016-09-02 17:14:37 -0700131 port['revision_number'])
Federico Ressie570de62018-10-10 15:33:55 +0200132
133 updated_port2 = self.client.update_port(
134 port['id'], security_groups=[])['port']
135 self.assertGreater(updated_port2['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')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530139 @utils.requires_ext(extension="security-group", service="network")
Kevin Benton183b7be2016-03-24 22:14:58 -0700140 def test_update_sg_rule_bumps_sg_revision(self):
Federico Ressie570de62018-10-10 15:33:55 +0200141 security_group = self.create_security_group()
142
143 security_group_rule = self.create_security_group_rule(
144 security_group=security_group,
145 protocol=constants.PROTO_NAME_TCP,
146 direction=constants.INGRESS_DIRECTION,
147 port_range_min=60,
148 port_range_max=70)
149 updated_security_group = self.client.show_security_group(
150 security_group['id'])['security_group']
151 self.assertGreater(updated_security_group['revision_number'],
152 security_group['revision_number'])
153
154 self.client.delete_security_group_rule(security_group_rule['id'])
155 updated_security_group2 = self.client.show_security_group(
156 security_group['id'])['security_group']
157 self.assertGreater(updated_security_group2['revision_number'],
158 updated_security_group['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700159
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000160 @decorators.idempotent_id('db70c285-0365-4fac-9f55-2a0ad8cf55a8')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530161 @utils.requires_ext(extension="allowed-address-pairs", service="network")
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700162 def test_update_allowed_address_pairs_bumps_revision(self):
163 net = self.create_network()
Prateek Aroraebc25142017-03-27 11:30:47 -0400164 self.addCleanup(self.client.delete_network, net['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700165 port = self.create_port(net)
Prateek Aroraebc25142017-03-27 11:30:47 -0400166 self.addCleanup(self.client.delete_port, port['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700167 updated = self.client.update_port(
168 port['id'], allowed_address_pairs=[{'ip_address': '1.1.1.1/32'}])
169 self.assertGreater(updated['port']['revision_number'],
170 port['revision_number'])
171 updated2 = self.client.update_port(
172 port['id'], allowed_address_pairs=[])
173 self.assertGreater(updated2['port']['revision_number'],
174 updated['port']['revision_number'])
175
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000176 @decorators.idempotent_id('a21ec3b4-3569-4b77-bf29-4177edaa2df5')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530177 @utils.requires_ext(extension="extra_dhcp_opt", service="network")
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700178 def test_update_extra_dhcp_opt_bumps_revision(self):
179 net = self.create_network()
Prateek Aroraebc25142017-03-27 11:30:47 -0400180 self.addCleanup(self.client.delete_network, net['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700181 port = self.create_port(net)
Prateek Aroraebc25142017-03-27 11:30:47 -0400182 self.addCleanup(self.client.delete_port, port['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700183 opts = [{'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'}]
184 updated = self.client.update_port(port['id'], extra_dhcp_opts=opts)
185 self.assertGreater(updated['port']['revision_number'],
186 port['revision_number'])
187 opts[0]['opt_value'] = 'pxelinux.77'
188 updated2 = self.client.update_port(
189 port['id'], extra_dhcp_opts=opts)
190 self.assertGreater(updated2['port']['revision_number'],
191 updated['port']['revision_number'])
192
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000193 @decorators.idempotent_id('40ba648f-f374-4c29-a5b7-489dd5a38a4e')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530194 @utils.requires_ext(extension="dns-integration", service="network")
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700195 def test_update_dns_domain_bumps_revision(self):
196 net = self.create_network(dns_domain='example.test.')
Prateek Aroraebc25142017-03-27 11:30:47 -0400197 self.addCleanup(self.client.delete_network, net['id'])
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700198 updated = self.client.update_network(net['id'], dns_domain='exa.test.')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700199 self.assertGreater(updated['network']['revision_number'],
200 net['revision_number'])
201 port = self.create_port(net)
Prateek Aroraebc25142017-03-27 11:30:47 -0400202 self.addCleanup(self.client.delete_port, port['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700203 updated = self.client.update_port(port['id'], dns_name='port1')
204 if not updated['port']['dns_name']:
205 self.skipTest("Server does not have DNS domain configured.")
206 self.assertGreater(updated['port']['revision_number'],
207 port['revision_number'])
208 updated2 = self.client.update_port(port['id'], dns_name='')
209 self.assertGreater(updated2['port']['revision_number'],
210 updated['port']['revision_number'])
211
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000212 @decorators.idempotent_id('8482324f-cf59-4d73-b98e-d37119255300')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530213 @utils.requires_ext(extension="router", service="network")
214 @utils.requires_ext(extension="extraroute", service="network")
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700215 def test_update_router_extra_routes_bumps_revision(self):
Prateek Aroraebc25142017-03-27 11:30:47 -0400216 net = self.create_network()
217 self.addCleanup(self.client.delete_network, net['id'])
218 subnet = self.create_subnet(net)
219 self.addCleanup(self.client.delete_subnet, subnet['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700220 subgateway = netaddr.IPAddress(subnet['gateway_ip'])
221 router = self.create_router(router_name='test')
Prateek Aroraebc25142017-03-27 11:30:47 -0400222 self.addCleanup(self.client.delete_router, router['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700223 self.create_router_interface(router['id'], subnet['id'])
Prateek Aroraebc25142017-03-27 11:30:47 -0400224 self.addCleanup(
225 self.client.remove_router_interface_with_subnet_id,
226 router['id'],
227 subnet['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700228 router = self.client.show_router(router['id'])['router']
Omer Ansond1586832016-10-10 22:46:32 +0300229 updated = self.client.update_extra_routes(
230 router['id'], str(subgateway + 1), '2.0.0.0/24')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700231 self.assertGreater(updated['router']['revision_number'],
232 router['revision_number'])
Omer Ansond1586832016-10-10 22:46:32 +0300233 updated2 = self.client.delete_extra_routes(router['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700234 self.assertGreater(updated2['router']['revision_number'],
235 updated['router']['revision_number'])
236
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000237 @decorators.idempotent_id('6bd18702-e25a-4b4b-8c0c-680113533511')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530238 @utils.requires_ext(extension="subnet-service-types", service="network")
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700239 def test_update_subnet_service_types_bumps_revisions(self):
Prateek Aroraebc25142017-03-27 11:30:47 -0400240 net = self.create_network()
241 self.addCleanup(self.client.delete_network, net['id'])
242 subnet = self.create_subnet(net)
243 self.addCleanup(self.client.delete_subnet, subnet['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700244 updated = self.client.update_subnet(
245 subnet['id'], service_types=['compute:'])
246 self.assertGreater(updated['subnet']['revision_number'],
247 subnet['revision_number'])
248 updated2 = self.client.update_subnet(
249 subnet['id'], service_types=[])
250 self.assertGreater(updated2['subnet']['revision_number'],
251 updated['subnet']['revision_number'])
252
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000253 @decorators.idempotent_id('9c83105c-9973-45ff-9ca2-e66d64700abe')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530254 @utils.requires_ext(extension="port-security", service="network")
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700255 def test_update_port_security_bumps_revisions(self):
256 net = self.create_network(port_security_enabled=False)
Prateek Aroraebc25142017-03-27 11:30:47 -0400257 self.addCleanup(self.client.delete_network, net['id'])
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700258 updated = self.client.update_network(net['id'],
259 port_security_enabled=True)
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700260 self.assertGreater(updated['network']['revision_number'],
261 net['revision_number'])
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700262 updated2 = self.client.update_network(net['id'],
263 port_security_enabled=False)
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700264 self.assertGreater(updated2['network']['revision_number'],
265 updated['network']['revision_number'])
266 port = self.create_port(net, port_security_enabled=False)
Prateek Aroraebc25142017-03-27 11:30:47 -0400267 self.addCleanup(self.client.delete_port, port['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700268 updated = self.client.update_port(port['id'],
269 port_security_enabled=True)
270 self.assertGreater(updated['port']['revision_number'],
271 port['revision_number'])
272 updated2 = self.client.update_port(port['id'],
273 port_security_enabled=False)
274 self.assertGreater(updated2['port']['revision_number'],
275 updated['port']['revision_number'])
276
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000277 @decorators.idempotent_id('68d5ac3a-11a1-4847-8e2e-5843c043d89b')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530278 @utils.requires_ext(extension="binding", service="network")
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700279 def test_portbinding_bumps_revision(self):
Prateek Aroraebc25142017-03-27 11:30:47 -0400280 net = self.create_network()
281 self.addCleanup(self.client.delete_network, net['id'])
282 port = self.create_port(net)
283 self.addCleanup(self.client.delete_port, port['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700284 port = self.admin_client.update_port(
285 port['id'], **{'binding:host_id': 'badhost1'})['port']
286 updated = self.admin_client.update_port(
287 port['id'], **{'binding:host_id': 'badhost2'})['port']
288 self.assertGreater(updated['revision_number'],
289 port['revision_number'])
290
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000291 @decorators.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530292 @utils.requires_ext(extension="router", service="network")
Kevin Benton183b7be2016-03-24 22:14:58 -0700293 def test_update_router_bumps_revision(self):
Prateek Aroraebc25142017-03-27 11:30:47 -0400294 net = self.create_network()
295 self.addCleanup(self.client.delete_network, net['id'])
296 subnet = self.create_subnet(net)
297 self.addCleanup(self.client.delete_subnet, subnet['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700298 router = self.create_router(router_name='test')
Prateek Aroraebc25142017-03-27 11:30:47 -0400299 self.addCleanup(self.client.delete_router, router['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700300 self.assertIn('revision_number', router)
301 rev1 = router['revision_number']
Kevin Benton183b7be2016-03-24 22:14:58 -0700302 router = self.client.update_router(router['id'],
303 name='test2')['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700304 self.assertGreater(router['revision_number'], rev1)
Kevin Benton183b7be2016-03-24 22:14:58 -0700305 self.create_router_interface(router['id'], subnet['id'])
Prateek Aroraebc25142017-03-27 11:30:47 -0400306 self.addCleanup(
307 self.client.remove_router_interface_with_subnet_id,
308 router['id'],
309 subnet['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700310 updated = self.client.show_router(router['id'])['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700311 self.assertGreater(updated['revision_number'],
312 router['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700313
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000314 @decorators.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530315 @utils.requires_ext(extension="router", service="network")
316 @utils.requires_ext(extension="standard-attr-description",
Federico Ressi3dfa94c2018-07-06 09:46:39 +0200317 service="network")
Kevin Benton183b7be2016-03-24 22:14:58 -0700318 def test_update_floatingip_bumps_revision(self):
319 ext_id = config.CONF.network.public_network_id
Prateek Aroraebc25142017-03-27 11:30:47 -0400320 net = self.create_network()
321 self.addCleanup(self.client.delete_network, net['id'])
322 subnet = self.create_subnet(net)
323 self.addCleanup(self.client.delete_subnet, subnet['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700324 router = self.create_router('test', external_network_id=ext_id)
Prateek Aroraebc25142017-03-27 11:30:47 -0400325 self.addCleanup(self.client.delete_router, router['id'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700326 self.create_router_interface(router['id'], subnet['id'])
Prateek Aroraebc25142017-03-27 11:30:47 -0400327 self.addCleanup(
328 self.client.remove_router_interface_with_subnet_id,
329 router['id'],
330 subnet['id'])
331 port = self.create_port(net)
332 self.addCleanup(self.client.delete_port, port['id'])
Federico Ressi3dfa94c2018-07-06 09:46:39 +0200333 body = self.create_floatingip(port=port, description='d1')
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')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530342 @utils.requires_ext(extension="router", service="network")
343 @utils.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')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530363 @utils.requires_ext(extension="external-net", service="network")
364 @utils.requires_ext(extension="auto-allocated-topology", service="network")
365 @utils.requires_ext(extension="subnet_allocation", service="network")
366 @utils.requires_ext(extension="router", service="network")
Lujinba9a4922016-11-21 18:19:04 +0900367 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')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530377 @utils.requires_ext(extension="qos", service="network")
Lujinba9a4922016-11-21 18:19:04 +0900378 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')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530390 @utils.requires_ext(extension="qos", service="network")
Lujinba9a4922016-11-21 18:19:04 +0900391 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'])