Fix non-deterministic copy_image_revert_lifecycle test

This test is failing fairly often in zuul. The test attempts to delete
one of the stores while the import is happening to simulate a failure
and ensure that the first store is not reverted. This can race and fail
to delete before the task completes. Instead, if we just delete the
store directory before the import, we know that when the flow gets to
the second store's step, it will fail to write the image, giving the same
result, reliably.

Change-Id: Ibeea8a93f140f35daa47024d07ad806162ff690d
This commit is contained in:
Dan Smith 2020-08-07 10:07:35 -07:00
parent 12167a9508
commit 5a7fb9db6e
1 changed files with 8 additions and 5 deletions

View File

@ -5553,17 +5553,20 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest):
'X-Roles': 'admin'
})
# NOTE(abhishekk): Deleting file3 image directory to trigger the
# failure, so that we can verify that revert call does not delete
# the data from existing stores
# NOTE(danms): Do this before we start the import, on a later store,
# which will cause that store to fail after we have already completed
# the first one.
os.rmdir(self.test_dir + "/images_3")
data = jsonutils.dumps(
{'method': {'name': 'copy-image'},
'stores': ['file2', 'file3']})
response = requests.post(path, headers=headers, data=data)
self.assertEqual(http.ACCEPTED, response.status_code)
# NOTE(abhishekk): Deleting file3 image directory to trigger the
# failure, so that we can verify that revert call does not delete
# the data from existing stores
os.rmdir(self.test_dir + "/images_3")
# Verify image is copied
# NOTE(abhishekk): As import is a async call we need to provide
# some timelap to complete the call.