Merge "Ensure queue exists before get/update the claim"

This commit is contained in:
Jenkins 2016-07-20 08:03:00 +00:00 committed by Gerrit Code Review
commit 678605c839
2 changed files with 22 additions and 0 deletions

View File

@ -118,6 +118,14 @@ class ClaimController(storage.Claim, scripting.Mixin):
client = self._client
claims_set_key = utils.scope_claims_set(queue, project,
QUEUE_CLAIMS_SUFFIX)
# In some cases, the queue maybe doesn't exist. So we should check
# whether the queue exists. Return False if no such queue exists.
# Todo(flwang): We should delete all related data after the queue is
# deleted. See the blueprint for more detail:
# https://blueprints.launchpad.net/zaqar/+spec/clear-resources-after-delete-queue
if not self._queue_ctrl._exists(queue, project):
return False
# Return False if no such claim exists
# TODO(prashanthr_): Discuss the feasibility of a bloom filter.

View File

@ -400,6 +400,20 @@ class RedisClaimsTest(base.ClaimControllerTest):
self.controller.update, queue_name,
claim_id, {}, project=None)
# create a claim and then delete the queue
claim_id, messages = self.controller.create(queue_name, {'ttl': 100,
'grace': 0},
project=None)
self.queue_controller.delete(queue_name)
self.assertRaises(storage.errors.ClaimDoesNotExist,
self.controller.get, queue_name,
claim_id, project=None)
self.assertRaises(storage.errors.ClaimDoesNotExist,
self.controller.update, queue_name,
claim_id, {}, project=None)
def test_get_claim_after_expires(self):
queue_name = 'no-such-claim'
self.queue_controller.create(queue_name, project='fake_project')