Fix race condition for image test

If first image is not captured in saving state,
then we should skip the test
- test_create_second_image_when_first_image_is_being_saved

Test is for creating the another image is first one is in
saving state and if image creation operation is fast and it
gets created before second API request then this test will
fail on its assert.

To handle the test scope and this race condition, we need to
assert on second operation if  image is in saving state.This
can be done via capturing the timeout exception from first image
creation and waiting for saving state.

Change-Id: Id59f7ebb223f968109917182e29267faa808a072
Closes-Bug: #1881592
This commit is contained in:
Ghanshyam Mann 2020-12-29 16:22:30 -06:00 committed by Martin Kopec
parent f4ddd6f8be
commit 5b36c36896
2 changed files with 22 additions and 18 deletions

View File

@ -110,6 +110,7 @@ class ImagesOneServerNegativeTestJSON(base.BaseV2ComputeTest):
Creating another server image when first image is being saved is
not allowed.
"""
try:
# Create first snapshot
image = self.create_image_from_server(self.server_id)
self.addCleanup(self._reset_server)
@ -122,9 +123,18 @@ class ImagesOneServerNegativeTestJSON(base.BaseV2ComputeTest):
"OpenStack-API-Version", "compute 2.45", image.response, "lt"):
image_id = image['image_id']
else:
image_id = data_utils.parse_image_id(image.response['location'])
image_id = data_utils.parse_image_id(
image.response['location'])
self.client.delete_image(image_id)
except lib_exc.TimeoutException as ex:
# Test cannot capture the image saving state.
# If timeout is reached, we don't need to check state,
# since, it wouldn't be a 'SAVING' state atleast and apart from
# it, this testcase doesn't have scope for other state transition
# Hence, skip the test.
raise self.skipException("This test is skipped because " + str(ex))
@decorators.attr(type=['negative'])
@decorators.idempotent_id('084f0cbc-500a-4963-8a4e-312905862581')
def test_create_image_specify_name_over_character_limit(self):

View File

@ -11,9 +11,3 @@ tempest.api.object_storage
tempest.scenario.test_object_storage_basic_ops.TestObjectStorageBasicOps.test_swift_basic_ops
tempest.scenario.test_object_storage_basic_ops.TestObjectStorageBasicOps.test_swift_acl_anonymous_download
tempest.scenario.test_volume_backup_restore.TestVolumeBackupRestore.test_volume_backup_restore
# Skip test scenario when creating second image from instance
# https://bugs.launchpad.net/tripleo/+bug/1881592
# The test is most likely wrong and may fail if the fists image is create quickly.
# FIXME: Either fix the test so it won't race or consider if we should cover the scenario at all.
tempest.api.compute.images.test_images_oneserver_negative.ImagesOneServerNegativeTestJSON.test_create_second_image_when_first_image_is_being_saved