Merge "Test message delete when claim expires"

This commit is contained in:
Jenkins 2014-11-25 03:47:45 +00:00 committed by Gerrit Code Review
commit 38a4cbab00
3 changed files with 55 additions and 0 deletions

View File

@ -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):

View File

@ -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'

View File

@ -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.