"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "zaqar/tests/unit/storage/test_impl_redis.py" between
zaqar-5.0.0.tar.gz and zaqar-7.0.0.tar.gz

About: OpenStack Zaqar is a multi-tenant cloud messaging and notification service for web and mobile developers.
The "Rocky" series (latest release).

test_impl_redis.py  (zaqar-5.0.0):test_impl_redis.py  (zaqar-7.0.0)
skipping to change at line 26 skipping to change at line 26
import time import time
import uuid import uuid
import mock import mock
from oslo_utils import timeutils from oslo_utils import timeutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
import redis import redis
from zaqar.common import cache as oslo_cache from zaqar.common import cache as oslo_cache
from zaqar.common import errors from zaqar.common import errors
from zaqar.conf import drivers_message_store_redis
from zaqar import storage from zaqar import storage
from zaqar.storage import mongodb from zaqar.storage import pooling
from zaqar.storage.redis import controllers from zaqar.storage.redis import controllers
from zaqar.storage.redis import driver from zaqar.storage.redis import driver
from zaqar.storage.redis import messages from zaqar.storage.redis import messages
from zaqar.storage.redis import options
from zaqar.storage.redis import utils from zaqar.storage.redis import utils
from zaqar import tests as testing from zaqar import tests as testing
from zaqar.tests.unit.storage import base from zaqar.tests.unit.storage import base
def _create_sample_message(now=None, claimed=False, body=None): def _create_sample_message(now=None, claimed=False, body=None):
if now is None: if now is None:
now = timeutils.utcnow_ts() now = timeutils.utcnow_ts()
if claimed: if claimed:
claim_id = uuid.uuid4() claim_id = uuid.uuid4()
skipping to change at line 66 skipping to change at line 66
body=body body=body
) )
class RedisUtilsTest(testing.TestBase): class RedisUtilsTest(testing.TestBase):
config_file = 'wsgi_redis.conf' config_file = 'wsgi_redis.conf'
def setUp(self): def setUp(self):
super(RedisUtilsTest, self).setUp() super(RedisUtilsTest, self).setUp()
self.conf.register_opts(options.MESSAGE_REDIS_OPTIONS, self.conf.register_opts(drivers_message_store_redis.ALL_OPTS,
group=options.MESSAGE_REDIS_GROUP) group=drivers_message_store_redis.GROUP_NAME)
self.redis_conf = self.conf[options.MESSAGE_REDIS_GROUP] self.redis_conf = self.conf[drivers_message_store_redis.GROUP_NAME]
MockDriver = collections.namedtuple('MockDriver', 'redis_conf') MockDriver = collections.namedtuple('MockDriver', 'redis_conf')
self.driver = MockDriver(self.redis_conf) self.driver = MockDriver(self.redis_conf)
def test_scope_queue_name(self): def test_scope_queue_name(self):
self.assertEqual('.my-q', utils.scope_queue_name('my-q')) self.assertEqual('.my-q', utils.scope_queue_name('my-q'))
self.assertEqual('.my-q', utils.scope_queue_name('my-q', None)) self.assertEqual('.my-q', utils.scope_queue_name('my-q', None))
self.assertEqual('123.my-q', utils.scope_queue_name('my-q', '123')) self.assertEqual('123.my-q', utils.scope_queue_name('my-q', '123'))
self.assertEqual('123.my-q_1', utils.scope_queue_name('my-q_1', '123')) self.assertEqual('123.my-q_1', utils.scope_queue_name('my-q_1', '123'))
skipping to change at line 244 skipping to change at line 244
uri = driver.ConnectionURI('redis://example.com:7777') uri = driver.ConnectionURI('redis://example.com:7777')
self.assertEqual(driver.STRATEGY_TCP, uri.strategy) self.assertEqual(driver.STRATEGY_TCP, uri.strategy)
self.assertEqual(7777, uri.port) self.assertEqual(7777, uri.port)
uri = driver.ConnectionURI( uri = driver.ConnectionURI(
'redis://example.com:7777?socket_timeout=1') 'redis://example.com:7777?socket_timeout=1')
self.assertEqual(driver.STRATEGY_TCP, uri.strategy) self.assertEqual(driver.STRATEGY_TCP, uri.strategy)
self.assertEqual(7777, uri.port) self.assertEqual(7777, uri.port)
self.assertEqual(1.0, uri.socket_timeout) self.assertEqual(1.0, uri.socket_timeout)
uri = driver.ConnectionURI(
'redis://test123@example.com:7777?socket_timeout=1&dbid=5')
self.assertEqual(driver.STRATEGY_TCP, uri.strategy)
self.assertEqual(7777, uri.port)
self.assertEqual(1.0, uri.socket_timeout)
self.assertEqual(5, uri.dbid)
self.assertEqual('test123', uri.password)
def test_connection_uri_unix_socket(self): def test_connection_uri_unix_socket(self):
uri = driver.ConnectionURI('redis:/tmp/redis.sock') uri = driver.ConnectionURI('redis:/tmp/redis.sock')
self.assertEqual(driver.STRATEGY_UNIX, uri.strategy) self.assertEqual(driver.STRATEGY_UNIX, uri.strategy)
self.assertEqual('/tmp/redis.sock', uri.unix_socket_path) self.assertEqual('/tmp/redis.sock', uri.unix_socket_path)
self.assertEqual(0.1, uri.socket_timeout) self.assertEqual(0.1, uri.socket_timeout)
uri = driver.ConnectionURI('redis:/tmp/redis.sock?socket_timeout=1.5') uri = driver.ConnectionURI('redis:/tmp/redis.sock?socket_timeout=1.5')
self.assertEqual(driver.STRATEGY_UNIX, uri.strategy) self.assertEqual(driver.STRATEGY_UNIX, uri.strategy)
self.assertEqual('/tmp/redis.sock', uri.unix_socket_path) self.assertEqual('/tmp/redis.sock', uri.unix_socket_path)
self.assertEqual(1.5, uri.socket_timeout) self.assertEqual(1.5, uri.socket_timeout)
uri = driver.ConnectionURI(
'redis:test123@/tmp/redis.sock?socket_timeout=1.5&dbid=5')
self.assertEqual(driver.STRATEGY_UNIX, uri.strategy)
self.assertEqual('/tmp/redis.sock', uri.unix_socket_path)
self.assertEqual(1.5, uri.socket_timeout)
self.assertEqual(5, uri.dbid)
self.assertEqual('test123', uri.password)
def test_connection_uri_sentinel(self): def test_connection_uri_sentinel(self):
uri = driver.ConnectionURI('redis://s1?master=dumbledore') uri = driver.ConnectionURI('redis://s1?master=dumbledore')
self.assertEqual(driver.STRATEGY_SENTINEL, uri.strategy) self.assertEqual(driver.STRATEGY_SENTINEL, uri.strategy)
self.assertEqual([('s1', 26379)], uri.sentinels) self.assertEqual([('s1', 26379)], uri.sentinels)
self.assertEqual('dumbledore', uri.master) self.assertEqual('dumbledore', uri.master)
self.assertEqual(0.1, uri.socket_timeout) self.assertEqual(0.1, uri.socket_timeout)
uri = driver.ConnectionURI('redis://s1,s2?master=dumbledore') uri = driver.ConnectionURI('redis://s1,s2?master=dumbledore')
self.assertEqual(driver.STRATEGY_SENTINEL, uri.strategy) self.assertEqual(driver.STRATEGY_SENTINEL, uri.strategy)
self.assertEqual([('s1', 26379), ('s2', 26379)], uri.sentinels) self.assertEqual([('s1', 26379), ('s2', 26379)], uri.sentinels)
skipping to change at line 281 skipping to change at line 297
self.assertEqual('dumbledore', uri.master) self.assertEqual('dumbledore', uri.master)
self.assertEqual(0.1, uri.socket_timeout) self.assertEqual(0.1, uri.socket_timeout)
uri = driver.ConnectionURI( uri = driver.ConnectionURI(
'redis://s1?master=dumbledore&socket_timeout=0.5') 'redis://s1?master=dumbledore&socket_timeout=0.5')
self.assertEqual(driver.STRATEGY_SENTINEL, uri.strategy) self.assertEqual(driver.STRATEGY_SENTINEL, uri.strategy)
self.assertEqual([('s1', 26379)], uri.sentinels) self.assertEqual([('s1', 26379)], uri.sentinels)
self.assertEqual('dumbledore', uri.master) self.assertEqual('dumbledore', uri.master)
self.assertEqual(0.5, uri.socket_timeout) self.assertEqual(0.5, uri.socket_timeout)
uri = driver.ConnectionURI(
'redis://test123@s1?master=dumbledore&socket_timeout=0.5&dbid=5')
self.assertEqual(driver.STRATEGY_SENTINEL, uri.strategy)
self.assertEqual([('s1', 26379)], uri.sentinels)
self.assertEqual('dumbledore', uri.master)
self.assertEqual(0.5, uri.socket_timeout)
self.assertEqual(5, uri.dbid)
self.assertEqual('test123', uri.password)
@testing.requires_redis @testing.requires_redis
class RedisQueuesTest(base.QueueControllerTest): class RedisQueuesTest(base.QueueControllerTest):
driver_class = driver.DataDriver driver_class = driver.DataDriver
config_file = 'wsgi_redis.conf' config_file = 'wsgi_redis.conf'
controller_class = controllers.QueueController controller_class = controllers.QueueController
control_driver_class = mongodb.ControlDriver control_driver_class = driver.ControlDriver
def setUp(self): def setUp(self):
super(RedisQueuesTest, self).setUp() super(RedisQueuesTest, self).setUp()
self.connection = self.driver.connection self.connection = self.driver.connection
self.msg_controller = self.driver.message_controller self.msg_controller = self.driver.message_controller
def tearDown(self): def tearDown(self):
super(RedisQueuesTest, self).tearDown() super(RedisQueuesTest, self).tearDown()
self.connection.flushdb() self.connection.flushdb()
@testing.requires_redis @testing.requires_redis
class RedisMessagesTest(base.MessageControllerTest): class RedisMessagesTest(base.MessageControllerTest):
driver_class = driver.DataDriver driver_class = driver.DataDriver
config_file = 'wsgi_redis.conf' config_file = 'wsgi_redis.conf'
controller_class = controllers.MessageController controller_class = controllers.MessageController
control_driver_class = mongodb.ControlDriver control_driver_class = driver.ControlDriver
gc_interval = 1 gc_interval = 1
def setUp(self): def setUp(self):
super(RedisMessagesTest, self).setUp() super(RedisMessagesTest, self).setUp()
self.connection = self.driver.connection self.connection = self.driver.connection
def tearDown(self): def tearDown(self):
super(RedisMessagesTest, self).tearDown() super(RedisMessagesTest, self).tearDown()
self.connection.flushdb() self.connection.flushdb()
skipping to change at line 369 skipping to change at line 394
}] }]
client_id = "invalid_uuid" client_id = "invalid_uuid"
self.assertRaises(ValueError, self.controller.post, queue_name, msgs, self.assertRaises(ValueError, self.controller.post, queue_name, msgs,
client_id) client_id)
@testing.requires_redis @testing.requires_redis
class RedisClaimsTest(base.ClaimControllerTest): class RedisClaimsTest(base.ClaimControllerTest):
driver_class = driver.DataDriver driver_class = driver.DataDriver
config_file = 'wsgi_redis.conf' config_file = 'wsgi_redis.conf'
controller_class = controllers.ClaimController controller_class = controllers.ClaimController
control_driver_class = mongodb.ControlDriver control_driver_class = driver.ControlDriver
def setUp(self): def setUp(self):
super(RedisClaimsTest, self).setUp() super(RedisClaimsTest, self).setUp()
self.connection = self.driver.connection self.connection = self.driver.connection
def tearDown(self): def tearDown(self):
super(RedisClaimsTest, self).tearDown() super(RedisClaimsTest, self).tearDown()
self.connection.flushdb() self.connection.flushdb()
def test_claim_doesnt_exist(self): def test_claim_doesnt_exist(self):
skipping to change at line 469 skipping to change at line 494
num_removed = self.controller._gc(self.queue_name, None) num_removed = self.controller._gc(self.queue_name, None)
self.assertEqual(5, num_removed) self.assertEqual(5, num_removed)
@testing.requires_redis @testing.requires_redis
class RedisSubscriptionTests(base.SubscriptionControllerTest): class RedisSubscriptionTests(base.SubscriptionControllerTest):
driver_class = driver.DataDriver driver_class = driver.DataDriver
config_file = 'wsgi_redis.conf' config_file = 'wsgi_redis.conf'
controller_class = controllers.SubscriptionController controller_class = controllers.SubscriptionController
control_driver_class = driver.ControlDriver control_driver_class = driver.ControlDriver
@testing.requires_redis
class RedisPoolsTests(base.PoolsControllerTest):
config_file = 'wsgi_redis.conf'
driver_class = driver.ControlDriver
controller_class = controllers.PoolsController
control_driver_class = driver.ControlDriver
def setUp(self):
super(RedisPoolsTests, self).setUp()
self.pools_controller = self.driver.pools_controller
# Let's create one pool
self.pool = str(uuid.uuid1())
self.pools_controller.create(self.pool, 100, 'localhost', options={})
self.pool1 = str(uuid.uuid1())
self.flavor = str(uuid.uuid1())
self.flavors_controller.create(self.flavor,
project=self.project,
capabilities={})
self.pools_controller.create(self.pool1, 100, 'localhost1',
flavor=self.flavor, options={})
self.flavors_controller = self.driver.flavors_controller
def tearDown(self):
self.pools_controller.drop_all()
super(RedisPoolsTests, self).tearDown()
def test_delete_pool_used_by_flavor(self):
with testing.expect(storage.errors.PoolInUseByFlavor):
self.pools_controller.delete(self.pool1)
def test_mismatching_capabilities_fifo(self):
# NOTE(gengchc2): The fifo function is not implemented
# in redis, we skip it.
self.skip("The fifo function is not implemented")
def test_mismatching_capabilities1(self):
# NOTE(gengchc2): This test is used for testing mismatchming
# capabilities in pool with flavor
with testing.expect(storage.errors.PoolCapabilitiesMismatch):
self.pools_controller.create(str(uuid.uuid1()),
100, 'mongodb://localhost',
flavor=self.flavor,
options={})
@testing.requires_redis
class RedisCatalogueTests(base.CatalogueControllerTest):
driver_class = driver.ControlDriver
controller_class = controllers.CatalogueController
control_driver_class = driver.ControlDriver
config_file = 'wsgi_redis.conf'
def setUp(self):
super(RedisCatalogueTests, self).setUp()
self.addCleanup(self.controller.drop_all)
@testing.requires_redis
class PooledMessageTests(base.MessageControllerTest):
config_file = 'wsgi_redis_pooled.conf'
controller_class = pooling.MessageController
driver_class = pooling.DataDriver
control_driver_class = driver.ControlDriver
controller_base_class = storage.Message
# NOTE(kgriffs): Redis's TTL scavenger only runs once a minute
gc_interval = 60
@testing.requires_redis
class PooledClaimsTests(base.ClaimControllerTest):
config_file = 'wsgi_redis_pooled.conf'
controller_class = pooling.ClaimController
driver_class = pooling.DataDriver
control_driver_class = driver.ControlDriver
controller_base_class = storage.Claim
def setUp(self):
super(PooledClaimsTests, self).setUp()
self.connection = self.controller._pool_catalog.lookup(
self.queue_name, self.project)._storage.\
claim_controller.driver.connection
def tearDown(self):
super(PooledClaimsTests, self).tearDown()
self.connection.flushdb()
# NOTE(gengchc2): Unittest for new flavor configure scenario.
@testing.requires_redis
class RedisFlavorsTest1(base.FlavorsControllerTest1):
driver_class = driver.ControlDriver
controller_class = controllers.FlavorsController
control_driver_class = driver.ControlDriver
config_file = 'wsgi_redis.conf'
def setUp(self):
super(RedisFlavorsTest1, self).setUp()
self.addCleanup(self.controller.drop_all)
 End of changes. 12 change blocks. 
8 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)