How to use _find_extend_volume_instance_action method in tempest

Best Python code snippet using tempest_python

test_volumes_extend.py

Source:test_volumes_extend.py Github

copy

Full Screen

...63 # NOTE(mriedem): The minimum required volume API version is 3.42 and the64 # minimum required compute API microversion is 2.51, but the compute call65 # is implicit - Cinder calls Nova at that microversion, Tempest does not.66 min_microversion = '3.42'67 def _find_extend_volume_instance_action(self, server_id):68 actions = self.servers_client.list_instance_actions(69 server_id)['instanceActions']70 for action in actions:71 if action['action'] == 'extend_volume':72 return action73 def _find_extend_volume_instance_action_finish_event(self, action):74 # This has to be called by an admin client otherwise75 # the events don't show up.76 action = self.os_admin.servers_client.show_instance_action(77 action['instance_uuid'], action['request_id'])['instanceAction']78 for event in action['events']:79 if (event['event'] == 'compute_extend_volume' and80 event['finish_time']):81 return event82 @decorators.idempotent_id('301f5a30-1c6f-4ea0-be1a-91fd28d44354')83 @testtools.skipUnless(CONF.volume_feature_enabled.extend_attached_volume,84 "Attached volume extend is disabled.")85 @utils.services('compute')86 def test_extend_attached_volume(self):87 """This is a happy path test which does the following:88 * Create a volume at the configured volume_size.89 * Create a server instance.90 * Attach the volume to the server.91 * Wait for the volume status to be "in-use".92 * Extend the size of the volume and wait for the volume status to go93 back to "in-use".94 * Assert the volume size change is reflected in the volume API.95 * Wait for the "compute_extend_volume" instance action event to show96 up in the compute API with the success or failure status. We fail97 if we timeout waiting for the instance action event to show up, or98 if the action on the server fails.99 """100 # Create a test volume. Will be automatically cleaned up on teardown.101 volume = self.create_volume()102 # Create a test server. Will be automatically cleaned up on teardown.103 server = self.create_server()104 # Attach the volume to the server and wait for the volume status to be105 # "in-use".106 self.attach_volume(server['id'], volume['id'])107 # Extend the size of the volume. If this is successful, the volume API108 # will change the status on the volume to "extending" before doing an109 # RPC cast to the volume manager on the backend. Note that we multiply110 # the size of the volume since certain Cinder backends, e.g. ScaleIO,111 # require multiples of 8GB.112 extend_size = volume['size'] * 2113 self.volumes_client.extend_volume(volume['id'], new_size=extend_size)114 # The volume status should go back to in-use since it is still attached115 # to the server instance.116 waiters.wait_for_volume_resource_status(self.volumes_client,117 volume['id'], 'in-use')118 # Assert that the volume size has changed in the volume API.119 volume = self.volumes_client.show_volume(volume['id'])['volume']120 self.assertEqual(extend_size, volume['size'])121 # Now we wait for the "compute_extend_volume" instance action event122 # to show up for the server instance. This is our indication that the123 # asynchronous operation is complete on the compute side.124 start_time = int(time.time())125 timeout = self.servers_client.build_timeout126 action = self._find_extend_volume_instance_action(server['id'])127 while action is None and int(time.time()) - start_time < timeout:128 time.sleep(self.servers_client.build_interval)129 action = self._find_extend_volume_instance_action(server['id'])130 if action is None:131 msg = ("Timed out waiting to get 'extend_volume' instance action "132 "record for server %(server)s after %(timeout)s seconds." %133 {'server': server['id'], 'timeout': timeout})134 raise lib_exc.TimeoutException(msg)135 # Now that we found the extend_volume instance action, we can wait for136 # the compute_extend_volume instance action event to show up to137 # indicate the operation is complete.138 start_time = int(time.time())139 event = self._find_extend_volume_instance_action_finish_event(action)140 while event is None and int(time.time()) - start_time < timeout:141 time.sleep(self.servers_client.build_interval)142 event = self._find_extend_volume_instance_action_finish_event(143 action)...

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