diff --git a/zaqar/storage/redis/messages.py b/zaqar/storage/redis/messages.py index d2dba5d06..792871e2e 100644 --- a/zaqar/storage/redis/messages.py +++ b/zaqar/storage/redis/messages.py @@ -386,7 +386,7 @@ class MessageController(storage.Message, scripting.Mixin): @utils.retries_on_connection_error def bulk_get(self, queue, message_ids, project=None): if not self._queue_ctrl.exists(queue, project): - raise errors.QueueDoesNotExist(queue, project) + return iter([]) # NOTE(prashanthr_): Pipelining is used here purely # for performance. @@ -440,7 +440,7 @@ class MessageController(storage.Message, scripting.Mixin): @utils.retries_on_connection_error def delete(self, queue, message_id, project=None, claim=None): if not self._queue_ctrl.exists(queue, project): - raise errors.QueueDoesNotExist(queue, project) + return # NOTE(kgriffs): The message does not exist, so # it is essentially "already" deleted. @@ -490,8 +490,7 @@ class MessageController(storage.Message, scripting.Mixin): @utils.retries_on_connection_error def bulk_delete(self, queue, message_ids, project=None): if not self._queue_ctrl.exists(queue, project): - raise errors.QueueDoesNotExist(queue, - project) + return msgset_key = utils.msgset_key(queue, project) diff --git a/zaqar/tests/unit/storage/base.py b/zaqar/tests/unit/storage/base.py index c119f6ff2..d0ec7013f 100644 --- a/zaqar/tests/unit/storage/base.py +++ b/zaqar/tests/unit/storage/base.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import collections import datetime import random import time @@ -739,6 +740,29 @@ class MessageControllerTest(ControllerBaseTest): self.assertEqual(1, len(popped_messages)) + def test_delete_message_from_nonexistent_queue(self): + queue_name = 'fake_name' + message_id = 'fake_id' + res = self.controller.delete(queue_name, message_id, + project=self.project) + self.assertIsNone(res) + + def test_delete_messages_with_ids_from__nonexistent_queue(self): + queue_name = 'fake_name' + message_ids = ['fake_id1', 'fake_id2'] + res = self.controller.bulk_delete(queue_name, message_ids, + project=self.project) + self.assertIsNone(res) + + def test_get_messages_with_ids_from__nonexistent_queue(self): + queue_name = 'fake_name' + message_ids = ['fake_id1', 'fake_id2'] + res = self.controller.bulk_get(queue_name, message_ids, + project=self.project) + + self.assertTrue(isinstance(res, collections.Iterable)) + self.assertEqual([], list(res)) + class ClaimControllerTest(ControllerBaseTest): """Claim Controller base tests.