Merge "Test message delete when claim expires"
This commit is contained in:
commit
38a4cbab00
@ -507,6 +507,16 @@ class PooledClaimsTests(base.ClaimControllerTest):
|
|||||||
control_driver_class = mongodb.ControlDriver
|
control_driver_class = mongodb.ControlDriver
|
||||||
controller_base_class = pooling.RoutingController
|
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
|
@testing.requires_mongodb
|
||||||
class MongodbFlavorsTest(base.FlavorsControllerTest):
|
class MongodbFlavorsTest(base.FlavorsControllerTest):
|
||||||
|
@ -115,6 +115,14 @@ class SqlalchemyClaimTests(base.ClaimControllerTest):
|
|||||||
driver_class = sqlalchemy.DataDriver
|
driver_class = sqlalchemy.DataDriver
|
||||||
controller_class = controllers.ClaimController
|
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):
|
class SqlalchemyPoolsTest(base.PoolsControllerTest):
|
||||||
driver_class = sqlalchemy.ControlDriver
|
driver_class = sqlalchemy.ControlDriver
|
||||||
@ -155,6 +163,14 @@ class PooledClaimsTests(base.ClaimControllerTest):
|
|||||||
control_driver_class = sqlalchemy.ControlDriver
|
control_driver_class = sqlalchemy.ControlDriver
|
||||||
controller_base_class = pooling.RoutingController
|
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):
|
class PooledQueueTests(base.QueueControllerTest):
|
||||||
config_file = 'wsgi_sqlalchemy_pooled.conf'
|
config_file = 'wsgi_sqlalchemy_pooled.conf'
|
||||||
|
@ -19,6 +19,7 @@ import time
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
|
import mock
|
||||||
from oslo.utils import timeutils
|
from oslo.utils import timeutils
|
||||||
import six
|
import six
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
@ -881,6 +882,34 @@ class ClaimControllerTest(ControllerBaseTest):
|
|||||||
self.controller.update(self.queue_name, claim_id,
|
self.controller.update(self.queue_name, claim_id,
|
||||||
meta, project=self.project)
|
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):
|
def test_illformed_id(self):
|
||||||
# any ill-formed IDs should be regarded as non-existing ones.
|
# any ill-formed IDs should be regarded as non-existing ones.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user