blob: 4284649fff200f0ffb165685049f62fe0129b802 [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
23 @test.requires_ext(extension="revisions", service="network")
24 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()
30 self.assertIn('revision', net)
31 updated = self.client.update_network(net['id'], name='newnet')
32 self.assertGreater(updated['network']['revision'], net['revision'])
33
34 @test.idempotent_id('cac7ecde-12d5-4331-9a03-420899dea077')
35 def test_update_port_bumps_revision(self):
36 net = self.create_network()
37 port = self.create_port(net)
38 self.assertIn('revision', port)
39 updated = self.client.update_port(port['id'], name='newport')
40 self.assertGreater(updated['port']['revision'], port['revision'])
41
42 @test.idempotent_id('c1c4fa41-8e89-44d0-9bfc-409f3b66dc57')
43 def test_update_subnet_bumps_revision(self):
44 net = self.create_network()
45 subnet = self.create_subnet(net)
46 self.assertIn('revision', subnet)
47 updated = self.client.update_subnet(subnet['id'], name='newsub')
48 self.assertGreater(updated['subnet']['revision'], subnet['revision'])
49
50 @test.idempotent_id('e8c5d7db-2b8d-4615-a476-6e537437c4f2')
51 def test_update_subnetpool_bumps_revision(self):
52 sp = self.create_subnetpool('subnetpool', default_prefixlen=24,
53 prefixes=['10.0.0.0/8'])
54 self.assertIn('revision', sp)
55 updated = self.admin_client.update_subnetpool(sp['id'], name='sp2')
56 self.assertGreater(updated['subnetpool']['revision'], sp['revision'])
57
Nam Nguyen Hoai2984b6d2016-08-05 09:46:43 +070058 @test.idempotent_id('e8c5d7db-2b8d-4567-a326-6e123437c4d1')
59 def test_update_subnet_bumps_network_revision(self):
60 net = self.create_network()
61 subnet = self.create_subnet(net)
62 updated = self.client.show_network(net['id'])
63 self.assertGreater(updated['network']['revision'], net['revision'])
64 self.client.delete_subnet(subnet['id'])
65 updated2 = self.client.show_network(net['id'])
66 self.assertGreater(updated2['network']['revision'],
67 updated['network']['revision'])
68
Kevin Benton183b7be2016-03-24 22:14:58 -070069 @test.idempotent_id('6c256f71-c929-4200-b3dc-4e1843506be5')
70 @test.requires_ext(extension="security-group", service="network")
71 def test_update_sg_group_bumps_revision(self):
72 sg, name = self._create_security_group()
73 self.assertIn('revision', sg['security_group'])
74 update_body = self.client.update_security_group(
75 sg['security_group']['id'], name='new_sg_name')
76 self.assertGreater(update_body['security_group']['revision'],
77 sg['security_group']['revision'])
78
79 @test.idempotent_id('6489632f-8550-4453-a674-c98849742967')
80 @test.requires_ext(extension="security-group", service="network")
81 def test_update_port_sg_binding_bumps_revision(self):
82 net = self.create_network()
83 port = self.create_port(net)
84 sg = self._create_security_group()[0]
85 self.client.update_port(
86 port['id'], security_groups=[sg['security_group']['id']])
87 updated = self.client.show_port(port['id'])
88 self.client.update_port(port['id'], security_groups=[])
89 # TODO(kevinbenton): these extra shows after after the update are
90 # to work around the fact that ML2 creates the result dict before
91 # commit happens if the port is unbound. The update response should
92 # be usable directly once that is fixed.
93 updated2 = self.client.show_port(port['id'])
94 self.assertGreater(updated['port']['revision'], port['revision'])
95 self.assertGreater(updated2['port']['revision'],
96 updated['port']['revision'])
97
98 @test.idempotent_id('29c7ab2b-d1d8-425d-8cec-fcf632960f22')
99 @test.requires_ext(extension="security-group", service="network")
100 def test_update_sg_rule_bumps_sg_revision(self):
101 sg, name = self._create_security_group()
102 rule = self.client.create_security_group_rule(
103 security_group_id=sg['security_group']['id'],
104 protocol='tcp', direction='ingress', ethertype=self.ethertype,
105 port_range_min=60, port_range_max=70)
106 updated = self.client.show_security_group(sg['security_group']['id'])
107 self.assertGreater(updated['security_group']['revision'],
108 sg['security_group']['revision'])
109 self.client.delete_security_group_rule(
110 rule['security_group_rule']['id'])
111 updated2 = self.client.show_security_group(sg['security_group']['id'])
112 self.assertGreater(updated2['security_group']['revision'],
113 updated['security_group']['revision'])
114
115 @test.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0')
116 @test.requires_ext(extension="router", service="network")
117 def test_update_router_bumps_revision(self):
118 subnet = self.create_subnet(self.create_network())
119 router = self.create_router(router_name='test')
120 self.assertIn('revision', router)
121 rev1 = router['revision']
122 router = self.client.update_router(router['id'],
123 name='test2')['router']
124 self.assertGreater(router['revision'], rev1)
125 self.create_router_interface(router['id'], subnet['id'])
126 updated = self.client.show_router(router['id'])['router']
127 self.assertGreater(updated['revision'], router['revision'])
128
129 @test.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9')
130 @test.requires_ext(extension="router", service="network")
131 @test.requires_ext(extension="standard-attr-description",
132 service="network")
133 def test_update_floatingip_bumps_revision(self):
134 ext_id = config.CONF.network.public_network_id
135 network = self.create_network()
136 subnet = self.create_subnet(network)
137 router = self.create_router('test', external_network_id=ext_id)
138 self.create_router_interface(router['id'], subnet['id'])
139 port = self.create_port(network)
140 body = self.client.create_floatingip(
141 floating_network_id=ext_id,
142 port_id=port['id'],
143 description='d1'
144 )['floatingip']
145 self.assertIn('revision', body)
146 b2 = self.client.update_floatingip(body['id'], description='d2')
147 self.assertGreater(b2['floatingip']['revision'], body['revision'])