blob: e0419d9de22a56fab01f67201efcf752fc1b0a2d [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
Kevin Benton183b7be2016-03-24 22:14:58 -070015from tempest import test
16
17from neutron.tests.tempest.api import base
18from neutron.tests.tempest.api import base_security_groups as bsg
19from neutron.tests.tempest import config
20
21
22class TestRevisions(base.BaseAdminNetworkTest, bsg.BaseSecGroupTest):
23
24 @classmethod
Kevin Bentonb944fcb2016-09-02 00:26:42 -060025 @test.requires_ext(extension="standard-attr-revisions", service="network")
Kevin Benton183b7be2016-03-24 22:14:58 -070026 def skip_checks(cls):
27 super(TestRevisions, cls).skip_checks()
28
29 @test.idempotent_id('4a26a4be-9c53-483c-bc50-b53f1db10ac6')
30 def test_update_network_bumps_revision(self):
31 net = self.create_network()
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
37 @test.idempotent_id('cac7ecde-12d5-4331-9a03-420899dea077')
38 def test_update_port_bumps_revision(self):
39 net = self.create_network()
40 port = self.create_port(net)
Kevin Benton2f067902016-09-02 17:14:37 -070041 self.assertIn('revision_number', port)
Kevin Benton183b7be2016-03-24 22:14:58 -070042 updated = self.client.update_port(port['id'], name='newport')
Kevin Benton2f067902016-09-02 17:14:37 -070043 self.assertGreater(updated['port']['revision_number'],
44 port['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070045
46 @test.idempotent_id('c1c4fa41-8e89-44d0-9bfc-409f3b66dc57')
47 def test_update_subnet_bumps_revision(self):
48 net = self.create_network()
49 subnet = self.create_subnet(net)
Kevin Benton2f067902016-09-02 17:14:37 -070050 self.assertIn('revision_number', subnet)
Kevin Benton183b7be2016-03-24 22:14:58 -070051 updated = self.client.update_subnet(subnet['id'], name='newsub')
Kevin Benton2f067902016-09-02 17:14:37 -070052 self.assertGreater(updated['subnet']['revision_number'],
53 subnet['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070054
55 @test.idempotent_id('e8c5d7db-2b8d-4615-a476-6e537437c4f2')
56 def test_update_subnetpool_bumps_revision(self):
57 sp = self.create_subnetpool('subnetpool', default_prefixlen=24,
58 prefixes=['10.0.0.0/8'])
Kevin Benton2f067902016-09-02 17:14:37 -070059 self.assertIn('revision_number', sp)
Kevin Benton183b7be2016-03-24 22:14:58 -070060 updated = self.admin_client.update_subnetpool(sp['id'], name='sp2')
Kevin Benton2f067902016-09-02 17:14:37 -070061 self.assertGreater(updated['subnetpool']['revision_number'],
62 sp['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070063
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070064 @test.idempotent_id('e8c5d7db-2b8d-4567-a326-6e123437c4d1')
65 def test_update_subnet_bumps_network_revision(self):
66 net = self.create_network()
67 subnet = self.create_subnet(net)
68 updated = self.client.show_network(net['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070069 self.assertGreater(updated['network']['revision_number'],
70 net['revision_number'])
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070071 self.client.delete_subnet(subnet['id'])
72 updated2 = self.client.show_network(net['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070073 self.assertGreater(updated2['network']['revision_number'],
74 updated['network']['revision_number'])
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070075
Kevin Benton183b7be2016-03-24 22:14:58 -070076 @test.idempotent_id('6c256f71-c929-4200-b3dc-4e1843506be5')
77 @test.requires_ext(extension="security-group", service="network")
78 def test_update_sg_group_bumps_revision(self):
79 sg, name = self._create_security_group()
Kevin Benton2f067902016-09-02 17:14:37 -070080 self.assertIn('revision_number', sg['security_group'])
Kevin Benton183b7be2016-03-24 22:14:58 -070081 update_body = self.client.update_security_group(
82 sg['security_group']['id'], name='new_sg_name')
Kevin Benton2f067902016-09-02 17:14:37 -070083 self.assertGreater(update_body['security_group']['revision_number'],
84 sg['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070085
86 @test.idempotent_id('6489632f-8550-4453-a674-c98849742967')
87 @test.requires_ext(extension="security-group", service="network")
88 def test_update_port_sg_binding_bumps_revision(self):
89 net = self.create_network()
90 port = self.create_port(net)
91 sg = self._create_security_group()[0]
92 self.client.update_port(
93 port['id'], security_groups=[sg['security_group']['id']])
94 updated = self.client.show_port(port['id'])
Kevin Bentona2bd97b2016-09-19 20:05:25 -070095 updated2 = self.client.update_port(port['id'], security_groups=[])
Kevin Benton2f067902016-09-02 17:14:37 -070096 self.assertGreater(updated['port']['revision_number'],
97 port['revision_number'])
98 self.assertGreater(updated2['port']['revision_number'],
99 updated['port']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700100
101 @test.idempotent_id('29c7ab2b-d1d8-425d-8cec-fcf632960f22')
102 @test.requires_ext(extension="security-group", service="network")
103 def test_update_sg_rule_bumps_sg_revision(self):
104 sg, name = self._create_security_group()
105 rule = self.client.create_security_group_rule(
106 security_group_id=sg['security_group']['id'],
107 protocol='tcp', direction='ingress', ethertype=self.ethertype,
108 port_range_min=60, port_range_max=70)
109 updated = self.client.show_security_group(sg['security_group']['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700110 self.assertGreater(updated['security_group']['revision_number'],
111 sg['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700112 self.client.delete_security_group_rule(
113 rule['security_group_rule']['id'])
114 updated2 = self.client.show_security_group(sg['security_group']['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700115 self.assertGreater(updated2['security_group']['revision_number'],
116 updated['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700117
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700118 @test.idempotent_id('db70c285-0365-4fac-9f55-2a0ad8cf55a8')
119 @test.requires_ext(extension="allowed-address-pairs", service="network")
120 def test_update_allowed_address_pairs_bumps_revision(self):
121 net = self.create_network()
122 port = self.create_port(net)
123 updated = self.client.update_port(
124 port['id'], allowed_address_pairs=[{'ip_address': '1.1.1.1/32'}])
125 self.assertGreater(updated['port']['revision_number'],
126 port['revision_number'])
127 updated2 = self.client.update_port(
128 port['id'], allowed_address_pairs=[])
129 self.assertGreater(updated2['port']['revision_number'],
130 updated['port']['revision_number'])
131
132 @test.idempotent_id('a21ec3b4-3569-4b77-bf29-4177edaa2df5')
133 @test.requires_ext(extension="extra_dhcp_opt", service="network")
134 def test_update_extra_dhcp_opt_bumps_revision(self):
135 net = self.create_network()
136 port = self.create_port(net)
137 opts = [{'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'}]
138 updated = self.client.update_port(port['id'], extra_dhcp_opts=opts)
139 self.assertGreater(updated['port']['revision_number'],
140 port['revision_number'])
141 opts[0]['opt_value'] = 'pxelinux.77'
142 updated2 = self.client.update_port(
143 port['id'], extra_dhcp_opts=opts)
144 self.assertGreater(updated2['port']['revision_number'],
145 updated['port']['revision_number'])
146
147 @test.idempotent_id('40ba648f-f374-4c29-a5b7-489dd5a38a4e')
148 @test.requires_ext(extension="dns-integration", service="network")
149 def test_update_dns_domain_bumps_revision(self):
150 net = self.create_network(dns_domain='example.test.')
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700151 updated = self.client.update_network(net['id'], dns_domain='exa.test.')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700152 self.assertGreater(updated['network']['revision_number'],
153 net['revision_number'])
154 port = self.create_port(net)
155 updated = self.client.update_port(port['id'], dns_name='port1')
156 if not updated['port']['dns_name']:
157 self.skipTest("Server does not have DNS domain configured.")
158 self.assertGreater(updated['port']['revision_number'],
159 port['revision_number'])
160 updated2 = self.client.update_port(port['id'], dns_name='')
161 self.assertGreater(updated2['port']['revision_number'],
162 updated['port']['revision_number'])
163
164 @test.idempotent_id('8482324f-cf59-4d73-b98e-d37119255300')
165 @test.requires_ext(extension="router", service="network")
166 @test.requires_ext(extension="extraroute", service="network")
167 def test_update_router_extra_routes_bumps_revision(self):
168 subnet = self.create_subnet(self.create_network())
169 subgateway = netaddr.IPAddress(subnet['gateway_ip'])
170 router = self.create_router(router_name='test')
171 self.create_router_interface(router['id'], subnet['id'])
172 router = self.client.show_router(router['id'])['router']
Omer Ansond1586832016-10-10 22:46:32 +0300173 updated = self.client.update_extra_routes(
174 router['id'], str(subgateway + 1), '2.0.0.0/24')
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700175 self.assertGreater(updated['router']['revision_number'],
176 router['revision_number'])
Omer Ansond1586832016-10-10 22:46:32 +0300177 updated2 = self.client.delete_extra_routes(router['id'])
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700178 self.assertGreater(updated2['router']['revision_number'],
179 updated['router']['revision_number'])
180
181 @test.idempotent_id('6bd18702-e25a-4b4b-8c0c-680113533511')
182 @test.requires_ext(extension="subnet-service-types", service="network")
183 def test_update_subnet_service_types_bumps_revisions(self):
184 subnet = self.create_subnet(self.create_network())
185 updated = self.client.update_subnet(
186 subnet['id'], service_types=['compute:'])
187 self.assertGreater(updated['subnet']['revision_number'],
188 subnet['revision_number'])
189 updated2 = self.client.update_subnet(
190 subnet['id'], service_types=[])
191 self.assertGreater(updated2['subnet']['revision_number'],
192 updated['subnet']['revision_number'])
193
194 @test.idempotent_id('9c83105c-9973-45ff-9ca2-e66d64700abe')
195 @test.requires_ext(extension="port-security", service="network")
196 def test_update_port_security_bumps_revisions(self):
197 net = self.create_network(port_security_enabled=False)
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700198 updated = self.client.update_network(net['id'],
199 port_security_enabled=True)
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700200 self.assertGreater(updated['network']['revision_number'],
201 net['revision_number'])
Kevin Bentonf46e7a22016-09-24 23:07:45 -0700202 updated2 = self.client.update_network(net['id'],
203 port_security_enabled=False)
Kevin Bentona2ceb2d2016-09-22 17:52:25 -0700204 self.assertGreater(updated2['network']['revision_number'],
205 updated['network']['revision_number'])
206 port = self.create_port(net, port_security_enabled=False)
207 updated = self.client.update_port(port['id'],
208 port_security_enabled=True)
209 self.assertGreater(updated['port']['revision_number'],
210 port['revision_number'])
211 updated2 = self.client.update_port(port['id'],
212 port_security_enabled=False)
213 self.assertGreater(updated2['port']['revision_number'],
214 updated['port']['revision_number'])
215
216 @test.idempotent_id('68d5ac3a-11a1-4847-8e2e-5843c043d89b')
217 @test.requires_ext(extension="binding", service="network")
218 def test_portbinding_bumps_revision(self):
219 port = self.create_port(self.create_network())
220 port = self.admin_client.update_port(
221 port['id'], **{'binding:host_id': 'badhost1'})['port']
222 updated = self.admin_client.update_port(
223 port['id'], **{'binding:host_id': 'badhost2'})['port']
224 self.assertGreater(updated['revision_number'],
225 port['revision_number'])
226
Kevin Benton183b7be2016-03-24 22:14:58 -0700227 @test.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0')
228 @test.requires_ext(extension="router", service="network")
229 def test_update_router_bumps_revision(self):
230 subnet = self.create_subnet(self.create_network())
231 router = self.create_router(router_name='test')
Kevin Benton2f067902016-09-02 17:14:37 -0700232 self.assertIn('revision_number', router)
233 rev1 = router['revision_number']
Kevin Benton183b7be2016-03-24 22:14:58 -0700234 router = self.client.update_router(router['id'],
235 name='test2')['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700236 self.assertGreater(router['revision_number'], rev1)
Kevin Benton183b7be2016-03-24 22:14:58 -0700237 self.create_router_interface(router['id'], subnet['id'])
238 updated = self.client.show_router(router['id'])['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700239 self.assertGreater(updated['revision_number'],
240 router['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700241
242 @test.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9')
243 @test.requires_ext(extension="router", service="network")
244 @test.requires_ext(extension="standard-attr-description",
245 service="network")
246 def test_update_floatingip_bumps_revision(self):
247 ext_id = config.CONF.network.public_network_id
248 network = self.create_network()
249 subnet = self.create_subnet(network)
250 router = self.create_router('test', external_network_id=ext_id)
251 self.create_router_interface(router['id'], subnet['id'])
252 port = self.create_port(network)
253 body = self.client.create_floatingip(
254 floating_network_id=ext_id,
255 port_id=port['id'],
256 description='d1'
257 )['floatingip']
Kevin Benton2f067902016-09-02 17:14:37 -0700258 self.assertIn('revision_number', body)
Kevin Benton183b7be2016-03-24 22:14:58 -0700259 b2 = self.client.update_floatingip(body['id'], description='d2')
Kevin Benton2f067902016-09-02 17:14:37 -0700260 self.assertGreater(b2['floatingip']['revision_number'],
261 body['revision_number'])
LIU Yulong39e5f102016-05-05 14:52:26 +0800262 # disassociate
263 self.client.update_floatingip(b2['floatingip']['id'], port_id=None)
Lujinba9a4922016-11-21 18:19:04 +0900264
265 @test.idempotent_id('afb6486c-41b5-483e-a500-3c506f4deb49')
266 @test.requires_ext(extension="router", service="network")
267 @test.requires_ext(extension="dvr", service="network")
268 def test_update_router_extra_attributes_bumps_revision(self):
269 router = self.create_router(router_name='r1')
270 self.assertIn('revision_number', router)
271 rev1 = router['revision_number']
272 router = self.admin_client.update_router(
273 router['id'], admin_state_up=False)['router']
274 self.assertGreater(router['revision_number'], rev1)
275 self.admin_client.update_router(router['id'],
276 distributed=True)['router']
277 updated = self.client.show_router(router['id'])['router']
278 self.assertGreater(updated['revision_number'],
279 router['revision_number'])
280
281 @test.idempotent_id('90743b00-b0e2-40e4-9524-1c884fe3ef23')
Kevin Benton3e305972016-12-28 02:05:29 -0800282 @test.requires_ext(extension="external-net", service="network")
Lujinba9a4922016-11-21 18:19:04 +0900283 @test.requires_ext(extension="auto-allocated-topology", service="network")
284 @test.requires_ext(extension="subnet_allocation", service="network")
285 @test.requires_ext(extension="router", service="network")
286 def test_update_external_network_bumps_revision(self):
287 net = self.create_network()
288 self.assertIn('revision_number', net)
289 updated = self.admin_client.update_network(net['id'],
290 **{'router:external': True})
291 self.assertGreater(updated['network']['revision_number'],
292 net['revision_number'])
293
294 @test.idempotent_id('5af6450a-0f61-49c3-b628-38db77c7b856')
295 @test.requires_ext(extension="qos", service="network")
296 def test_update_qos_port_policy_binding_bumps_revision(self):
297 policy = self.create_qos_policy(name='port-policy', shared=False)
298 port = self.create_port(self.create_network())
299 self.addCleanup(self.client.delete_port, port['id'])
300 updated = self.admin_client.update_port(
301 port['id'], qos_policy_id=policy['id'])
302 self.assertGreater(updated['port']['revision_number'],
303 port['revision_number'])
304
305 @test.idempotent_id('817da343-c6e4-445c-9519-a621f124dfbe')
306 @test.requires_ext(extension="qos", service="network")
307 def test_update_qos_network_policy_binding_bumps_revision(self):
308 policy = self.create_qos_policy(name='network-policy', shared=False)
309 network = self.create_network()
310 self.addCleanup(self.client.delete_network, network['id'])
311 updated = self.admin_client.update_network(
312 network['id'], qos_policy_id=policy['id'])
313 self.assertGreater(updated['network']['revision_number'],
314 network['revision_number'])