def setUp(self): uris = ['host{}:{}'.format(i, p) \ for i, p in enumerate(range(6000,6006))] nodes = [ClusterNode.from_uri(u) for u in uris[:3]] for n in nodes: n.r = MockMember(n) self.cluster = Cluster(nodes) self.new_nodes = [ClusterNode.from_uri(u) for u in uris[3:]] for n in self.new_nodes: n.r = MockNewNode(n)
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 setUp(self): self.uris = ['host{}:{}'.format(i, p) \ for i, p in enumerate(range(6000,6006))] self.cluster = Cluster(self.gen_nodes()) self.new_nodes = [ClusterNode.from_uri(u) for u in self.uris[3:]] for n in self.new_nodes: n.r = MockNewNode(n)
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
def gen_nodes(self): nodes = [ClusterNode.from_uri(u) for u in self.uris[:3]] for n in nodes: n.r = MockMember(n) return nodes
def setUp(self): self.uris = ["host{}:{}".format(i, p) for i, p in enumerate(range(6000, 6006))] self.cluster = Cluster(self.gen_nodes()) self.new_nodes = [ClusterNode.from_uri(u) for u in self.uris[3:]] for n in self.new_nodes: n.r = MockNewNode(n)