Browse Source

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
(cherry picked from commit 5a7fb9db6e)
changes/39/748239/1
Dan Smith 1 month ago
parent
commit
541c0fd61e
1 changed files with 8 additions and 5 deletions
  1. +8
    -5
      glance/tests/functional/v2/test_images.py

+ 8
- 5
glance/tests/functional/v2/test_images.py View File

@@ -5574,17 +5574,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.


Loading…
Cancel
Save