Skip to content

Commit a514df4

Browse files
kk7dsCyrilRoelandteNovance
authored andcommitted
Harden copy bust lock test
Hopefully this resolves a race in the test_import_copy_bust_lock test, where we look for the task id before it may have actually started. Change-Id: I69ce5e831fab6ebe061fed7ce32140591769a368 (cherry picked from commit caac5fc) (cherry picked from commit eebe82f) (cherry picked from commit 7af1ddb)
1 parent 028de8e commit a514df4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

glance/tests/functional/v2/test_images_import_locking.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,17 @@ def slow_fake_set_data(data_iter, size=None, backend=None,
9191

9292
# Try a second copy-image import. If we are warping time,
9393
# expect the lock to be busted. If not, then we should get
94-
# a 409 Conflict.
95-
resp = self._import_copy(image_id, ['store3'])
96-
time.sleep(0.1)
94+
# a 409 Conflict. We should make sure to wait until it gets started
95+
# before looking for the task id.
96+
with mock.patch('glance.location.ImageProxy.set_data') as mock_sd:
97+
mock_sd.side_effect = slow_fake_set_data
98+
resp = self._import_copy(image_id, ['store3'])
99+
100+
# Wait to make sure the data stream gets started
101+
for i in range(0, 10):
102+
if 'running' in state:
103+
break
104+
time.sleep(0.1)
97105

98106
self.addDetail('Second import response',
99107
ttc.text_content(str(resp)))

0 commit comments

Comments
 (0)