blob: 2e06c7c929c70d9d7f60005dfa5d517be049bc0d [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 Benton183b7be2016-03-24 22:14:58 -070016from tempest import test
17
18from neutron.tests.tempest.api import base
19from neutron.tests.tempest.api import base_security_groups as bsg
20from neutron.tests.tempest import config
21
22
23class TestRevisions(base.BaseAdminNetworkTest, bsg.BaseSecGroupTest):
24
25 @classmethod
Kevin Bentonb944fcb2016-09-02 00:26:42 -060026 @test.requires_ext(extension="standard-attr-revisions", service="network")
Kevin Benton183b7be2016-03-24 22:14:58 -070027 def skip_checks(cls):
28 super(TestRevisions, cls).skip_checks()
29
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000030 @decorators.idempotent_id('4a26a4be-9c53-483c-bc50-b53f1db10ac6')
Kevin Benton183b7be2016-03-24 22:14:58 -070031 def test_update_network_bumps_revision(self):
32 net = self.create_network()
Kevin Benton2f067902016-09-02 17:14:37 -070033 self.assertIn('revision_number', net)
Kevin Benton183b7be2016-03-24 22:14:58 -070034 updated = self.client.update_network(net['id'], name='newnet')
Kevin Benton2f067902016-09-02 17:14:37 -070035 self.assertGreater(updated['network']['revision_number'],
36 net['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070037
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000038 @decorators.idempotent_id('cac7ecde-12d5-4331-9a03-420899dea077')
Kevin Benton183b7be2016-03-24 22:14:58 -070039 def test_update_port_bumps_revision(self):
40 net = self.create_network()
41 port = self.create_port(net)
Kevin Benton2f067902016-09-02 17:14:37 -070042 self.assertIn('revision_number', port)
Kevin Benton183b7be2016-03-24 22:14:58 -070043 updated = self.client.update_port(port['id'], name='newport')
Kevin Benton2f067902016-09-02 17:14:37 -070044 self.assertGreater(updated['port']['revision_number'],
45 port['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070046
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000047 @decorators.idempotent_id('c1c4fa41-8e89-44d0-9bfc-409f3b66dc57')
Kevin Benton183b7be2016-03-24 22:14:58 -070048 def test_update_subnet_bumps_revision(self):
49 net = self.create_network()
50 subnet = self.create_subnet(net)
Kevin Benton2f067902016-09-02 17:14:37 -070051 self.assertIn('revision_number', subnet)
Kevin Benton183b7be2016-03-24 22:14:58 -070052 updated = self.client.update_subnet(subnet['id'], name='newsub')
Kevin Benton2f067902016-09-02 17:14:37 -070053 self.assertGreater(updated['subnet']['revision_number'],
54 subnet['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070055
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000056 @decorators.idempotent_id('e8c5d7db-2b8d-4615-a476-6e537437c4f2')
Kevin Benton183b7be2016-03-24 22:14:58 -070057 def test_update_subnetpool_bumps_revision(self):
58 sp = self.create_subnetpool('subnetpool', default_prefixlen=24,
59 prefixes=['10.0.0.0/8'])
Kevin Benton2f067902016-09-02 17:14:37 -070060 self.assertIn('revision_number', sp)
Kevin Benton183b7be2016-03-24 22:14:58 -070061 updated = self.admin_client.update_subnetpool(sp['id'], name='sp2')
Kevin Benton2f067902016-09-02 17:14:37 -070062 self.assertGreater(updated['subnetpool']['revision_number'],
63 sp['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070064
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000065 @decorators.idempotent_id('e8c5d7db-2b8d-4567-a326-6e123437c4d1')
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070066 def test_update_subnet_bumps_network_revision(self):
67 net = self.create_network()
68 subnet = self.create_subnet(net)
69 updated = self.client.show_network(net['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070070 self.assertGreater(updated['network']['revision_number'],
71 net['revision_number'])
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070072 self.client.delete_subnet(subnet['id'])
73 updated2 = self.client.show_network(net['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070074 self.assertGreater(updated2['network']['revision_number'],
75 updated['network']['revision_number'])
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070076
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000077 @decorators.idempotent_id('6c256f71-c929-4200-b3dc-4e1843506be5')
Kevin Benton183b7be2016-03-24 22:14:58 -070078 @test.requires_ext(extension="security-group", service="network")
79 def test_update_sg_group_bumps_revision(self):
80 sg, name = self._create_security_group()
Kevin Benton2f067902016-09-02 17:14:37 -070081 self.assertIn('revision_number', sg['security_group'])
Kevin Benton183b7be2016-03-24 22:14:58 -070082 update_body = self.client.update_security_group(
83 sg['security_group']['id'], name='new_sg_name')
Kevin Benton2f067902016-09-02 17:14:37 -070084 self.assertGreater(update_body['security_group']['revision_number'],
85 sg['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070086
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000087 @decorators.idempotent_id('6489632f-8550-4453-a674-c98849742967')
Kevin Benton183b7be2016-03-24 22:14:58 -070088 @test.requires_ext(extension="security-group", service="network")
89 def test_update_port_sg_binding_bumps_revision(self):
90 net = self.create_network()
91 port = self.create_port(net)
92 sg = self._create_security_group()[0]
93 self.client.update_port(
94 port['id'], security_groups=[sg['security_group']['id']])
95 updated = self.client.show_port(port['id'])
Kevin Bentona2bd97b2016-09-19 20:05:25 -070096 updated2 = self.client.update_port(port['id'], security_groups=[])
Kevin Benton2f067902016-09-02 17:14:37 -070097 self.assertGreater(updated['port']['revision_number'],
98 port['revision_number'])
99 self.assertGreater(updated2['port']['revision_number'],
100 updated['port']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700101
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000102 @decorators.idempotent_id('29c7ab2b-d1d8-425d-8cec-fcf632960f22')
Kevin Benton183b7be2016-03-24 22:14:58 -0700103 @test.requires_ext(extension="security-group", service="network")
104 def test_update_sg_rule_bumps_sg_revision(self):
105 sg, name = self._create_security_group()
106 rule = self.client.create_security_group_rule(
107 security_group_id=sg['security_group']['id'],
108 protocol='tcp', direction='ingress', ethertype=self.ethertype,
109 port_range_min=60, port_range_max=70)
110 updated = self.client.show_security_group(sg['security_group']['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700111 self.assertGreater(updated['security_group']['revision_number'],
112 sg['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700113 self.client.delete_security_group_rule(
114 rule['security_group_rule']['id'])
115 updated2 = self.client.show_security_group(sg['security_group']['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700116 self.assertGreater(updated2['security_group']['revision_number'],
117 updated['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700118
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000119 @decorators.idempotent_id('db70c285-0365-4fac-9f55-2a0ad8cf55a8')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700120 @test.requires_ext(extension="allowed-address-pairs", service="network")
121 def test_update_allowed_address_pairs_bumps_revision(self):
122 net = self.create_network()
123 port = self.create_port(net)
124 updated = self.client.update_port(
125 port['id'], allowed_address_pairs=[{'ip_address': '1.1.1.1/32'}])
126 self.assertGreater(updated['port']['revision_number'],
127 port['revision_number'])
128 updated2 = self.client.update_port(
129 port['id'], allowed_address_pairs=[])
130 self.assertGreater(updated2['port']['revision_number'],
131 updated['port']['revision_number'])
132
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000133 @decorators.idempotent_id('a21ec3b4-3569-4b77-bf29-4177edaa2df5')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700134 @test.requires_ext(extension="extra_dhcp_opt", service="network")
135 def test_update_extra_dhcp_opt_bumps_revision(self):
136 net = self.create_network()
137 port = self.create_port(net)
138 opts = [{'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'}]
139 updated = self.client.update_port(port['id'], extra_dhcp_opts=opts)
140 self.assertGreater(updated['port']['revision_number'],
141 port['revision_number'])
142 opts[0]['opt_value'] = 'pxelinux.77'
143 updated2 = self.client.update_port(
144 port['id'], extra_dhcp_opts=opts)
145 self.assertGreater(updated2['port']['revision_number'],
146 updated['port']['revision_number'])
147
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000148 @decorators.idempotent_id('40ba648f-f374-4c29-a5b7-489dd5a38a4e')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700149 @test.requires_ext(extension="dns-integration", service="network")
150 def test_update_dns_domain_bumps_revision(self):
151 net = self.create_network(dns_domain='example.test.')
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700152 updated = self.client.update_network(net['id'], dns_domain='exa.test.')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700153 self.assertGreater(updated['network']['revision_number'],
154 net['revision_number'])
155 port = self.create_port(net)
156 updated = self.client.update_port(port['id'], dns_name='port1')
157 if not updated['port']['dns_name']:
158 self.skipTest("Server does not have DNS domain configured.")
159 self.assertGreater(updated['port']['revision_number'],
160 port['revision_number'])
161 updated2 = self.client.update_port(port['id'], dns_name='')
162 self.assertGreater(updated2['port']['revision_number'],
163 updated['port']['revision_number'])
164
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000165 @decorators.idempotent_id('8482324f-cf59-4d73-b98e-d37119255300')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700166 @test.requires_ext(extension="router", service="network")
167 @test.requires_ext(extension="extraroute", service="network")
168 def test_update_router_extra_routes_bumps_revision(self):
169 subnet = self.create_subnet(self.create_network())
170 subgateway = netaddr.IPAddress(subnet['gateway_ip'])
171 router = self.create_router(router_name='test')
172 self.create_router_interface(router['id'], subnet['id'])
173 router = self.client.show_router(router['id'])['router']
Omer Ansond1586832016-10-10 22:46:32 +0300174 updated = self.client.update_extra_routes(
175 router['id'], str(subgateway + 1), '2.0.0.0/24')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700176 self.assertGreater(updated['router']['revision_number'],
177 router['revision_number'])
Omer Ansond1586832016-10-10 22:46:32 +0300178 updated2 = self.client.delete_extra_routes(router['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700179 self.assertGreater(updated2['router']['revision_number'],
180 updated['router']['revision_number'])
181
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000182 @decorators.idempotent_id('6bd18702-e25a-4b4b-8c0c-680113533511')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700183 @test.requires_ext(extension="subnet-service-types", service="network")
184 def test_update_subnet_service_types_bumps_revisions(self):
185 subnet = self.create_subnet(self.create_network())
186 updated = self.client.update_subnet(
187 subnet['id'], service_types=['compute:'])
188 self.assertGreater(updated['subnet']['revision_number'],
189 subnet['revision_number'])
190 updated2 = self.client.update_subnet(
191 subnet['id'], service_types=[])
192 self.assertGreater(updated2['subnet']['revision_number'],
193 updated['subnet']['revision_number'])
194
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000195 @decorators.idempotent_id('9c83105c-9973-45ff-9ca2-e66d64700abe')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700196 @test.requires_ext(extension="port-security", service="network")
197 def test_update_port_security_bumps_revisions(self):
198 net = self.create_network(port_security_enabled=False)
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700199 updated = self.client.update_network(net['id'],
200 port_security_enabled=True)
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700201 self.assertGreater(updated['network']['revision_number'],
202 net['revision_number'])
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700203 updated2 = self.client.update_network(net['id'],
204 port_security_enabled=False)
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700205 self.assertGreater(updated2['network']['revision_number'],
206 updated['network']['revision_number'])
207 port = self.create_port(net, port_security_enabled=False)
208 updated = self.client.update_port(port['id'],
209 port_security_enabled=True)
210 self.assertGreater(updated['port']['revision_number'],
211 port['revision_number'])
212 updated2 = self.client.update_port(port['id'],
213 port_security_enabled=False)
214 self.assertGreater(updated2['port']['revision_number'],
215 updated['port']['revision_number'])
216
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000217 @decorators.idempotent_id('68d5ac3a-11a1-4847-8e2e-5843c043d89b')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700218 @test.requires_ext(extension="binding", service="network")
219 def test_portbinding_bumps_revision(self):
220 port = self.create_port(self.create_network())
221 port = self.admin_client.update_port(
222 port['id'], **{'binding:host_id': 'badhost1'})['port']
223 updated = self.admin_client.update_port(
224 port['id'], **{'binding:host_id': 'badhost2'})['port']
225 self.assertGreater(updated['revision_number'],
226 port['revision_number'])
227
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000228 @decorators.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0')
Kevin Benton183b7be2016-03-24 22:14:58 -0700229 @test.requires_ext(extension="router", service="network")
230 def test_update_router_bumps_revision(self):
231 subnet = self.create_subnet(self.create_network())
232 router = self.create_router(router_name='test')
Kevin Benton2f067902016-09-02 17:14:37 -0700233 self.assertIn('revision_number', router)
234 rev1 = router['revision_number']
Kevin Benton183b7be2016-03-24 22:14:58 -0700235 router = self.client.update_router(router['id'],
236 name='test2')['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700237 self.assertGreater(router['revision_number'], rev1)
Kevin Benton183b7be2016-03-24 22:14:58 -0700238 self.create_router_interface(router['id'], subnet['id'])
239 updated = self.client.show_router(router['id'])['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700240 self.assertGreater(updated['revision_number'],
241 router['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700242
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000243 @decorators.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9')
Kevin Benton183b7be2016-03-24 22:14:58 -0700244 @test.requires_ext(extension="router", service="network")
245 @test.requires_ext(extension="standard-attr-description",
246 service="network")
247 def test_update_floatingip_bumps_revision(self):
248 ext_id = config.CONF.network.public_network_id
249 network = self.create_network()
250 subnet = self.create_subnet(network)
251 router = self.create_router('test', external_network_id=ext_id)
252 self.create_router_interface(router['id'], subnet['id'])
253 port = self.create_port(network)
254 body = self.client.create_floatingip(
255 floating_network_id=ext_id,
256 port_id=port['id'],
257 description='d1'
258 )['floatingip']
Itzik Browna3926d92017-02-12 02:49:29 +0200259 self.floating_ips.append(body)
Kevin Benton2f067902016-09-02 17:14:37 -0700260 self.assertIn('revision_number', body)
Kevin Benton183b7be2016-03-24 22:14:58 -0700261 b2 = self.client.update_floatingip(body['id'], description='d2')
Kevin Benton2f067902016-09-02 17:14:37 -0700262 self.assertGreater(b2['floatingip']['revision_number'],
263 body['revision_number'])
LIU Yulong39e5f102016-05-05 14:52:26 +0800264 # disassociate
265 self.client.update_floatingip(b2['floatingip']['id'], port_id=None)
Lujinba9a4922016-11-21 18:19:04 +0900266
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000267 @decorators.idempotent_id('afb6486c-41b5-483e-a500-3c506f4deb49')
Lujinba9a4922016-11-21 18:19:04 +0900268 @test.requires_ext(extension="router", service="network")
269 @test.requires_ext(extension="dvr", service="network")
270 def test_update_router_extra_attributes_bumps_revision(self):
271 router = self.create_router(router_name='r1')
272 self.assertIn('revision_number', router)
273 rev1 = router['revision_number']
274 router = self.admin_client.update_router(
275 router['id'], admin_state_up=False)['router']
276 self.assertGreater(router['revision_number'], rev1)
277 self.admin_client.update_router(router['id'],
278 distributed=True)['router']
279 updated = self.client.show_router(router['id'])['router']
280 self.assertGreater(updated['revision_number'],
281 router['revision_number'])
282
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000283 @decorators.idempotent_id('90743b00-b0e2-40e4-9524-1c884fe3ef23')
Kevin Benton3e305972016-12-28 02:05:29 -0800284 @test.requires_ext(extension="external-net", service="network")
Lujinba9a4922016-11-21 18:19:04 +0900285 @test.requires_ext(extension="auto-allocated-topology", service="network")
286 @test.requires_ext(extension="subnet_allocation", service="network")
287 @test.requires_ext(extension="router", service="network")
288 def test_update_external_network_bumps_revision(self):
289 net = self.create_network()
290 self.assertIn('revision_number', net)
291 updated = self.admin_client.update_network(net['id'],
292 **{'router:external': True})
293 self.assertGreater(updated['network']['revision_number'],
294 net['revision_number'])
295
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000296 @decorators.idempotent_id('5af6450a-0f61-49c3-b628-38db77c7b856')
Lujinba9a4922016-11-21 18:19:04 +0900297 @test.requires_ext(extension="qos", service="network")
298 def test_update_qos_port_policy_binding_bumps_revision(self):
299 policy = self.create_qos_policy(name='port-policy', shared=False)
300 port = self.create_port(self.create_network())
301 self.addCleanup(self.client.delete_port, port['id'])
302 updated = self.admin_client.update_port(
303 port['id'], qos_policy_id=policy['id'])
304 self.assertGreater(updated['port']['revision_number'],
305 port['revision_number'])
306
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000307 @decorators.idempotent_id('817da343-c6e4-445c-9519-a621f124dfbe')
Lujinba9a4922016-11-21 18:19:04 +0900308 @test.requires_ext(extension="qos", service="network")
309 def test_update_qos_network_policy_binding_bumps_revision(self):
310 policy = self.create_qos_policy(name='network-policy', shared=False)
311 network = self.create_network()
312 self.addCleanup(self.client.delete_network, network['id'])
313 updated = self.admin_client.update_network(
314 network['id'], qos_policy_id=policy['id'])
315 self.assertGreater(updated['network']['revision_number'],
316 network['revision_number'])