Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1 | # 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 | |
| 13 | import copy |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 14 | import time |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 15 | |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 16 | from neutron_lib import constants |
Hongbin Lu | 7681a5c | 2018-04-18 15:54:45 +0000 | [diff] [blame] | 17 | from tempest.common import utils |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 18 | from tempest.lib.common.utils import data_utils |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 19 | from tempest.lib import decorators |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 20 | |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 21 | from neutron_tempest_plugin.api import base |
| 22 | from neutron_tempest_plugin.api import base_routers |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 23 | from neutron_tempest_plugin import config |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 24 | |
| 25 | CONF = config.CONF |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 26 | |
| 27 | |
| 28 | class TestTimeStamp(base.BaseAdminNetworkTest): |
| 29 | |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 30 | required_extensions = ["standard-attr-timestamp"] |
| 31 | |
Brian Haley | 6767cec | 2018-04-10 15:30:23 -0400 | [diff] [blame] | 32 | # attributes for subnetpool |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 33 | min_prefixlen = '28' |
| 34 | max_prefixlen = '31' |
| 35 | _ip_version = 4 |
| 36 | subnet_cidr = '10.11.12.0/31' |
| 37 | new_prefix = '10.11.15.0/24' |
| 38 | larger_prefix = '10.11.0.0/16' |
| 39 | |
| 40 | @classmethod |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 41 | def resource_setup(cls): |
| 42 | super(TestTimeStamp, cls).resource_setup() |
| 43 | prefixes = ['10.11.12.0/24'] |
| 44 | cls._subnetpool_data = {'min_prefixlen': '29', 'prefixes': prefixes} |
| 45 | |
| 46 | def _create_subnetpool(self, is_admin=False, **kwargs): |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 47 | name = data_utils.rand_name('subnetpool') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 48 | subnetpool_data = copy.deepcopy(self._subnetpool_data) |
| 49 | for key in subnetpool_data.keys(): |
| 50 | kwargs[key] = subnetpool_data[key] |
| 51 | return self.create_subnetpool(name=name, is_admin=is_admin, **kwargs) |
| 52 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 53 | @decorators.idempotent_id('462be770-b310-4df9-9c42-773217e4c8b1') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 54 | def test_create_network_with_timestamp(self): |
| 55 | network = self.create_network() |
| 56 | # Verifies body contains timestamp fields |
| 57 | self.assertIsNotNone(network['created_at']) |
| 58 | self.assertIsNotNone(network['updated_at']) |
| 59 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 60 | @decorators.idempotent_id('4db5417a-e11c-474d-a361-af00ebef57c5') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 61 | def test_update_network_with_timestamp(self): |
| 62 | network = self.create_network() |
| 63 | origin_updated_at = network['updated_at'] |
| 64 | update_body = {'name': network['name'] + 'new'} |
| 65 | body = self.admin_client.update_network(network['id'], |
| 66 | **update_body) |
| 67 | updated_network = body['network'] |
| 68 | new_updated_at = updated_network['updated_at'] |
| 69 | self.assertEqual(network['created_at'], updated_network['created_at']) |
| 70 | # Verify that origin_updated_at is not same with new_updated_at |
| 71 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 72 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 73 | @decorators.idempotent_id('2ac50ab2-7ebd-4e27-b3ce-a9e399faaea2') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 74 | def test_show_networks_attribute_with_timestamp(self): |
| 75 | network = self.create_network() |
| 76 | body = self.client.show_network(network['id']) |
| 77 | show_net = body['network'] |
| 78 | # verify the timestamp from creation and showed is same |
| 79 | self.assertEqual(network['created_at'], |
| 80 | show_net['created_at']) |
| 81 | self.assertEqual(network['updated_at'], |
| 82 | show_net['updated_at']) |
| 83 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 84 | @decorators.idempotent_id('8ee55186-454f-4b97-9f9f-eb2772ee891c') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 85 | def test_create_subnet_with_timestamp(self): |
| 86 | network = self.create_network() |
| 87 | subnet = self.create_subnet(network) |
| 88 | # Verifies body contains timestamp fields |
| 89 | self.assertIsNotNone(subnet['created_at']) |
| 90 | self.assertIsNotNone(subnet['updated_at']) |
| 91 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 92 | @decorators.idempotent_id('a490215a-6f4c-4af9-9a4c-57c41f1c4fa1') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 93 | def test_update_subnet_with_timestamp(self): |
| 94 | network = self.create_network() |
| 95 | subnet = self.create_subnet(network) |
| 96 | origin_updated_at = subnet['updated_at'] |
| 97 | update_body = {'name': subnet['name'] + 'new'} |
| 98 | body = self.admin_client.update_subnet(subnet['id'], |
| 99 | **update_body) |
| 100 | updated_subnet = body['subnet'] |
| 101 | new_updated_at = updated_subnet['updated_at'] |
| 102 | self.assertEqual(subnet['created_at'], updated_subnet['created_at']) |
| 103 | # Verify that origin_updated_at is not same with new_updated_at |
| 104 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 105 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 106 | @decorators.idempotent_id('1836a086-e7cf-4141-bf57-0cfe79e8051e') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 107 | def test_show_subnet_attribute_with_timestamp(self): |
| 108 | network = self.create_network() |
| 109 | subnet = self.create_subnet(network) |
| 110 | body = self.client.show_subnet(subnet['id']) |
| 111 | show_subnet = body['subnet'] |
| 112 | # verify the timestamp from creation and showed is same |
| 113 | self.assertEqual(subnet['created_at'], |
| 114 | show_subnet['created_at']) |
| 115 | self.assertEqual(subnet['updated_at'], |
| 116 | show_subnet['updated_at']) |
| 117 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 118 | @decorators.idempotent_id('e2450a7b-d84f-4600-a093-45e78597bbac') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 119 | def test_create_port_with_timestamp(self): |
| 120 | network = self.create_network() |
| 121 | port = self.create_port(network) |
| 122 | # Verifies body contains timestamp fields |
| 123 | self.assertIsNotNone(port['created_at']) |
| 124 | self.assertIsNotNone(port['updated_at']) |
| 125 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 126 | @decorators.idempotent_id('4241e0d3-54b4-46ce-a9a7-093fc764161b') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 127 | def test_update_port_with_timestamp(self): |
| 128 | network = self.create_network() |
| 129 | port = self.create_port(network) |
| 130 | origin_updated_at = port['updated_at'] |
| 131 | update_body = {'name': port['name'] + 'new'} |
| 132 | body = self.admin_client.update_port(port['id'], |
| 133 | **update_body) |
| 134 | updated_port = body['port'] |
| 135 | new_updated_at = updated_port['updated_at'] |
| 136 | self.assertEqual(port['created_at'], updated_port['created_at']) |
| 137 | # Verify that origin_updated_at is not same with new_updated_at |
| 138 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 139 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 140 | @decorators.idempotent_id('584c6723-40b6-4f26-81dd-f508f9d9fb51') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 141 | def test_show_port_attribute_with_timestamp(self): |
| 142 | network = self.create_network() |
| 143 | port = self.create_port(network) |
| 144 | body = self.client.show_port(port['id']) |
| 145 | show_port = body['port'] |
| 146 | # verify the timestamp from creation and showed is same |
| 147 | self.assertEqual(port['created_at'], |
| 148 | show_port['created_at']) |
| 149 | self.assertEqual(port['updated_at'], |
| 150 | show_port['updated_at']) |
| 151 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 152 | @decorators.idempotent_id('87a8b196-4b90-44f0-b7f3-d2057d7d658e') |
Ilya Menkov | 319bd38 | 2020-05-22 15:16:32 +0400 | [diff] [blame] | 153 | @utils.requires_ext(extension='default-subnetpools', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 154 | def test_create_subnetpool_with_timestamp(self): |
| 155 | sp = self._create_subnetpool() |
| 156 | # Verifies body contains timestamp fields |
| 157 | self.assertIsNotNone(sp['created_at']) |
| 158 | self.assertIsNotNone(sp['updated_at']) |
| 159 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 160 | @decorators.idempotent_id('d48c7578-c3d2-4f9b-a7a1-be2008c770a0') |
Ilya Menkov | 319bd38 | 2020-05-22 15:16:32 +0400 | [diff] [blame] | 161 | @utils.requires_ext(extension='default-subnetpools', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 162 | def test_update_subnetpool_with_timestamp(self): |
| 163 | sp = self._create_subnetpool() |
| 164 | origin_updated_at = sp['updated_at'] |
| 165 | update_body = {'name': sp['name'] + 'new', |
| 166 | 'min_prefixlen': self.min_prefixlen, |
| 167 | 'max_prefixlen': self.max_prefixlen} |
| 168 | body = self.client.update_subnetpool(sp['id'], **update_body) |
| 169 | updated_sp = body['subnetpool'] |
| 170 | new_updated_at = updated_sp['updated_at'] |
| 171 | self.assertEqual(sp['created_at'], updated_sp['created_at']) |
| 172 | # Verify that origin_updated_at is not same with new_updated_at |
| 173 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 174 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 175 | @decorators.idempotent_id('1d3970e6-bcf7-46cd-b7d7-0807759c73b4') |
Ilya Menkov | 319bd38 | 2020-05-22 15:16:32 +0400 | [diff] [blame] | 176 | @utils.requires_ext(extension='default-subnetpools', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 177 | def test_show_subnetpool_attribute_with_timestamp(self): |
| 178 | sp = self._create_subnetpool() |
| 179 | body = self.client.show_subnetpool(sp['id']) |
| 180 | show_sp = body['subnetpool'] |
| 181 | # verify the timestamp from creation and showed is same |
| 182 | self.assertEqual(sp['created_at'], show_sp['created_at']) |
| 183 | self.assertEqual(sp['updated_at'], show_sp['updated_at']) |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 184 | |
Hongbin Lu | 840c03c | 2018-04-03 19:34:58 +0000 | [diff] [blame] | 185 | @decorators.idempotent_id('396a97dc-b66c-4c46-9171-c39eefe6936c') |
Hongbin Lu | 7681a5c | 2018-04-18 15:54:45 +0000 | [diff] [blame] | 186 | @utils.requires_ext(extension="standard-attr-segment", service="network") |
Hongbin Lu | 840c03c | 2018-04-03 19:34:58 +0000 | [diff] [blame] | 187 | def test_segment_with_timestamp(self): |
| 188 | network = self.create_network() |
| 189 | segment = self.admin_client.list_segments( |
| 190 | network_id=network['id'])['segments'][0] |
| 191 | # Verifies body contains timestamp fields |
| 192 | self.assertIsNotNone(segment['created_at']) |
| 193 | self.assertIsNotNone(segment['updated_at']) |
| 194 | |
| 195 | body = self.admin_client.show_segment(segment['id']) |
| 196 | show_segment = body['segment'] |
| 197 | # verify the timestamp from creation and showed is same |
| 198 | self.assertEqual(segment['created_at'], show_segment['created_at']) |
| 199 | self.assertEqual(segment['updated_at'], show_segment['updated_at']) |
| 200 | |
| 201 | origin_updated_at = segment['updated_at'] |
| 202 | update_body = {'name': str(segment['name']) + 'new'} |
| 203 | body = self.admin_client.update_segment(segment['id'], **update_body) |
| 204 | updated_segment = body['segment'] |
| 205 | new_updated_at = updated_segment['updated_at'] |
| 206 | self.assertEqual(segment['created_at'], updated_segment['created_at']) |
| 207 | # Verify that origin_updated_at is not same with new_updated_at |
| 208 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 209 | |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 210 | |
| 211 | class TestTimeStampWithL3(base_routers.BaseRouterTest): |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 212 | |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 213 | required_extensions = ['standard-attr-timestamp'] |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 214 | |
| 215 | @classmethod |
| 216 | def resource_setup(cls): |
| 217 | super(TestTimeStampWithL3, cls).resource_setup() |
| 218 | cls.ext_net_id = CONF.network.public_network_id |
| 219 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 220 | @decorators.idempotent_id('433ba770-b310-4da9-5d42-733217a1c7b1') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 221 | def test_create_router_with_timestamp(self): |
| 222 | router = self.create_router(router_name='test') |
| 223 | # Verifies body contains timestamp fields |
| 224 | self.assertIsNotNone(router['created_at']) |
| 225 | self.assertIsNotNone(router['updated_at']) |
| 226 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 227 | @decorators.idempotent_id('4a65417a-c11c-4b4d-a351-af01abcf57c6') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 228 | def test_update_router_with_timestamp(self): |
| 229 | router = self.create_router(router_name='test') |
| 230 | origin_updated_at = router['updated_at'] |
| 231 | update_body = {'name': router['name'] + 'new'} |
| 232 | body = self.client.update_router(router['id'], **update_body) |
| 233 | updated_router = body['router'] |
| 234 | new_updated_at = updated_router['updated_at'] |
| 235 | self.assertEqual(router['created_at'], updated_router['created_at']) |
| 236 | # Verify that origin_updated_at is not same with new_updated_at |
| 237 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 238 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 239 | @decorators.idempotent_id('1ab50ac2-7cbd-4a17-b23e-a9e36cfa4ec2') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 240 | def test_show_router_attribute_with_timestamp(self): |
| 241 | router = self.create_router(router_name='test') |
| 242 | body = self.client.show_router(router['id']) |
| 243 | show_router = body['router'] |
| 244 | # verify the timestamp from creation and showed is same |
| 245 | self.assertEqual(router['created_at'], |
| 246 | show_router['created_at']) |
Brian Haley | 060f803 | 2017-04-04 14:10:12 -0400 | [diff] [blame] | 247 | # 'updated_at' timestamp can change immediately after creation |
| 248 | # if environment is HA or DVR, so just make sure it's >= |
| 249 | self.assertGreaterEqual(show_router['updated_at'], |
| 250 | router['updated_at']) |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 251 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 252 | @decorators.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 253 | def test_create_floatingip_with_timestamp(self): |
Federico Ressi | 3dfa94c | 2018-07-06 09:46:39 +0200 | [diff] [blame] | 254 | fip = self.create_floatingip() |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 255 | # Verifies body contains timestamp fields |
| 256 | self.assertIsNotNone(fip['created_at']) |
| 257 | self.assertIsNotNone(fip['updated_at']) |
| 258 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 259 | @decorators.idempotent_id('a3ac215a-61ac-13f9-9d3c-57c51f11afa1') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 260 | def test_update_floatingip_with_timestamp(self): |
Federico Ressi | 3dfa94c | 2018-07-06 09:46:39 +0200 | [diff] [blame] | 261 | fip = self.create_floatingip() |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 262 | origin_updated_at = fip['updated_at'] |
| 263 | update_body = {'description': 'new'} |
| 264 | body = self.client.update_floatingip(fip['id'], **update_body) |
| 265 | updated_fip = body['floatingip'] |
| 266 | new_updated_at = updated_fip['updated_at'] |
| 267 | self.assertEqual(fip['created_at'], updated_fip['created_at']) |
| 268 | # Verify that origin_updated_at is not same with new_updated_at |
| 269 | self.assertIsNot(origin_updated_at, new_updated_at) |
| 270 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 271 | @decorators.idempotent_id('32a6a086-e1ef-413b-b13a-0cfe13ef051e') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 272 | def test_show_floatingip_attribute_with_timestamp(self): |
Federico Ressi | 3dfa94c | 2018-07-06 09:46:39 +0200 | [diff] [blame] | 273 | fip = self.create_floatingip() |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 274 | body = self.client.show_floatingip(fip['id']) |
| 275 | show_fip = body['floatingip'] |
| 276 | # verify the timestamp from creation and showed is same |
| 277 | self.assertEqual(fip['created_at'], |
| 278 | show_fip['created_at']) |
| 279 | self.assertEqual(fip['updated_at'], |
| 280 | show_fip['updated_at']) |
| 281 | |
| 282 | |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 283 | class TestTimeStampWithSecurityGroup(base.BaseNetworkTest): |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 284 | |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 285 | required_extensions = ['standard-attr-timestamp'] |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 286 | |
| 287 | @classmethod |
| 288 | def resource_setup(cls): |
| 289 | super(TestTimeStampWithSecurityGroup, cls).resource_setup() |
| 290 | cls.ext_net_id = CONF.network.public_network_id |
| 291 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 292 | @decorators.idempotent_id('a3150a7b-d31a-423a-abf3-45e71c97cbac') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 293 | def test_create_sg_with_timestamp(self): |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 294 | security_group = self.create_security_group() |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 295 | # Verifies body contains timestamp fields |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 296 | self.assertIsNotNone(security_group['created_at']) |
| 297 | self.assertIsNotNone(security_group['updated_at']) |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 298 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 299 | @decorators.idempotent_id('432ae0d3-32b4-413e-a9b3-091ac76da31b') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 300 | def test_update_sg_with_timestamp(self): |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 301 | security_group = self.create_security_group() |
| 302 | |
| 303 | # Make sure update time will be different |
| 304 | time.sleep(2.) |
| 305 | updated_security_group = self.client.update_security_group( |
| 306 | security_group['id'], name=security_group['name'] + 'new')[ |
| 307 | 'security_group'] |
ibumarskov | 9c98912 | 2020-10-16 13:34:32 +0400 | [diff] [blame^] | 308 | # Workaround for PRODX-7986 |
| 309 | if CONF.service_available.contrail: |
| 310 | updated_security_group = self.client.show_security_group( |
| 311 | security_group['id'])['security_group'] |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 312 | |
| 313 | # Verify that created_at hasn't changed |
| 314 | self.assertEqual(security_group['created_at'], |
| 315 | updated_security_group['created_at']) |
| 316 | # Verify that updated_at has changed |
| 317 | self.assertNotEqual(security_group['updated_at'], |
| 318 | updated_security_group['updated_at']) |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 319 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 320 | @decorators.idempotent_id('521e6723-43d6-12a6-8c3d-f5042ad9fc32') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 321 | def test_show_sg_attribute_with_timestamp(self): |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 322 | security_group = self.create_security_group() |
| 323 | observed_security_group = self.client.show_security_group( |
| 324 | security_group['id'])['security_group'] |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 325 | |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 326 | # Verify that created_at hasn't changed |
| 327 | self.assertEqual(security_group['created_at'], |
| 328 | observed_security_group['created_at']) |
| 329 | # Verify that updated_at hasn't changed |
| 330 | self.assertEqual(security_group['updated_at'], |
| 331 | observed_security_group['updated_at']) |
| 332 | |
| 333 | def _create_security_group_rule(self): |
| 334 | security_group = self.create_security_group() |
| 335 | return self.create_security_group_rule( |
| 336 | security_group=security_group, |
| 337 | direction=constants.INGRESS_DIRECTION, |
| 338 | protocol=constants.PROTO_NAME_TCP, |
| 339 | port_range_min=77, |
| 340 | port_range_max=77) |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 341 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 342 | @decorators.idempotent_id('83e8bd32-43e0-a3f0-1af3-12a5733c653e') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 343 | def test_create_sgrule_with_timestamp(self): |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 344 | security_group_rule = self._create_security_group_rule() |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 345 | # Verifies body contains timestamp fields |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 346 | self.assertIn('created_at', security_group_rule) |
| 347 | self.assertIn('updated_at', security_group_rule) |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 348 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 349 | @decorators.idempotent_id('143da0e6-ba17-43ad-b3d7-03aa759c3cb4') |
ZhaoBo | f562069 | 2016-05-05 17:16:23 +0800 | [diff] [blame] | 350 | def test_show_sgrule_attribute_with_timestamp(self): |
Federico Ressi | e570de6 | 2018-10-10 15:33:55 +0200 | [diff] [blame] | 351 | security_group_rule = self._create_security_group_rule() |
| 352 | |
| 353 | observed_security_group_rule = self.client.show_security_group_rule( |
| 354 | security_group_rule['id'])['security_group_rule'] |
| 355 | |
| 356 | # Verify the time stamp from creation and showed are equal |
| 357 | self.assertEqual(security_group_rule['created_at'], |
| 358 | observed_security_group_rule['created_at']) |
| 359 | self.assertEqual(security_group_rule['updated_at'], |
| 360 | observed_security_group_rule['updated_at']) |