How to use get_class_validation_resources method in tempest

Best Python code snippet using tempest_python

test_create_server.py

Source:test_create_server.py Github

copy

Full Screen

...34 cls.client = cls.servers_client35 @classmethod36 def resource_setup(cls):37 super(ServersTestJSON, cls).resource_setup()38 validation_resources = cls.get_class_validation_resources(39 cls.os_primary)40 cls.meta = {'hello': 'world'}41 cls.accessIPv4 = '1.1.1.1'42 cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2'43 cls.name = data_utils.rand_name(cls.__name__ + '-server')44 cls.password = data_utils.rand_password()45 disk_config = cls.disk_config46 server_initial = cls.create_test_server(47 validatable=True,48 validation_resources=validation_resources,49 wait_until='ACTIVE',50 name=cls.name,51 metadata=cls.meta,52 accessIPv4=cls.accessIPv4,53 accessIPv6=cls.accessIPv6,54 disk_config=disk_config,55 adminPass=cls.password,56 volume_backed=cls.volume_backed)57 cls.server = (cls.client.show_server(server_initial['id'])58 ['server'])59 @decorators.attr(type='smoke')60 @decorators.idempotent_id('5de47127-9977-400a-936f-abcfbec1218f')61 def test_verify_server_details(self):62 # Verify the specified server attributes are set correctly63 self.assertEqual(self.accessIPv4, self.server['accessIPv4'])64 # NOTE(maurosr): See http://tools.ietf.org/html/rfc5952 (section 4)65 # Here we compare directly with the canonicalized format.66 self.assertEqual(self.server['accessIPv6'],67 str(netaddr.IPAddress(self.accessIPv6)))68 self.assertEqual(self.name, self.server['name'])69 if self.volume_backed:70 # Image is an empty string as per documentation71 self.assertEqual("", self.server['image'])72 else:73 self.assertEqual(self.image_ref, self.server['image']['id'])74 self.assert_flavor_equal(self.flavor_ref, self.server['flavor'])75 self.assertEqual(self.meta, self.server['metadata'])76 @decorators.attr(type='smoke')77 @decorators.idempotent_id('9a438d88-10c6-4bcd-8b5b-5b6e25e1346f')78 def test_list_servers(self):79 # The created server should be in the list of all servers80 body = self.client.list_servers()81 servers = body['servers']82 found = [i for i in servers if i['id'] == self.server['id']]83 self.assertNotEmpty(found)84 @decorators.idempotent_id('585e934c-448e-43c4-acbf-d06a9b899997')85 def test_list_servers_with_detail(self):86 # The created server should be in the detailed list of all servers87 body = self.client.list_servers(detail=True)88 servers = body['servers']89 found = [i for i in servers if i['id'] == self.server['id']]90 self.assertNotEmpty(found)91 @decorators.idempotent_id('cbc0f52f-05aa-492b-bdc1-84b575ca294b')92 @testtools.skipUnless(CONF.validation.run_validation,93 'Instance validation tests are disabled.')94 def test_verify_created_server_vcpus(self):95 # Verify that the number of vcpus reported by the instance matches96 # the amount stated by the flavor97 flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']98 validation_resources = self.get_class_validation_resources(99 self.os_primary)100 linux_client = remote_client.RemoteClient(101 self.get_server_ip(self.server, validation_resources),102 self.ssh_user,103 self.password,104 validation_resources['keypair']['private_key'],105 server=self.server,106 servers_client=self.client)107 output = linux_client.exec_command('grep -c ^processor /proc/cpuinfo')108 self.assertEqual(flavor['vcpus'], int(output))109 @decorators.idempotent_id('ac1ad47f-984b-4441-9274-c9079b7a0666')110 @testtools.skipUnless(CONF.validation.run_validation,111 'Instance validation tests are disabled.')112 def test_host_name_is_same_as_server_name(self):113 # Verify the instance host name is the same as the server name114 validation_resources = self.get_class_validation_resources(115 self.os_primary)116 linux_client = remote_client.RemoteClient(117 self.get_server_ip(self.server, validation_resources),118 self.ssh_user,119 self.password,120 validation_resources['keypair']['private_key'],121 server=self.server,122 servers_client=self.client)123 hostname = linux_client.exec_command("hostname").rstrip()124 msg = ('Failed while verifying servername equals hostname. Expected '125 'hostname "%s" but got "%s".' %126 (self.name, hostname.split(".")[0]))127 # NOTE(zhufl): Some images will add postfix for the hostname, e.g.,128 # if hostname is "aaa", postfix ".novalocal" may be added to it, and...

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