Test message delete when claim expires
The patch adds a test for message deletion after a claim has expired. The result of the test is that the message should be deleted. Unfortunately, some issues related to the state of the sqlalchemy driver make it quite hard for this test to work there without further changes. I'm proposing this patch with some skips in place for the scenarios where sqlalchemy is required, I'll propose a follow up patch to fix those issues and enable these tests. Closes-bug: #1369536 Change-Id: Icb12eed18c37455ad3528fa6a84fb8f2d8fcf19f
This commit is contained in:
parent
cd30b3903d
commit
92c22f54f9
@ -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):
|
||||
|
@ -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'
|
||||
|
@ -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.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user