Created
November 17, 2014 21:41
-
-
Save 72squared/c34d633b6de6e43d8a0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~$ py.test tests/test_cluster_obj.py | |
====================================== test session starts ======================================= | |
platform darwin -- Python 2.7.8 -- py-1.4.24 -- pytest-2.6.2 | |
collected 18 items | |
tests/test_cluster_obj.py ................F. | |
============================================ FAILURES ============================================ | |
_____________________________________ test_moved_redirection _____________________________________ | |
def test_moved_redirection(): | |
""" | |
Test that the client handles MOVED response. | |
At first call it should return a MOVED ResponseError that will point | |
the client to the next server it should talk to. | |
Important thing to verify is that it tries to talk to the second node. | |
""" | |
r = RedisCluster(host="127.0.0.1", port=7000) | |
m = Mock(autospec=True) | |
def ask_redirect_effect(connection, command_name, **options): | |
def ok_response(connection, command_name, **options): | |
assert connection.host == "127.0.0.1" | |
assert connection.port == 7001 | |
return "MOCK_OK" | |
m.side_effect = ok_response | |
resp = ResponseError() | |
resp.message = "MOVED 12182 127.0.0.1:7001" | |
raise resp | |
m.side_effect = ask_redirect_effect | |
r.parse_response = m | |
> assert r.set("foo", "bar") == "MOCK_OK" | |
tests/test_cluster_obj.py:358: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
build/bdist.macosx-10.10-x86_64/egg/redis/client.py:1055: in set | |
??? | |
rediscluster/utils.py:92: in inner | |
return func(*args, **kwargs) | |
rediscluster/client.py:323: in execute_command | |
self.connection_pool.release(r) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <[KeyError("'host'") raised in repr()] SafeRepr object at 0x10ef099e0> | |
connection = ClusterConnection<host=127.0.0.1,port=7002> | |
def release(self, connection): | |
""" | |
Releases the connection back to the pool | |
""" | |
self._checkpid() | |
if connection.pid != self.pid: | |
return | |
if connection in self._in_use_pubsub_connections: | |
self._in_use_pubsub_connections.remove(connection) | |
self._available_pubsub_connections.append(connection) | |
else: | |
# Remove the current connection from _in_use_connection and add it back to the available pool | |
> self._in_use_connections.get(connection._node["name"], set()).remove(connection) | |
E KeyError: ClusterConnection<host=127.0.0.1,port=7002> | |
rediscluster/connection.py:115: KeyError | |
============================== 1 failed, 17 passed in 0.25 seconds =============================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment