How to use _shelve_server method in tempest

Best Python code snippet using tempest_python

test_attach_volume.py

Source:test_attach_volume.py Github

copy

Full Screen

...146 servers_client=self.servers_client)147 command = 'grep -c -E [vs]d.$ /proc/partitions'148 volumes = int(linux_client.exec_command(command).strip())149 return volumes150 def _shelve_server(self, server):151 # NOTE(andreaf) If we are going to shelve a server, we should152 # check first whether the server is ssh-able. Otherwise we153 # won't be able to distinguish failures introduced by shelve154 # from pre-existing ones. Also it's good to wait for cloud-init155 # to be done and sshd server to be running before shelving to156 # avoid breaking the VM157 if CONF.validation.run_validation:158 linux_client = remote_client.RemoteClient(159 self.get_server_ip(server),160 self.image_ssh_user,161 self.image_ssh_password,162 self.validation_resources['keypair']['private_key'],163 server=server,164 servers_client=self.servers_client)165 linux_client.validate_authentication()166 # If validation went ok, or it was skipped, shelve the server167 compute.shelve_server(self.servers_client, server['id'])168 def _unshelve_server_and_check_volumes(self, server, number_of_volumes):169 # Unshelve the instance and check that there are expected volumes170 self.servers_client.unshelve_server(server['id'])171 waiters.wait_for_server_status(self.servers_client,172 server['id'],173 'ACTIVE')174 if CONF.validation.run_validation:175 counted_volumes = self._count_volumes(server)176 self.assertEqual(number_of_volumes, counted_volumes)177 @test.idempotent_id('13a940b6-3474-4c3c-b03f-29b89112bfee')178 @testtools.skipUnless(CONF.compute_feature_enabled.shelve,179 'Shelve is not available.')180 def test_attach_volume_shelved_or_offload_server(self):181 # Create server, count number of volumes on it, shelve182 # server and attach pre-created volume to shelved server183 server = self._create_server()184 num_vol = self._count_volumes(server)185 self._shelve_server(server)186 self._create_and_attach_volume(server)187 # Unshelve the instance and check that attached volume exists188 self._unshelve_server_and_check_volumes(server, num_vol + 1)189 # Get Volume attachment of the server190 volume_attachment = self.servers_client.show_volume_attachment(191 server['id'],192 self.attachment['id'])['volumeAttachment']193 self.assertEqual(server['id'], volume_attachment['serverId'])194 self.assertEqual(self.attachment['id'], volume_attachment['id'])195 # Check the mountpoint is not None after unshelve server even in196 # case of shelved_offloaded.197 self.assertIsNotNone(volume_attachment['device'])198 @test.idempotent_id('b54e86dd-a070-49c4-9c07-59ae6dae15aa')199 @testtools.skipUnless(CONF.compute_feature_enabled.shelve,200 'Shelve is not available.')201 def test_detach_volume_shelved_or_offload_server(self):202 # Create server, count number of volumes on it, shelve203 # server and attach pre-created volume to shelved server204 server = self._create_server()205 num_vol = self._count_volumes(server)206 self._shelve_server(server)207 volume = self._create_and_attach_volume(server)208 # Detach the volume209 self._detach(server['id'], volume['id'])210 self.attachment = None211 # Unshelve the instance and check that we have the expected number of212 # volume(s)...

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