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