예제 #1
0
def test_migrate_node_with_count():
    from ruskit.cluster import Cluster

    node1 = MockNode("node1", list(range(3)), "master")
    node2 = MockNode("node2", list(range(2, 8)), "master")
    node3 = MockNode("node3", list(range(8, 12)), "master")

    cluster = Cluster([node1, node2, node3])

    with mock.patch.object(cluster, "migrate") as mock_migrate:
        cluster.migrate_node(node2, count=5)

    calls = [mock.call(node2, node1, 3), mock.call(node2, node3, 2)]
    mock_migrate.assert_has_calls(calls)
예제 #2
0
def test_migrate_node_with_income():
    from ruskit.cluster import Cluster

    node1 = MockNode("node1", list(range(3)), "master")
    node2 = MockNode("node2", list(range(2, 5)), "master")
    node3 = MockNode("node3", list(range(5, 10)), "master")

    cluster = Cluster([node1, node2, node3])

    with mock.patch.object(cluster, "migrate") as mock_migrate:
        cluster.migrate_node(node2, income=True)

    calls = [mock.call(node3, node2, 2), mock.call(node1, node2, 1)]
    mock_migrate.assert_has_calls(calls)
예제 #3
0
def test_migrate_node_with_income():
    node1 = MockNode("node1", list(range(3)), "master")
    node2 = MockNode("node2", list(range(2, 5)), "master")
    node3 = MockNode("node3", list(range(5, 10)), "master")

    cluster = Cluster([node1, node2, node3])

    with mock.patch.object(cluster, "migrate") as mock_migrate:
        cluster.migrate_node(node2, income=True)

    calls = [
        mock.call(node3, node2, 2),
        mock.call(node1, node2, 1)
    ]
    mock_migrate.assert_has_calls(calls)
예제 #4
0
def test_migrate_node_with_count():
    node1 = MockNode("node1", list(range(3)), "master")
    node2 = MockNode("node2", list(range(2, 8)), "master")
    node3 = MockNode("node3", list(range(8, 12)), "master")

    cluster = Cluster([node1, node2, node3])

    with mock.patch.object(cluster, "migrate") as mock_migrate:
        cluster.migrate_node(node2, count=5)

    calls = [
        mock.call(node2, node1, 3),
        mock.call(node2, node3, 2)
    ]
    mock_migrate.assert_has_calls(calls)
예제 #5
0
 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)
예제 #6
0
def test_migrate_node():
    from ruskit.cluster import Cluster

    node1 = MockNode("node1", list(range(3)), "master")
    node2 = MockNode("node2", list(range(2, 5)), "master")
    node3 = MockNode("node3", list(range(5, 8)), "master")

    cluster = Cluster([node1, node2, node3])

    with mock.patch.object(cluster, "migrate") as mock_migrate:
        cluster.migrate_node(node2)

    calls = [
        mock.call(node2, node1, 2),
        mock.call(node2, node3, 1)
    ]
    mock_migrate.assert_has_calls(calls)
예제 #7
0
 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)