コード例 #1
0
ファイル: test_cluster.py プロジェクト: baranbartu/ruskit
def test_retry(monkeypatch):
    monkeypatch.setattr(redis.Redis, "ping", mock.Mock())
    times = [0]

    def execute(*args, **kwargs):
        times[0] += 1
        if times[0] < 4:
            raise redis.RedisError('Err: connection timeout')

    monkeypatch.setattr(redis.Redis, "execute_command", execute)

    node = ClusterNode("localhost", 8000, retry=3)
    node.setslot('NODE', 844, 'abcd')

    assert times[0] == 4
コード例 #2
0
ファイル: test_cluster.py プロジェクト: shengxianye/ruskit
def test_retry(monkeypatch):
    from ruskit.cluster import ClusterNode

    monkeypatch.setattr(redis.Redis, "ping", mock.Mock())
    times = [0]

    def execute(*args, **kwargs):
        times[0] += 1
        if times[0] < 4:
            raise redis.RedisError('Err: connection timeout')

    monkeypatch.setattr(redis.Redis, "execute_command", execute)

    node = ClusterNode("localhost", 8000, retry=3)
    node.setslot('NODE', 844, 'abcd')

    assert times[0] == 4