blob: 10438b72ce0e60036e8c6110fc022a497ec577e5 [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
13from tempest import test
14
15from neutron.tests.tempest.api import base
16from neutron.tests.tempest.api import base_security_groups as bsg
17from neutron.tests.tempest import config
18
19
20class TestRevisions(base.BaseAdminNetworkTest, bsg.BaseSecGroupTest):
21
22 @classmethod
Kevin Bentonb944fcb2016-09-02 00:26:42 -060023 @test.requires_ext(extension="standard-attr-revisions", service="network")
Kevin Benton183b7be2016-03-24 22:14:58 -070024 def skip_checks(cls):
25 super(TestRevisions, cls).skip_checks()
26
27 @test.idempotent_id('4a26a4be-9c53-483c-bc50-b53f1db10ac6')
28 def test_update_network_bumps_revision(self):
29 net = self.create_network()
Kevin Benton2f067902016-09-02 17:14:37 -070030 self.assertIn('revision_number', net)
Kevin Benton183b7be2016-03-24 22:14:58 -070031 updated = self.client.update_network(net['id'], name='newnet')
Kevin Benton2f067902016-09-02 17:14:37 -070032 self.assertGreater(updated['network']['revision_number'],
33 net['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070034
35 @test.idempotent_id('cac7ecde-12d5-4331-9a03-420899dea077')
36 def test_update_port_bumps_revision(self):
37 net = self.create_network()
38 port = self.create_port(net)
Kevin Benton2f067902016-09-02 17:14:37 -070039 self.assertIn('revision_number', port)
Kevin Benton183b7be2016-03-24 22:14:58 -070040 updated = self.client.update_port(port['id'], name='newport')
Kevin Benton2f067902016-09-02 17:14:37 -070041 self.assertGreater(updated['port']['revision_number'],
42 port['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070043
44 @test.idempotent_id('c1c4fa41-8e89-44d0-9bfc-409f3b66dc57')
45 def test_update_subnet_bumps_revision(self):
46 net = self.create_network()
47 subnet = self.create_subnet(net)
Kevin Benton2f067902016-09-02 17:14:37 -070048 self.assertIn('revision_number', subnet)
Kevin Benton183b7be2016-03-24 22:14:58 -070049 updated = self.client.update_subnet(subnet['id'], name='newsub')
Kevin Benton2f067902016-09-02 17:14:37 -070050 self.assertGreater(updated['subnet']['revision_number'],
51 subnet['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070052
53 @test.idempotent_id('e8c5d7db-2b8d-4615-a476-6e537437c4f2')
54 def test_update_subnetpool_bumps_revision(self):
55 sp = self.create_subnetpool('subnetpool', default_prefixlen=24,
56 prefixes=['10.0.0.0/8'])
Kevin Benton2f067902016-09-02 17:14:37 -070057 self.assertIn('revision_number', sp)
Kevin Benton183b7be2016-03-24 22:14:58 -070058 updated = self.admin_client.update_subnetpool(sp['id'], name='sp2')
Kevin Benton2f067902016-09-02 17:14:37 -070059 self.assertGreater(updated['subnetpool']['revision_number'],
60 sp['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070061
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070062 @test.idempotent_id('e8c5d7db-2b8d-4567-a326-6e123437c4d1')
63 def test_update_subnet_bumps_network_revision(self):
64 net = self.create_network()
65 subnet = self.create_subnet(net)
66 updated = self.client.show_network(net['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070067 self.assertGreater(updated['network']['revision_number'],
68 net['revision_number'])
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070069 self.client.delete_subnet(subnet['id'])
70 updated2 = self.client.show_network(net['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070071 self.assertGreater(updated2['network']['revision_number'],
72 updated['network']['revision_number'])
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070073
Kevin Benton183b7be2016-03-24 22:14:58 -070074 @test.idempotent_id('6c256f71-c929-4200-b3dc-4e1843506be5')
75 @test.requires_ext(extension="security-group", service="network")
76 def test_update_sg_group_bumps_revision(self):
77 sg, name = self._create_security_group()
Kevin Benton2f067902016-09-02 17:14:37 -070078 self.assertIn('revision_number', sg['security_group'])
Kevin Benton183b7be2016-03-24 22:14:58 -070079 update_body = self.client.update_security_group(
80 sg['security_group']['id'], name='new_sg_name')
Kevin Benton2f067902016-09-02 17:14:37 -070081 self.assertGreater(update_body['security_group']['revision_number'],
82 sg['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -070083
84 @test.idempotent_id('6489632f-8550-4453-a674-c98849742967')
85 @test.requires_ext(extension="security-group", service="network")
86 def test_update_port_sg_binding_bumps_revision(self):
87 net = self.create_network()
88 port = self.create_port(net)
89 sg = self._create_security_group()[0]
90 self.client.update_port(
91 port['id'], security_groups=[sg['security_group']['id']])
92 updated = self.client.show_port(port['id'])
93 self.client.update_port(port['id'], security_groups=[])
94 # TODO(kevinbenton): these extra shows after after the update are
95 # to work around the fact that ML2 creates the result dict before
96 # commit happens if the port is unbound. The update response should
97 # be usable directly once that is fixed.
98 updated2 = self.client.show_port(port['id'])
Kevin Benton2f067902016-09-02 17:14:37 -070099 self.assertGreater(updated['port']['revision_number'],
100 port['revision_number'])
101 self.assertGreater(updated2['port']['revision_number'],
102 updated['port']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700103
104 @test.idempotent_id('29c7ab2b-d1d8-425d-8cec-fcf632960f22')
105 @test.requires_ext(extension="security-group", service="network")
106 def test_update_sg_rule_bumps_sg_revision(self):
107 sg, name = self._create_security_group()
108 rule = self.client.create_security_group_rule(
109 security_group_id=sg['security_group']['id'],
110 protocol='tcp', direction='ingress', ethertype=self.ethertype,
111 port_range_min=60, port_range_max=70)
112 updated = self.client.show_security_group(sg['security_group']['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700113 self.assertGreater(updated['security_group']['revision_number'],
114 sg['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700115 self.client.delete_security_group_rule(
116 rule['security_group_rule']['id'])
117 updated2 = self.client.show_security_group(sg['security_group']['id'])
Kevin Benton2f067902016-09-02 17:14:37 -0700118 self.assertGreater(updated2['security_group']['revision_number'],
119 updated['security_group']['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700120
121 @test.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0')
122 @test.requires_ext(extension="router", service="network")
123 def test_update_router_bumps_revision(self):
124 subnet = self.create_subnet(self.create_network())
125 router = self.create_router(router_name='test')
Kevin Benton2f067902016-09-02 17:14:37 -0700126 self.assertIn('revision_number', router)
127 rev1 = router['revision_number']
Kevin Benton183b7be2016-03-24 22:14:58 -0700128 router = self.client.update_router(router['id'],
129 name='test2')['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700130 self.assertGreater(router['revision_number'], rev1)
Kevin Benton183b7be2016-03-24 22:14:58 -0700131 self.create_router_interface(router['id'], subnet['id'])
132 updated = self.client.show_router(router['id'])['router']
Kevin Benton2f067902016-09-02 17:14:37 -0700133 self.assertGreater(updated['revision_number'],
134 router['revision_number'])
Kevin Benton183b7be2016-03-24 22:14:58 -0700135
136 @test.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9')
137 @test.requires_ext(extension="router", service="network")
138 @test.requires_ext(extension="standard-attr-description",
139 service="network")
140 def test_update_floatingip_bumps_revision(self):
141 ext_id = config.CONF.network.public_network_id
142 network = self.create_network()
143 subnet = self.create_subnet(network)
144 router = self.create_router('test', external_network_id=ext_id)
145 self.create_router_interface(router['id'], subnet['id'])
146 port = self.create_port(network)
147 body = self.client.create_floatingip(
148 floating_network_id=ext_id,
149 port_id=port['id'],
150 description='d1'
151 )['floatingip']
Kevin Benton2f067902016-09-02 17:14:37 -0700152 self.assertIn('revision_number', body)
Kevin Benton183b7be2016-03-24 22:14:58 -0700153 b2 = self.client.update_floatingip(body['id'], description='d2')
Kevin Benton2f067902016-09-02 17:14:37 -0700154 self.assertGreater(b2['floatingip']['revision_number'],
155 body['revision_number'])
LIU Yulong39e5f102016-05-05 14:52:26 +0800156 # disassociate
157 self.client.update_floatingip(b2['floatingip']['id'], port_id=None)