blob: 6c36cf616b2862d12c612e4a5f3f6aa2f75e88b7 [file] [log] [blame]
Daniel Mellado3c0aeab2016-01-29 11:30:25 +00001# 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
13import copy
14
15from tempest.lib.common.utils import data_utils
16from tempest import test
17
18from neutron.tests.tempest.api import base
19
20
21class TestTimeStamp(base.BaseAdminNetworkTest):
22
23 ## attributes for subnetpool
24 min_prefixlen = '28'
25 max_prefixlen = '31'
26 _ip_version = 4
27 subnet_cidr = '10.11.12.0/31'
28 new_prefix = '10.11.15.0/24'
29 larger_prefix = '10.11.0.0/16'
30
31 @classmethod
32 @test.requires_ext(extension="timestamp_core", service="network")
33 def skip_checks(cls):
34 super(TestTimeStamp, cls).skip_checks()
35
36 @classmethod
37 def resource_setup(cls):
38 super(TestTimeStamp, cls).resource_setup()
39 prefixes = ['10.11.12.0/24']
40 cls._subnetpool_data = {'min_prefixlen': '29', 'prefixes': prefixes}
41
42 def _create_subnetpool(self, is_admin=False, **kwargs):
43 name = data_utils.rand_name('subnetpool-')
44 subnetpool_data = copy.deepcopy(self._subnetpool_data)
45 for key in subnetpool_data.keys():
46 kwargs[key] = subnetpool_data[key]
47 return self.create_subnetpool(name=name, is_admin=is_admin, **kwargs)
48
49 @test.idempotent_id('462be770-b310-4df9-9c42-773217e4c8b1')
50 def test_create_network_with_timestamp(self):
51 network = self.create_network()
52 # Verifies body contains timestamp fields
53 self.assertIsNotNone(network['created_at'])
54 self.assertIsNotNone(network['updated_at'])
55
56 @test.idempotent_id('4db5417a-e11c-474d-a361-af00ebef57c5')
57 def test_update_network_with_timestamp(self):
58 network = self.create_network()
59 origin_updated_at = network['updated_at']
60 update_body = {'name': network['name'] + 'new'}
61 body = self.admin_client.update_network(network['id'],
62 **update_body)
63 updated_network = body['network']
64 new_updated_at = updated_network['updated_at']
65 self.assertEqual(network['created_at'], updated_network['created_at'])
66 # Verify that origin_updated_at is not same with new_updated_at
67 self.assertIsNot(origin_updated_at, new_updated_at)
68
69 @test.idempotent_id('2ac50ab2-7ebd-4e27-b3ce-a9e399faaea2')
70 def test_show_networks_attribute_with_timestamp(self):
71 network = self.create_network()
72 body = self.client.show_network(network['id'])
73 show_net = body['network']
74 # verify the timestamp from creation and showed is same
75 self.assertEqual(network['created_at'],
76 show_net['created_at'])
77 self.assertEqual(network['updated_at'],
78 show_net['updated_at'])
79
80 @test.idempotent_id('8ee55186-454f-4b97-9f9f-eb2772ee891c')
81 def test_create_subnet_with_timestamp(self):
82 network = self.create_network()
83 subnet = self.create_subnet(network)
84 # Verifies body contains timestamp fields
85 self.assertIsNotNone(subnet['created_at'])
86 self.assertIsNotNone(subnet['updated_at'])
87
88 @test.idempotent_id('a490215a-6f4c-4af9-9a4c-57c41f1c4fa1')
89 def test_update_subnet_with_timestamp(self):
90 network = self.create_network()
91 subnet = self.create_subnet(network)
92 origin_updated_at = subnet['updated_at']
93 update_body = {'name': subnet['name'] + 'new'}
94 body = self.admin_client.update_subnet(subnet['id'],
95 **update_body)
96 updated_subnet = body['subnet']
97 new_updated_at = updated_subnet['updated_at']
98 self.assertEqual(subnet['created_at'], updated_subnet['created_at'])
99 # Verify that origin_updated_at is not same with new_updated_at
100 self.assertIsNot(origin_updated_at, new_updated_at)
101
102 @test.idempotent_id('1836a086-e7cf-4141-bf57-0cfe79e8051e')
103 def test_show_subnet_attribute_with_timestamp(self):
104 network = self.create_network()
105 subnet = self.create_subnet(network)
106 body = self.client.show_subnet(subnet['id'])
107 show_subnet = body['subnet']
108 # verify the timestamp from creation and showed is same
109 self.assertEqual(subnet['created_at'],
110 show_subnet['created_at'])
111 self.assertEqual(subnet['updated_at'],
112 show_subnet['updated_at'])
113
114 @test.idempotent_id('e2450a7b-d84f-4600-a093-45e78597bbac')
115 def test_create_port_with_timestamp(self):
116 network = self.create_network()
117 port = self.create_port(network)
118 # Verifies body contains timestamp fields
119 self.assertIsNotNone(port['created_at'])
120 self.assertIsNotNone(port['updated_at'])
121
122 @test.idempotent_id('4241e0d3-54b4-46ce-a9a7-093fc764161b')
123 def test_update_port_with_timestamp(self):
124 network = self.create_network()
125 port = self.create_port(network)
126 origin_updated_at = port['updated_at']
127 update_body = {'name': port['name'] + 'new'}
128 body = self.admin_client.update_port(port['id'],
129 **update_body)
130 updated_port = body['port']
131 new_updated_at = updated_port['updated_at']
132 self.assertEqual(port['created_at'], updated_port['created_at'])
133 # Verify that origin_updated_at is not same with new_updated_at
134 self.assertIsNot(origin_updated_at, new_updated_at)
135
136 @test.idempotent_id('584c6723-40b6-4f26-81dd-f508f9d9fb51')
137 def test_show_port_attribute_with_timestamp(self):
138 network = self.create_network()
139 port = self.create_port(network)
140 body = self.client.show_port(port['id'])
141 show_port = body['port']
142 # verify the timestamp from creation and showed is same
143 self.assertEqual(port['created_at'],
144 show_port['created_at'])
145 self.assertEqual(port['updated_at'],
146 show_port['updated_at'])
147
148 @test.idempotent_id('87a8b196-4b90-44f0-b7f3-d2057d7d658e')
149 def test_create_subnetpool_with_timestamp(self):
150 sp = self._create_subnetpool()
151 # Verifies body contains timestamp fields
152 self.assertIsNotNone(sp['created_at'])
153 self.assertIsNotNone(sp['updated_at'])
154
155 @test.idempotent_id('d48c7578-c3d2-4f9b-a7a1-be2008c770a0')
156 def test_update_subnetpool_with_timestamp(self):
157 sp = self._create_subnetpool()
158 origin_updated_at = sp['updated_at']
159 update_body = {'name': sp['name'] + 'new',
160 'min_prefixlen': self.min_prefixlen,
161 'max_prefixlen': self.max_prefixlen}
162 body = self.client.update_subnetpool(sp['id'], **update_body)
163 updated_sp = body['subnetpool']
164 new_updated_at = updated_sp['updated_at']
165 self.assertEqual(sp['created_at'], updated_sp['created_at'])
166 # Verify that origin_updated_at is not same with new_updated_at
167 self.assertIsNot(origin_updated_at, new_updated_at)
168
169 @test.idempotent_id('1d3970e6-bcf7-46cd-b7d7-0807759c73b4')
170 def test_show_subnetpool_attribute_with_timestamp(self):
171 sp = self._create_subnetpool()
172 body = self.client.show_subnetpool(sp['id'])
173 show_sp = body['subnetpool']
174 # verify the timestamp from creation and showed is same
175 self.assertEqual(sp['created_at'], show_sp['created_at'])
176 self.assertEqual(sp['updated_at'], show_sp['updated_at'])