Best Python code snippet using tempest_python
test_server_actions.py
Source:test_server_actions.py
...69 server = self.client.show_server(self.server_id)70 linux_client = remote_client.RemoteClient(self.ip_addr,71 self.ssh_user, new_password)72 linux_client.validate_authentication()73 def _test_reboot_server(self, reboot_type):74 if self.run_ssh:75 # Get the time the server was last rebooted,76 server = self.client.show_server(self.server_id)77 linux_client = remote_client.RemoteClient(self.ip_addr,78 self.ssh_user, self.password)79 boot_time = linux_client.get_boot_time()80 self.client.reboot(self.server_id, reboot_type)81 self.client.wait_for_server_status(self.server_id, 'ACTIVE')82 if self.run_ssh:83 # Log in and verify the boot time has changed84 linux_client = remote_client.RemoteClient(self.ip_addr,85 self.ssh_user, self.password)86 new_boot_time = linux_client.get_boot_time()87 self.assertTrue(new_boot_time > boot_time,88 '%s > %s' % (new_boot_time, boot_time))89 @test.attr(type='smoke')90 @test.idempotent_id('2cb1baf6-ac8d-4429-bf0d-ba8a0ba53e32')91 def test_reboot_server_hard(self):92 # The server should be power cycled93 self._test_reboot_server('HARD')94 @decorators.skip_because(bug="1014647")95 @test.idempotent_id('4640e3ef-a5df-482e-95a1-ceeeb0faa84d')96 def test_reboot_server_soft(self):97 # The server should be signaled to reboot gracefully98 self._test_reboot_server('SOFT')99 def _rebuild_server_and_check(self, image_ref):100 rebuilt_server = self.client.rebuild(self.server_id, image_ref)101 self.client.wait_for_server_status(self.server_id, 'ACTIVE')102 msg = ('Server was not rebuilt to the original image. '103 'The original image: {0}. The current image: {1}'104 .format(image_ref, rebuilt_server['image']['id']))105 self.assertEqual(image_ref, rebuilt_server['image']['id'], msg)106 @test.idempotent_id('aaa6cdf3-55a7-461a-add9-1c8596b9a07c')107 def test_rebuild_server(self):108 # The server should be rebuilt using the provided image and data109 meta = {'rebuild': 'server'}110 new_name = data_utils.rand_name('server')111 file_contents = 'Test server rebuild.'112 personality = [{'path': 'rebuild.txt',...
test_sf_server_action.py
Source:test_sf_server_action.py
...18 @classmethod19 def resource_setup(cls):20 # cls.set_validation_resources()21 super(SfServerActionsTestJSON, cls).resource_setup()22 def _test_reboot_server(self, reboot_type, server):23 # Get the time the server was last rebooted,24 if CONF.compute.ssh_run:25 self.ssh_validation()26 linux_client = sf_remote_client.SfRemoteClient(27 self.floating_ip,28 self.ssh_user,29 self.ssh_password,30 )31 boot_time = linux_client.get_boot_time()32 self.client.reboot(server['id'], reboot_type)33 waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')34 if CONF.compute.ssh_run:35 # Log in and verify the boot time has changed36 linux_client = sf_remote_client.SfRemoteClient(37 self.floating_ip,38 self.ssh_user,39 self.ssh_password,40 )41 new_boot_time = linux_client.get_boot_time()42 self.assertTrue(new_boot_time > boot_time,43 '%s > %s' % (new_boot_time, boot_time))44 @test.attr(type='smoke')45 @test.idempotent_id('ac8330b4-d476-44c6-b164-3e17ee94a6b3')46 def test_reboot_server_hard(self):47 server = self.create_sf_server()48 # The server should be power cycled49 self._test_reboot_server('HARD', server)50 @test.attr(type='smoke')51 @test.idempotent_id('87e415eb-80c1-4a65-82d4-856d88d80b20')52 def test_force_stop_server(self):53 server = self.create_sf_server()54 self.client.sf_force_stop(server['id'])...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!