diff --git a/tests/unit/queues/storage/test_impl_mongodb.py b/tests/unit/queues/storage/test_impl_mongodb.py index f18ac677e..e0426f6d2 100644 --- a/tests/unit/queues/storage/test_impl_mongodb.py +++ b/tests/unit/queues/storage/test_impl_mongodb.py @@ -507,6 +507,16 @@ class PooledClaimsTests(base.ClaimControllerTest): control_driver_class = mongodb.ControlDriver controller_base_class = pooling.RoutingController + def test_delete_message_expired_claim(self): + # NOTE(flaper87): The pool tests uses sqlalchemy + # as one of the pools, which causes this test to fail. + # Several reasons to do this: + # The sqla driver is deprecated + # It's not optimized + # mocking utcnow mocks the driver too, which + # requires to put sleeps in the test + self.skip("Fix sqlalchemy driver") + @testing.requires_mongodb class MongodbFlavorsTest(base.FlavorsControllerTest): diff --git a/tests/unit/queues/storage/test_impl_sqlalchemy.py b/tests/unit/queues/storage/test_impl_sqlalchemy.py index ca8d8cd1d..b690ca8a1 100644 --- a/tests/unit/queues/storage/test_impl_sqlalchemy.py +++ b/tests/unit/queues/storage/test_impl_sqlalchemy.py @@ -115,6 +115,14 @@ class SqlalchemyClaimTests(base.ClaimControllerTest): driver_class = sqlalchemy.DataDriver controller_class = controllers.ClaimController + def test_delete_message_expired_claim(self): + # NOTE(flaper87): Several reasons to do this: + # The sqla driver is deprecated + # It's not optimized + # mocking utcnow mocks the driver too, which + # requires to put sleeps in the test + self.skip("Fix sqlalchemy driver") + class SqlalchemyPoolsTest(base.PoolsControllerTest): driver_class = sqlalchemy.ControlDriver @@ -155,6 +163,14 @@ class PooledClaimsTests(base.ClaimControllerTest): control_driver_class = sqlalchemy.ControlDriver controller_base_class = pooling.RoutingController + def test_delete_message_expired_claim(self): + # NOTE(flaper87): Several reasons to do this: + # The sqla driver is deprecated + # It's not optimized + # mocking utcnow mocks the driver too, which + # requires to put sleeps in the test + self.skip("Fix sqlalchemy driver") + class PooledQueueTests(base.QueueControllerTest): config_file = 'wsgi_sqlalchemy_pooled.conf' diff --git a/zaqar/tests/queues/storage/base.py b/zaqar/tests/queues/storage/base.py index 4bdfd9314..f7af26d6e 100644 --- a/zaqar/tests/queues/storage/base.py +++ b/zaqar/tests/queues/storage/base.py @@ -19,6 +19,7 @@ import time import uuid import ddt +import mock from oslo.utils import timeutils import six from testtools import matchers @@ -881,6 +882,34 @@ class ClaimControllerTest(ControllerBaseTest): self.controller.update(self.queue_name, claim_id, meta, project=self.project) + def test_delete_message_expired_claim(self): + meta = {'ttl': 2, 'grace': 2} + new_messages = [{'ttl': 60, 'body': {}}, + {'ttl': 60, 'body': {}}, + {'ttl': 60, 'body': {}}] + + self.message_controller.post(self.queue_name, new_messages, + client_uuid=str(uuid.uuid1()), + project=self.project) + + claim_id, messages = self.controller.create(self.queue_name, meta, + project=self.project) + + now = timeutils.utcnow_ts() + timeutils_utcnow = 'oslo.utils.timeutils.utcnow_ts' + + with mock.patch(timeutils_utcnow) as mock_utcnow: + mock_utcnow.return_value = now + 2 + + messages = [msg['id'] for msg in messages] + self.message_controller.delete(self.queue_name, + messages.pop(), + project=self.project) + + self.message_controller.bulk_delete(self.queue_name, + messages, + project=self.project) + def test_illformed_id(self): # any ill-formed IDs should be regarded as non-existing ones.