Browse Source

Make test_copy_image_revert_lifecycle handle 409 on import retry

This test is very racy in general, and specifically on the post-revert
retry to do the import, it may start the next import before the previous
one has finished reverting. This patch makes it retry a few times with
delay if an HTTP 409 is received so it is tolerant of that situation once
it becomes possible in the subsequent patch to add import locking.

Change-Id: Ic933f170d43b290fd819e8527ecb60be7f7f3f89
(cherry picked from commit 8c7342cbc1)
changes/03/748003/1
Dan Smith 1 month ago
parent
commit
0895d19197
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      glance/tests/functional/v2/test_images.py

+ 12
- 1
glance/tests/functional/v2/test_images.py View File

@@ -15,6 +15,7 @@

import hashlib
import os
import time
import uuid

from oslo_serialization import jsonutils
@@ -5616,7 +5617,17 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest):
{'method': {'name': 'copy-image'},
'stores': ['file2', 'file3'],
'all_stores_must_succeed': False})
response = requests.post(path, headers=headers, data=data)

for i in range(0, 5):
response = requests.post(path, headers=headers, data=data)
if response.status_code != http.CONFLICT:
break
# We might race with the revert of the previous task and do not
# really have a good way to make sure that it's done. In order
# to make sure we tolerate the 409 possibility when import
# locking is added, gracefully wait a few times before failing.
time.sleep(1)

self.assertEqual(http.ACCEPTED, response.status_code)

# Verify image is copied


Loading…
Cancel
Save