Skip to content

Commit

Permalink
Fix a race condition in test_create_delete_image()
Browse files Browse the repository at this point in the history
The delete portion test_create_delete_image() in
ImagesOneServerTest has a race condition between the delete
and the assertRaises(). This commit fixes this by enabling
wait_for_resource_deletion() for the images_client and using that
after the delete request.

Fixes Bug 1187566

Change-Id: I13114d6c549756b3d753c9395f82d58cbaec04db
  • Loading branch information
Matthew Treinish committed Jun 4, 2013
1 parent 9653aa2 commit 0d66049
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tempest/api/compute/images/test_images_oneserver.py
Expand Up @@ -131,7 +131,7 @@ def test_create_delete_image(self):
# Verify the image was deleted correctly
resp, body = self.client.delete_image(image_id)
self.assertEqual('204', resp['status'])
self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
self.client.wait_for_resource_deletion(image_id)

@testtools.skipUnless(compute.MULTI_USER,
'Need multiple users for this test.')
Expand Down
7 changes: 7 additions & 0 deletions tempest/services/compute/json/images_client.py
Expand Up @@ -150,3 +150,10 @@ def delete_image_metadata_item(self, image_id, key):
resp, body = self.delete("images/%s/metadata/%s" %
(str(image_id), key))
return resp, body

def is_resource_deleted(self, id):
try:
self.get_image(id)
except exceptions.NotFound:
return True
return False
7 changes: 7 additions & 0 deletions tempest/services/compute/xml/images_client.py
Expand Up @@ -226,3 +226,10 @@ def delete_image_metadata_item(self, image_id, key):
"""Deletes a single image metadata key/value pair."""
return self.delete("images/%s/metadata/%s" % (str(image_id), key),
self.headers)

def is_resource_deleted(self, id):
try:
self.get_image(id)
except exceptions.NotFound:
return True
return False

0 comments on commit 0d66049

Please sign in to comment.