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