Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Disable all pubsub tests because pubsub & publish command do not work…
Browse files Browse the repository at this point in the history
… properly and require major refactoring before it can be enabled again.
  • Loading branch information
Grokzen committed Sep 28, 2014
1 parent 0931127 commit 5e6c192
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 9 deletions.
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(1, basepath)

from redis import StrictRedis
from rediscluster import RedisCluster

from distutils.version import StrictVersion
Expand Down Expand Up @@ -49,12 +50,26 @@ def skip_if_server_version_lt(min_version):

@pytest.fixture()
def r(request, **kwargs):
"""
Create a Rediscluster instance with default settings.
"""
return _init_client(request, **kwargs)


@pytest.fixture()
def s(request, **kwargs):
"""
Create a RedisCluster instance with 'init_slot_cache' set to false
"""
s = _get_client(init_slot_cache=False, **kwargs)
assert s.slots == {}
assert s.nodes == []
return s


@pytest.fixture()
def t(request, *args, **kwargs):
"""
Create a regular StrictRedis object instance
"""
return StrictRedis(*args, **kwargs)
52 changes: 43 additions & 9 deletions tests/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time

import redis
from redis import StrictRedis
from redis.exceptions import ConnectionError
from redis._compat import basestring, u, unichr

Expand Down Expand Up @@ -53,6 +54,7 @@ def make_subscribe_test_data(pubsub, type):
assert False, 'invalid subscribe type: %s' % type


@pytest.mark.xfail(reason="Currently broken...")
class TestPubSubSubscribeUnsubscribe(object):

def _test_subscribe_unsubscribe(self, p, sub_type, unsub_type, sub_func,
Expand Down Expand Up @@ -212,24 +214,58 @@ def test_ignore_individual_subscribe_messages(self, r):
assert p.subscribed is False


@pytest.mark.xfail(reason="Currently broken...")
class TestPubSubMessages(object):
"""
Bug: Currently in cluster mode publish command will behave different then in
standard/non cluster mode. See (docs/Pubsub.md) for details.
Currently StrictRedis instances will be used to test pubsub because they
are easier to work with.
"""

def get_strict_redis_node(self, port, host="127.0.0.1"):
return StrictRedis(port=port, host=host)

def setup_method(self, method):
self.message = None

def message_handler(self, message):
self.message = message

@pytest.mark.xfail(reason="Currently broken...")
def test_published_message_to_channel(self, r):
p = r.pubsub(ignore_subscribe_messages=True)
def test_published_message_to_channel(self):
node = self.get_strict_redis_node(7000)
p = node.pubsub(ignore_subscribe_messages=True)
p.subscribe('foo')
assert r.publish('foo', 'test message') == 1

assert node.publish('foo', 'test message') == 1

message = wait_for_message(p)
assert isinstance(message, dict)
assert message == make_message('message', 'foo', 'test message')

@pytest.mark.xfail(reason="Currently broken...")
# Cleanup pubsub connections
p.close()

def test_publish_message_to_channel_other_server(self):
"""
Test that pubsub still works across the cluster on different nodes
"""
node_subscriber = self.get_strict_redis_node(7000)
p = node_subscriber.pubsub(ignore_subscribe_messages=True)
p.subscribe('foo')

node_sender = self.get_strict_redis_node(7001)
# This should return 0 because of no connected clients to this server.
assert node_sender.publish('foo', 'test message') == 0

message = wait_for_message(p)
assert isinstance(message, dict)
assert message == make_message('message', 'foo', 'test message')

# Cleanup pubsub connections
p.close()

def test_published_message_to_pattern(self, r):
p = r.pubsub(ignore_subscribe_messages=True)
p.subscribe('foo')
Expand All @@ -251,15 +287,13 @@ def test_published_message_to_pattern(self, r):
assert message2 in expected
assert message1 != message2

@pytest.mark.xfail(reason="Currently broken...")
def test_channel_message_handler(self, r):
p = r.pubsub(ignore_subscribe_messages=True)
p.subscribe(foo=self.message_handler)
assert r.publish('foo', 'test message') == 1
assert wait_for_message(p) is None
assert self.message == make_message('message', 'foo', 'test message')

@pytest.mark.xfail(reason="Currently broken...")
def test_pattern_message_handler(self, r):
p = r.pubsub(ignore_subscribe_messages=True)
p.psubscribe(**{'f*': self.message_handler})
Expand All @@ -268,7 +302,6 @@ def test_pattern_message_handler(self, r):
assert self.message == make_message('pmessage', 'foo', 'test message',
pattern='f*')

@pytest.mark.xfail(reason="Currently broken...")
def test_unicode_channel_message_handler(self, r):
p = r.pubsub(ignore_subscribe_messages=True)
channel = u('uni') + unichr(4456) + u('code')
Expand All @@ -278,7 +311,6 @@ def test_unicode_channel_message_handler(self, r):
assert wait_for_message(p) is None
assert self.message == make_message('message', channel, 'test message')

@pytest.mark.xfail(reason="Currently broken...")
def test_unicode_pattern_message_handler(self, r):
p = r.pubsub(ignore_subscribe_messages=True)
pattern = u('uni') + unichr(4456) + u('*')
Expand All @@ -290,6 +322,7 @@ def test_unicode_pattern_message_handler(self, r):
'test message', pattern=pattern)


@pytest.mark.xfail(reason="Currently broken...")
class TestPubSubAutoDecoding(object):
"These tests only validate that we get unicode values back"

Expand Down Expand Up @@ -389,6 +422,7 @@ def test_pattern_message_handler(self, r):
pattern=self.pattern)


@pytest.mark.xfail(reason="Currently broken...")
class TestPubSubRedisDown(object):

def test_channel_subscribe(self, r):
Expand Down

0 comments on commit 5e6c192

Please sign in to comment.