How to use extend_volume method in tempest

Best Python code snippet using tempest_python

test_volumes_extend.py

Source:test_volumes_extend.py Github

copy

Full Screen

...28 """Test extend a volume"""29 # Extend Volume Test.30 volume = self.create_volume(imageRef=self.image_ref)31 extend_size = volume['size'] * 232 self.volumes_client.extend_volume(volume['id'],33 new_size=extend_size)34 waiters.wait_for_volume_resource_status(self.volumes_client,35 volume['id'], 'available')36 volume = self.volumes_client.show_volume(volume['id'])['volume']37 self.assertEqual(volume['size'], extend_size)38 @decorators.idempotent_id('86be1cba-2640-11e5-9c82-635fb964c912')39 @testtools.skipUnless(CONF.volume_feature_enabled.snapshot,40 "Cinder volume snapshots are disabled")41 def test_volume_extend_when_volume_has_snapshot(self):42 """Test extending a volume which has a snapshot"""43 volume = self.create_volume()44 self.create_snapshot(volume['id'])45 extend_size = volume['size'] * 246 self.volumes_client.extend_volume(volume['id'], new_size=extend_size)47 waiters.wait_for_volume_resource_status(self.volumes_client,48 volume['id'], 'available')49 resized_volume = self.volumes_client.show_volume(50 volume['id'])['volume']51 self.assertEqual(extend_size, resized_volume['size'])52class VolumesExtendAttachedTest(base.BaseVolumeTest):53 """Tests extending the size of an attached volume."""54 create_default_network = True55 # We need admin credentials for getting instance action event details. By56 # default a non-admin can list and show instance actions if they own the57 # server instance, but since the event details can contain error messages58 # and tracebacks, like an instance fault, those are not viewable by59 # non-admins. This is obviously not a great user experience since the user60 # may not know when the operation is actually complete. A microversion in61 # the compute API will be added so that non-admins can see instance action62 # events but will continue to hide the traceback field.63 # TODO(mriedem): Change this to not rely on the admin user to get the event64 # details once that microversion is available in Nova.65 credentials = ['primary', 'admin']66 _api_version = 367 # NOTE(mriedem): The minimum required volume API version is 3.42 and the68 # minimum required compute API microversion is 2.51, but the compute call69 # is implicit - Cinder calls Nova at that microversion, Tempest does not.70 min_microversion = '3.42'71 def _find_extend_volume_instance_action(self, server_id):72 actions = self.servers_client.list_instance_actions(73 server_id)['instanceActions']74 for action in actions:75 if action['action'] == 'extend_volume':76 return action77 def _find_extend_volume_instance_action_finish_event(self, action):78 # This has to be called by an admin client otherwise79 # the events don't show up.80 action = self.os_admin.servers_client.show_instance_action(81 action['instance_uuid'], action['request_id'])['instanceAction']82 for event in action['events']:83 if (event['event'] == 'compute_extend_volume' and84 event['finish_time']):85 return event86 @decorators.idempotent_id('301f5a30-1c6f-4ea0-be1a-91fd28d44354')87 @testtools.skipUnless(CONF.volume_feature_enabled.extend_attached_volume,88 "Attached volume extend is disabled.")89 @utils.services('compute')90 def test_extend_attached_volume(self):91 """This is a happy path test which does the following:92 * Create a volume at the configured volume_size.93 * Create a server instance.94 * Attach the volume to the server.95 * Wait for the volume status to be "in-use".96 * Extend the size of the volume and wait for the volume status to go97 back to "in-use".98 * Assert the volume size change is reflected in the volume API.99 * Wait for the "compute_extend_volume" instance action event to show100 up in the compute API with the success or failure status. We fail101 if we timeout waiting for the instance action event to show up, or102 if the action on the server fails.103 """104 # Create a test volume. Will be automatically cleaned up on teardown.105 volume = self.create_volume()106 # Create a test server. Will be automatically cleaned up on teardown.107 server = self.create_server()108 # Attach the volume to the server and wait for the volume status to be109 # "in-use".110 self.attach_volume(server['id'], volume['id'])111 # Extend the size of the volume. If this is successful, the volume API112 # will change the status on the volume to "extending" before doing an113 # RPC cast to the volume manager on the backend. Note that we multiply114 # the size of the volume since certain Cinder backends, e.g. ScaleIO,115 # require multiples of 8GB.116 extend_size = volume['size'] * 2117 self.volumes_client.extend_volume(volume['id'], new_size=extend_size)118 # The volume status should go back to in-use since it is still attached119 # to the server instance.120 waiters.wait_for_volume_resource_status(self.volumes_client,121 volume['id'], 'in-use')122 # Assert that the volume size has changed in the volume API.123 volume = self.volumes_client.show_volume(volume['id'])['volume']124 self.assertEqual(extend_size, volume['size'])125 # Now we wait for the "compute_extend_volume" instance action event126 # to show up for the server instance. This is our indication that the127 # asynchronous operation is complete on the compute side.128 start_time = int(time.time())129 timeout = self.servers_client.build_timeout130 action = self._find_extend_volume_instance_action(server['id'])131 while action is None and int(time.time()) - start_time < timeout:...

Full Screen

Full Screen

vds_storage_manager.py

Source:vds_storage_manager.py Github

copy

Full Screen

...49 if volume_idx not in volume_indexes:50 extend_volume = False5152 if extend_volume:53 self._extend_volume(pack, volume, volume_prop)54 finally:55 ole32.CoTaskMemFree(volume_prop.pwszName)5657 def _get_volume_index(self, volume_name):58 m = re.match(r"[^0-9]+([0-9]+)$", volume_name)59 if m:60 return int(m.group(1))6162 def _extend_volume(self, pack, volume, volume_prop):63 volume_extents = self._get_volume_extents_to_resize(pack,64 volume_prop.id)65 input_disks = []6667 for (volume_extent, volume_extend_size) in volume_extents:68 input_disk = vds.VDS_INPUT_DISK()69 input_disks.append(input_disk)7071 input_disk.diskId = volume_extent.diskId72 input_disk.memberIdx = volume_extent.memberIdx73 input_disk.plexId = volume_extent.plexId74 input_disk.ullSize = volume_extend_size7576 if input_disks: ...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful