How to use _create_multiattach_volume method in tempest

Best Python code snippet using tempest_python

test_attach_volume.py

Source:test_attach_volume.py Github

copy

Full Screen

...283 self.servers_client.detach_volume(server_id, volume_id)284 # Now wait for the volume status to change.285 waiters.wait_for_volume_resource_status(286 self.volumes_client, volume_id, wait_status)287 def _create_multiattach_volume(self, bootable=False):288 kwargs = {}289 if bootable:290 kwargs['image_ref'] = CONF.compute.image_ref291 return self.create_volume(multiattach=True, **kwargs)292 def _create_and_multiattach(self):293 """Creates two server instances and a volume and attaches to both.294 :returns: A three-item tuple of the list of created servers,295 the created volume, and dict of server ID to volumeAttachment296 dict entries297 """298 servers = []299 for x in range(2):300 name = 'multiattach-server-%i' % x301 servers.append(self.create_test_server(name=name))302 # Now wait for the servers to be ACTIVE.303 for server in servers:304 waiters.wait_for_server_status(self.servers_client, server['id'],305 'ACTIVE')306 volume = self._create_multiattach_volume()307 # Attach the volume to the servers308 attachments = self._attach_volume_to_servers(volume, servers)309 return servers, volume, attachments310 @decorators.idempotent_id('8d5853f7-56e7-4988-9b0c-48cea3c7049a')311 def test_list_get_volume_attachments_multiattach(self):312 # Attach a single volume to two servers.313 servers, volume, attachments = self._create_and_multiattach()314 # List attachments from the volume and make sure the server uuids315 # are in that list.316 vol_attachments = self.volumes_client.show_volume(317 volume['id'])['volume']['attachments']318 attached_server_ids = [attachment['server_id']319 for attachment in vol_attachments]320 self.assertEqual(2, len(attached_server_ids))321 # List Volume attachment of the servers322 for server in servers:323 self.assertIn(server['id'], attached_server_ids)324 vol_attachments = self.servers_client.list_volume_attachments(325 server['id'])['volumeAttachments']326 self.assertEqual(1, len(vol_attachments))327 attachment = attachments[server['id']]328 self.assertDictEqual(attachment, vol_attachments[0])329 # Detach the volume from this server.330 self._detach_multiattach_volume(volume['id'], server['id'])331 def _boot_from_multiattach_volume(self):332 """Boots a server from a multiattach volume.333 The volume will not be deleted when the server is deleted.334 :returns: 2-item tuple of (server, volume)335 """336 volume = self._create_multiattach_volume(bootable=True)337 # Now create a server from the bootable volume.338 bdm = [{339 'uuid': volume['id'],340 'source_type': 'volume',341 'destination_type': 'volume',342 'boot_index': 0,343 'delete_on_termination': False}]344 server = self.create_test_server(345 image_id='', block_device_mapping_v2=bdm, wait_until='ACTIVE')346 # Assert the volume is attached to the server.347 attachments = self.servers_client.list_volume_attachments(348 server['id'])['volumeAttachments']349 self.assertEqual(1, len(attachments))350 self.assertEqual(volume['id'], attachments[0]['volumeId'])...

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