Best Python code snippet using tempest_python
test_server_diagnostics.py
Source:test_server_diagnostics.py
...23 cls.client = cls.os_admin.servers_client24 @decorators.idempotent_id('31ff3486-b8a0-4f56-a6c0-aab460531db3')25 def test_get_server_diagnostics(self):26 server_id = self.create_test_server(wait_until='ACTIVE')['id']27 diagnostics = self.client.show_server_diagnostics(server_id)28 # NOTE(snikitin): Before microversion 2.48 response data from each29 # hypervisor (libvirt, xen, vmware) was different. None of the fields30 # were equal. As this test is common for libvirt, xen and vmware CI31 # jobs we can't check any field in the response because all fields are32 # different.33 self.assertNotEmpty(diagnostics)34class ServerDiagnosticsV248Test(base.BaseV2ComputeAdminTest):35 min_microversion = '2.48'36 max_microversion = 'latest'37 @classmethod38 def setup_clients(cls):39 super(ServerDiagnosticsV248Test, cls).setup_clients()40 cls.client = cls.os_admin.servers_client41 @decorators.idempotent_id('64d0d48c-dff1-11e6-bf01-fe55135034f3')42 def test_get_server_diagnostics(self):43 server_id = self.create_test_server(wait_until='ACTIVE')['id']44 # Response status and filed types will be checked by json schema45 self.client.show_server_diagnostics(server_id)46 # NOTE(snikitin): This is a special case for Xen hypervisor. In Xen47 # case we're getting diagnostics stats from the RRDs which are updated48 # every 5 seconds. It means that diagnostics information may be49 # incomplete during first 5 seconds of VM life. In such cases methods50 # which get diagnostics stats from Xen may raise exceptions or51 # return `NaN` values. Such behavior must be handled correctly.52 # Response must contain all diagnostics fields (may be with `None`53 # values) and response status must be 200. Line above checks it by54 # json schema.55 time.sleep(10)56 diagnostics = self.client.show_server_diagnostics(server_id)57 # NOTE(snikitin): After 10 seconds diagnostics fields must contain58 # not None values. But we will check only "memory_details.maximum"59 # field because only this field meets all the following conditions:60 # 1) This field may be unset because of Xen 5 seconds timeout.61 # 2) This field is present in responses from all three supported62 # hypervisors (libvirt, xen, vmware)....
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!!