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