Best Python code snippet using tempest_python
test_group_snapshots_rbac.py
Source:test_group_snapshots_rbac.py
...37 if self.vol['id'] == snap['volume_id']:38 waiters.wait_for_volume_resource_status(39 self.snapshots_client, snap['id'], 'available')40 return group_snapshot41 def _delete_group_snapshot(self, group_snapshot):42 self.group_snapshots_client.delete_group_snapshot(group_snapshot['id'])43 vols = self.volumes_client.list_volumes(detail=True)['volumes']44 snapshots = self.snapshots_client.list_snapshots(45 detail=True)['snapshots']46 for vol in vols:47 for snap in snapshots:48 if (vol['group_id'] == group_snapshot['group_id'] and49 vol['id'] == snap['volume_id']):50 self.snapshots_client.wait_for_resource_deletion(51 snap['id'])52 self.group_snapshots_client.wait_for_resource_deletion(53 group_snapshot['id'])54class GroupSnaphotsV314RbacTest(BaseGroupSnapshotsRbacTest):55 _api_version = 356 volume_min_microversion = '3.14'57 volume_max_microversion = 'latest'58 @classmethod59 def skip_checks(cls):60 super(GroupSnaphotsV314RbacTest, cls).skip_checks()61 if not utils.is_extension_enabled('groupsnapshot', 'volume'):62 msg = "%s skipped as group snapshots not enabled." % cls.__name__63 raise cls.skipException(msg)64 @classmethod65 def setup_clients(cls):66 super(GroupSnaphotsV314RbacTest, cls).setup_clients()67 cls.group_snapshot_client = \68 cls.os_primary.group_snapshots_client_latest69 def setUp(self):70 super(GroupSnaphotsV314RbacTest, self).setUp()71 self.volume_type = self.create_volume_type()72 self.group_type = self.create_group_type()73 self.grp = self.create_group(group_type=self.group_type['id'],74 volume_types=[self.volume_type['id']])75 self.vol = self.create_volume(volume_type=self.volume_type['id'],76 group_id=self.grp['id'])77 @decorators.idempotent_id('653df0e8-d90a-474a-a5ce-3c2339aff7ba')78 @rbac_rule_validation.action(79 service="cinder",80 rules=["group:create_group_snapshot"]81 )82 def test_create_group_snapshot(self):83 with self.override_role():84 name = data_utils.rand_name(85 self.__class__.__name__ + '-Group_Snapshot')86 group_snapshot = self.group_snapshots_client.create_group_snapshot(87 name=name, group_id=self.grp['id'])['group_snapshot']88 group_snapshot['group_id'] = self.grp['id']89 self.addCleanup(test_utils.call_and_ignore_notfound_exc,90 self._delete_group_snapshot, group_snapshot)91 waiters.wait_for_volume_resource_status(92 self.group_snapshots_client, group_snapshot['id'], 'available')93 snapshots = self.snapshots_client.list_snapshots(94 detail=True)['snapshots']95 for snap in snapshots:96 if self.vol['id'] == snap['volume_id']:97 waiters.wait_for_volume_resource_status(98 self.snapshots_client, snap['id'], 'available')99 @decorators.idempotent_id('8b966844-4421-4f73-940b-9157cb878331')100 @rbac_rule_validation.action(101 service="cinder",102 rules=["group:get_group_snapshot"]103 )104 def test_show_group_snapshot_rbac(self):105 group_snapshot_name = data_utils.rand_name('group_snapshot')106 group_snapshot = self._create_group_snapshot(group_id=self.grp['id'],107 name=group_snapshot_name)108 with self.override_role():109 self.group_snapshots_client.show_group_snapshot(110 group_snapshot['id'])111 @decorators.idempotent_id('e9de6dae-1efb-47cd-a3a8-d1f4b8f9f3ff')112 @rbac_rule_validation.action(113 service="cinder",114 rules=["group:get_all_group_snapshots"]115 )116 def test_list_group_snapshot_rbac(self):117 with self.override_role():118 self.group_snapshots_client.list_group_snapshots()119 @decorators.idempotent_id('cf2e25ee-ca58-4ad6-b98d-33235c77db7b')120 @rbac_rule_validation.action(121 service="cinder",122 rules=["group:delete_group_snapshot"]123 )124 def test_delete_group_snapshot_rbac(self):125 group_snapshot_name = data_utils.rand_name('group_snapshot')126 group_snapshot = self._create_group_snapshot(group_id=self.grp['id'],127 name=group_snapshot_name)128 with self.override_role():129 self.group_snapshots_client.delete_group_snapshot(130 group_snapshot['id'])131 vols = self.volumes_client.list_volumes(detail=True)['volumes']132 snapshots = self.snapshots_client.list_snapshots(133 detail=True)['snapshots']134 for vol in vols:135 for snap in snapshots:136 if (vol['group_id'] == group_snapshot['group_id'] and137 vol['id'] == snap['volume_id']):138 self.snapshots_client.wait_for_resource_deletion(139 snap['id'])140 self.group_snapshots_client.wait_for_resource_deletion(141 group_snapshot['id'])142class GroupSnaphotsV319RbacTest(BaseGroupSnapshotsRbacTest):143 _api_version = 3...
group_snapshots_client.py
Source:group_snapshots_client.py
...30 resp, body = self.post('group_snapshots', post_body)31 body = json.loads(body)32 self.validate_response(schema.create_group_snapshot, resp, body)33 return rest_client.ResponseBody(resp, body)34 def delete_group_snapshot(self, group_snapshot_id):35 """Deletes a group snapshot.36 For more information, please refer to the official API reference:37 https://docs.openstack.org/api-ref/block-storage/v3/#delete-group-snapshot38 """39 resp, body = self.delete('group_snapshots/%s' % group_snapshot_id)40 self.validate_response(schema.delete_group_snapshot, resp, body)41 return rest_client.ResponseBody(resp, body)42 def show_group_snapshot(self, group_snapshot_id):43 """Returns the details of a single group snapshot.44 For more information, please refer to the official API reference:45 https://docs.openstack.org/api-ref/block-storage/v3/#show-group-snapshot-details46 """47 url = "group_snapshots/%s" % str(group_snapshot_id)48 resp, body = self.get(url)...
group_snapshots.py
Source:group_snapshots.py
1# Copyright 2015 NEC Corporation. All rights reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"); you may4# not use this file except in compliance with the License. You may obtain5# a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the12# License for the specific language governing permissions and limitations13# under the License.14from tempest.lib.api_schema.response.compute.v2_1 import parameter_types15create_group_snapshot = {16 'status_code': [202],17 'response_body': {18 'type': 'object',19 'properties': {20 'group_snapshot': {21 'type': 'object',22 'properties': {23 'id': {'type': 'string', 'format': 'uuid'},24 'name': {'type': 'string'},25 'group_type_id': {'type': 'string', 'format': 'uuid'},26 },27 'additionalProperties': False,28 'required': ['id', 'name', 'group_type_id']29 }30 },31 'additionalProperties': False,32 'required': ['group_snapshot']33 }34}35delete_group_snapshot = {'status_code': [202]}36common_show_group_snapshot = {37 'type': 'object',38 'properties': {39 'created_at': parameter_types.date_time,40 'group_id': {'type': 'string', 'format': 'uuid'},41 'id': {'type': 'string', 'format': 'uuid'},42 'name': {'type': 'string'},43 'status': {'type': 'string'},44 'description': {'type': ['string', 'null']},45 'group_type_id': {'type': 'string', 'format': 'uuid'},46 },47 'additionalProperties': False,48 'required': ['created_at', 'group_id', 'id', 'name',49 'status', 'description', 'group_type_id']50}51show_group_snapshot = {52 'status_code': [200],53 'response_body': {54 'type': 'object',55 'properties': {56 'group_snapshot': common_show_group_snapshot57 },58 'additionalProperties': False,59 'required': ['group_snapshot']60 }61}62list_group_snapshots_no_detail = {63 'status_code': [200],64 'response_body': {65 'type': 'object',66 'properties': {67 'group_snapshots': {68 'type': 'array',69 'items': {70 'type': 'object',71 'properties': {72 'id': {'type': 'string', 'format': 'uuid'},73 'name': {'type': 'string'}74 },75 'additionalProperties': False,76 'required': ['id', 'name'],77 }78 }79 },80 'additionalProperties': False,81 'required': ['group_snapshots'],82 }83}84list_group_snapshots_with_detail = {85 'status_code': [200],86 'response_body': {87 'type': 'object',88 'properties': {89 'group_snapshots': {90 'type': 'array',91 'items': common_show_group_snapshot92 }93 },94 'additionalProperties': False,95 'required': ['group_snapshots'],96 }97}...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!