How to use _boot_instance_from_volume method in tempest

Best Python code snippet using tempest_python

test_volume_boot_pattern.py

Source:test_volume_boot_pattern.py Github

copy

Full Screen

...46 'device_name': 'vda',47 'volume_id': vol_id,48 'delete_on_termination': str(int(delete_on_termination))}]49 return {'block_device_mapping': bd_map}50 def _boot_instance_from_volume(self, vol_id, keypair=None,51 security_group=None,52 delete_on_termination=False):53 create_kwargs = dict()54 if keypair:55 create_kwargs['key_name'] = keypair['name']56 if security_group:57 create_kwargs['security_groups'] = [58 {'name': security_group['name']}]59 create_kwargs.update(self._get_bdm(60 vol_id, delete_on_termination=delete_on_termination))61 return self.create_server(62 image='',63 wait_until='ACTIVE',64 **create_kwargs)65 def _create_snapshot_from_volume(self, vol_id):66 snap_name = data_utils.rand_name('snapshot')67 snap = self.snapshots_client.create_snapshot(68 volume_id=vol_id,69 force=True,70 display_name=snap_name)['snapshot']71 self.addCleanup(72 self.snapshots_client.wait_for_resource_deletion, snap['id'])73 self.addCleanup(self.snapshots_client.delete_snapshot, snap['id'])74 self.snapshots_client.wait_for_snapshot_status(snap['id'], 'available')75 # NOTE(e0ne): Cinder API v2 uses name instead of display_name76 if 'display_name' in snap:77 self.assertEqual(snap_name, snap['display_name'])78 else:79 self.assertEqual(snap_name, snap['name'])80 return snap81 def _create_volume_from_snapshot(self, snap_id):82 vol_name = data_utils.rand_name('volume')83 return self.create_volume(name=vol_name, snapshot_id=snap_id)84 def _delete_server(self, server):85 self.servers_client.delete_server(server['id'])86 waiters.wait_for_server_termination(self.servers_client, server['id'])87 @test.idempotent_id('557cd2c2-4eb8-4dce-98be-f86765ff311b')88 @test.attr(type='smoke')89 @test.services('compute', 'volume', 'image')90 def test_volume_boot_pattern(self):91 keypair = self.create_keypair()92 security_group = self._create_security_group()93 # create an instance from volume94 volume_origin = self._create_volume_from_image()95 instance_1st = self._boot_instance_from_volume(volume_origin['id'],96 keypair, security_group)97 # write content to volume on instance98 ip_instance_1st = self.get_server_or_ip(instance_1st)99 timestamp = self.create_timestamp(ip_instance_1st,100 private_key=keypair['private_key'])101 # delete instance102 self._delete_server(instance_1st)103 # create a 2nd instance from volume104 instance_2nd = self._boot_instance_from_volume(volume_origin['id'],105 keypair, security_group)106 # check the content of written file107 ip_instance_2nd = self.get_server_or_ip(instance_2nd)108 timestamp2 = self.get_timestamp(ip_instance_2nd,109 private_key=keypair['private_key'])110 self.assertEqual(timestamp, timestamp2)111 # snapshot a volume112 snapshot = self._create_snapshot_from_volume(volume_origin['id'])113 # create a 3rd instance from snapshot114 volume = self._create_volume_from_snapshot(snapshot['id'])115 server_from_snapshot = (116 self._boot_instance_from_volume(volume['id'],117 keypair, security_group))118 # check the content of written file119 server_from_snapshot_ip = self.get_server_or_ip(server_from_snapshot)120 timestamp3 = self.get_timestamp(server_from_snapshot_ip,121 private_key=keypair['private_key'])122 self.assertEqual(timestamp, timestamp3)123 @test.idempotent_id('36c34c67-7b54-4b59-b188-02a2f458a63b')124 @test.services('compute', 'volume', 'image')125 def test_create_ebs_image_and_check_boot(self):126 # create an instance from volume127 volume_origin = self._create_volume_from_image()128 instance = self._boot_instance_from_volume(volume_origin['id'],129 delete_on_termination=True)130 # create EBS image131 name = data_utils.rand_name('image')132 image = self.create_server_snapshot(instance, name=name)133 # delete instance134 self._delete_server(instance)135 # boot instance from EBS image136 instance = self.create_server(137 image_id=image['id'])138 # just ensure that instance booted139 # delete instance140 self._delete_server(instance)141class TestVolumeBootPatternV2(TestVolumeBootPattern):142 def _get_bdm(self, vol_id, delete_on_termination=False):...

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