How to use wait_for_server_status method in tempest

Best Python code snippet using tempest_python

test_servers.py

Source:test_servers.py Github

copy

Full Screen

...23class FunctionalException(Exception):24 pass25class ServersTest(utils.TestCase):26 @staticmethod27 def wait_for_server_status(s, active):28 start_time = int(time.time())29 while True:30 timed_out = int(time.time()) - start_time > STATUS_WAIT_TIMEOUT31 if timed_out:32 raise FunctionalException()33 time.sleep(BUILD_INTERVAL)34 s = s.refresh()35 if s.active == active:36 return37 @staticmethod38 def create_volume(size=1):39 pool = cs.pools.list()[0]40 return cs.volumes.create(size, pool)41 def test_list_servers(self):42 sl = cs.servers.list()43 self.assertTrue(len(sl) > 0)44 def test_get_server(self):45 s = cs.servers.get(SERVER_ID)46 self.assertEqual(s.id, SERVER_ID)47 def test_power_on_power_off(self):48 s = cs.servers.get(SERVER_ID)49 self.assertEqual(s.id, SERVER_ID)50 if s.active:51 s.power_off()52 self.wait_for_server_status(s, active=False)53 s = s.refresh()54 self.assertEqual(s.active, False)55 s.power_on()56 else:57 s.power_on()58 self.wait_for_server_status(s, active=True)59 s = s.refresh()60 self.assertEqual(s.active, True)61 s.power_off()62 def test_reset(self):63 s = cs.servers.get(SERVER_ID)64 self.assertEqual(s.id, SERVER_ID)65 s.reset()66 self.wait_for_server_status(s, active=True)67 s = s.refresh()68 self.assertEqual(s.active, True)69 def test_attach_detach_volume(self):70 volume_id = self.create_volume()71 server = cs.servers.list()[0]72 server.detach_volume()73 server.attach_volume(volume_id)74 server = server.refresh()75 self.assertEqual(server.vdisk['0'], volume_id)76 server.detach_volume()77 cs.volumes.delete(volume_id)78 def test_set_tagged_vlan(self):79 server = cs.servers.list()[0]80 server.unset_tagged_vlan(TAGGED_VLAN_ID)...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...62 self.linux_client.ping_host(floating_ip2['ip'], 5)63 except:64 raise exceptions.TempestException("cannot ping between vms")65 self.servers_client.pause_server(vm1['id'])66 waiters.wait_for_server_status(self.servers_client, vm1['id'],67 'PAUSED')68 self.servers_client.unpause_server(vm1['id'])69 waiters.wait_for_server_status(self.servers_client, vm1['id'],70 'ACTIVE')71 self.servers_client.reboot_server(vm2['id'], type='SOFT')72 waiters.wait_for_server_status(self.servers_client, vm2['id'],73 'ACTIVE')74 self.linux_client = self.get_remote_client(75 floating_ip1['ip'], private_key=keypair['private_key'])76 try:77 self.linux_client.ping_host(floating_ip2['ip'], 5)78 except:79 raise exceptions.TempestException("cannot ping between vms after \...

Full Screen

Full Screen

test_suspend_server_rbac.py

Source:test_suspend_server_rbac.py Github

copy

Full Screen

...35 vm_state = self.servers_client.show_server(36 self.server['id'])['server']['OS-EXT-STS:vm_state'].upper()37 if vm_state != 'ACTIVE':38 self.servers_client.resume_server(self.server['id'])39 waiters.wait_for_server_status(self.servers_client,40 self.server['id'],41 'ACTIVE')42 super(SuspendServerRbacTest, self).tearDown()43 @decorators.idempotent_id('b775930f-237c-431c-83ae-d33ed1b9700b')44 @rbac_rule_validation.action(45 service="nova",46 rule="os_compute_api:os-suspend-server:suspend")47 def test_suspend_server(self):48 self.rbac_utils.switch_role(self, toggle_rbac_role=True)49 self.servers_client.suspend_server(self.server['id'])50 waiters.wait_for_server_status(self.servers_client, self.server['id'],51 'SUSPENDED')52 @decorators.idempotent_id('4d90bd02-11f8-45b1-a8a1-534665584675')53 @rbac_rule_validation.action(54 service="nova",55 rule="os_compute_api:os-suspend-server:resume")56 def test_resume_server(self):57 self.servers_client.suspend_server(self.server['id'])58 waiters.wait_for_server_status(self.servers_client, self.server['id'],59 'SUSPENDED')60 self.rbac_utils.switch_role(self, toggle_rbac_role=True)61 self.servers_client.resume_server(self.server['id'])62 waiters.wait_for_server_status(self.servers_client,63 self.server['id'],...

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