How to use get_test_validation_resources method in tempest

Best Python code snippet using tempest_python

test_server_personality.py

Source:test_server_personality.py Github

copy

Full Screen

...43 file_path = '/test.txt'44 personality = [{'path': file_path,45 'contents': base64.encode_as_text(file_contents)}]46 password = data_utils.rand_password()47 validation_resources = self.get_test_validation_resources(48 self.os_primary)49 created_server = self.create_test_server(50 personality=personality, adminPass=password, wait_until='ACTIVE',51 validatable=True,52 validation_resources=validation_resources)53 self.addCleanup(waiters.wait_for_server_termination,54 self.servers_client, created_server['id'])55 self.addCleanup(test_utils.call_and_ignore_notfound_exc,56 self.servers_client.delete_server,57 created_server['id'])58 server = self.client.show_server(created_server['id'])['server']59 if CONF.validation.run_validation:60 linux_client = remote_client.RemoteClient(61 self.get_server_ip(server, validation_resources),62 self.ssh_user, password,63 validation_resources['keypair']['private_key'],64 server=server,65 servers_client=self.client)66 self.assertEqual(file_contents,67 linux_client.exec_command(68 'sudo cat %s' % file_path))69 @decorators.idempotent_id('128966d8-71fc-443c-8cab-08e24114ecc9')70 def test_rebuild_server_with_personality(self):71 validation_resources = self.get_test_validation_resources(72 self.os_primary)73 server = self.create_test_server(74 wait_until='ACTIVE', validatable=True,75 validation_resources=validation_resources)76 server_id = server['id']77 self.addCleanup(waiters.wait_for_server_termination,78 self.servers_client, server_id)79 self.addCleanup(test_utils.call_and_ignore_notfound_exc,80 self.servers_client.delete_server, server_id)81 file_contents = 'Test server rebuild.'82 personality = [{'path': 'rebuild.txt',83 'contents': base64.encode_as_text(file_contents)}]84 rebuilt_server = self.client.rebuild_server(server_id,85 self.image_ref_alt,86 personality=personality)87 waiters.wait_for_server_status(self.client, server_id, 'ACTIVE')88 self.assertEqual(self.image_ref_alt,89 rebuilt_server['server']['image']['id'])90 @decorators.idempotent_id('176cd8c9-b9e8-48ee-a480-180beab292bf')91 def test_personality_files_exceed_limit(self):92 # Server creation should fail if greater than the maximum allowed93 # number of files are injected into the server.94 file_contents = 'This is a test file.'95 personality = []96 limits = self.user_client.show_limits()['limits']97 max_file_limit = limits['absolute']['maxPersonality']98 if max_file_limit == -1:99 raise self.skipException("No limit for personality files")100 for i in range(0, max_file_limit + 1):101 path = 'etc/test' + str(i) + '.txt'102 personality.append({'path': path,103 'contents': base64.encode_as_text(104 file_contents)})105 # A 403 Forbidden or 413 Overlimit (old behaviour) exception106 # will be raised when out of quota107 self.assertRaises((lib_exc.Forbidden, lib_exc.OverLimit),108 self.create_test_server, personality=personality)109 @decorators.idempotent_id('52f12ee8-5180-40cc-b417-31572ea3d555')110 def test_can_create_server_with_max_number_personality_files(self):111 # Server should be created successfully if maximum allowed number of112 # files is injected into the server during creation.113 file_contents = 'This is a test file.'114 limits = self.user_client.show_limits()['limits']115 max_file_limit = limits['absolute']['maxPersonality']116 if max_file_limit == -1:117 raise self.skipException("No limit for personality files")118 person = []119 for i in range(0, max_file_limit):120 # NOTE(andreaf) The cirros disk image is blank before boot121 # so we can only inject safely to /122 path = '/test' + str(i) + '.txt'123 person.append({124 'path': path,125 'contents': base64.encode_as_text(file_contents + str(i)),126 })127 password = data_utils.rand_password()128 validation_resources = self.get_test_validation_resources(129 self.os_primary)130 created_server = self.create_test_server(131 personality=person, adminPass=password, wait_until='ACTIVE',132 validatable=True, validation_resources=validation_resources)133 self.addCleanup(waiters.wait_for_server_termination,134 self.servers_client, created_server['id'])135 self.addCleanup(test_utils.call_and_ignore_notfound_exc,136 self.servers_client.delete_server,137 created_server['id'])138 server = self.client.show_server(created_server['id'])['server']139 if CONF.validation.run_validation:140 linux_client = remote_client.RemoteClient(141 self.get_server_ip(server, validation_resources),142 self.ssh_user, password,...

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