How to use _stage_and_check method in tempest

Best Python code snippet using tempest_python

test_images.py

Source:test_images.py Github

copy

Full Screen

...62 def _require_import_method(self, method):63 if method not in self.available_import_methods:64 raise self.skipException('Server does not support '65 '%s import method' % method)66 def _stage_and_check(self):67 image = self._create_image()68 # Stage image data69 file_content = data_utils.random_bytes()70 image_file = io.BytesIO(file_content)71 self.client.stage_image_file(image['id'], image_file)72 # Check image status is 'uploading'73 body = self.client.show_image(image['id'])74 self.assertEqual(image['id'], body['id'])75 self.assertEqual('uploading', body['status'])76 return image['id']77 @decorators.idempotent_id('32ca0c20-e16f-44ac-8590-07869c9b4cc2')78 def test_image_glance_direct_import(self):79 """Test 'glance-direct' import functionalities80 Create image, stage image data, import image and verify81 that import succeeded.82 """83 self._require_import_method('glance-direct')84 image_id = self._stage_and_check()85 # import image from staging to backend86 resp = self.client.image_import(image_id, method='glance-direct')87 waiters.wait_for_image_imported_to_stores(self.client, image_id)88 if not self.versions_client.has_version('2.12'):89 # API is not new enough to support image/tasks API90 LOG.info('Glance does not support v2.12, so I am unable to '91 'validate the image/tasks API.')92 return93 tasks = waiters.wait_for_image_tasks_status(94 self.client, image_id, 'success')95 self.assertEqual(1, len(tasks))96 task = tasks[0]97 self.assertEqual(resp.response['x-openstack-request-id'],98 task['request_id'])99 self.assertEqual('glance-direct',100 task['input']['import_req']['method']['name'])101 @decorators.idempotent_id('f6feb7a4-b04f-4706-a011-206129f83e62')102 def test_image_web_download_import(self):103 """Test 'web-download' import functionalities104 Create image, import image and verify that import105 succeeded.106 """107 self._require_import_method('web-download')108 image = self._create_image()109 # Now try to get image details110 body = self.client.show_image(image['id'])111 self.assertEqual(image['id'], body['id'])112 self.assertEqual('queued', body['status'])113 # import image from web to backend114 image_uri = CONF.image.http_image115 self.client.image_import(image['id'], method='web-download',116 import_params={'uri': image_uri})117 waiters.wait_for_image_imported_to_stores(self.client, image['id'])118 @decorators.idempotent_id('e04761a1-22af-42c2-b8bc-a34a3f12b585')119 def test_remote_import(self):120 """Test image import against a different worker than stage.121 This creates and stages an image against the primary API worker,122 but then calls import on a secondary worker (if available) to123 test that distributed image import works (i.e. proxies the import124 request to the proper worker).125 """126 self._require_import_method('glance-direct')127 if not CONF.image.alternate_image_endpoint:128 raise self.skipException('No image_remote service to test '129 'against')130 image_id = self._stage_and_check()131 # import image from staging to backend, but on the alternate worker132 self.os_primary.image_client_remote.image_import(133 image_id, method='glance-direct')134 waiters.wait_for_image_imported_to_stores(self.client, image_id)135 @decorators.idempotent_id('44d60544-1524-42f7-8899-315301105dd8')136 def test_remote_delete(self):137 """Test image delete against a different worker than stage.138 This creates and stages an image against the primary API worker,139 but then calls delete on a secondary worker (if available) to140 test that distributed image import works (i.e. proxies the delete141 request to the proper worker).142 """143 self._require_import_method('glance-direct')144 if not CONF.image.alternate_image_endpoint:145 raise self.skipException('No image_remote service to test '146 'against')147 image_id = self._stage_and_check()148 # delete image from staging to backend, but on the alternate worker149 self.os_primary.image_client_remote.delete_image(image_id)150 self.client.wait_for_resource_deletion(image_id)151class MultiStoresImportImagesTest(base.BaseV2ImageTest):152 """Test importing image in multiple stores"""153 @classmethod154 def skip_checks(cls):155 super(MultiStoresImportImagesTest, cls).skip_checks()156 if not CONF.image_feature_enabled.import_image:157 skip_msg = (158 "%s skipped as image import is not available" % cls.__name__)159 raise cls.skipException(skip_msg)160 @classmethod161 def resource_setup(cls):...

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