Ejemplo n.º 1
0
    def test_process_cluster_odd_count(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.add_topic(Topic("testTopic3", 3))
        partition = self.cluster.topics['testTopic3'].partitions[0]
        partition.add_replica(b1, 0)
        partition.add_replica(b2, 1)
        partition = self.cluster.topics['testTopic3'].partitions[1]
        partition.add_replica(b1, 0)
        partition.add_replica(b2, 1)
        partition = self.cluster.topics['testTopic3'].partitions[2]
        partition.add_replica(b1, 0)
        partition.add_replica(b2, 1)
        self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(b1, b2)

        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()

        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [b1, b2]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [b1, b2]
        assert self.cluster.topics['testTopic3'].partitions[0].replicas == [b1, b2]
        assert self.cluster.topics['testTopic3'].partitions[1].replicas == [b1, b2]
        assert self.cluster.topics['testTopic3'].partitions[2].replicas == [b1, b2]
Ejemplo n.º 2
0
    def test_process_cluster_one_move(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(b1, b2)

        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()
        assert self.is_cluster_even()
Ejemplo n.º 3
0
    def test_process_cluster_one_move(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(b1, b2)

        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()
        assert self.is_cluster_even()
Ejemplo n.º 4
0
    def test_process_cluster_no_change(self):
        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()

        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [b1, b2]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [b1, b2]
Ejemplo n.º 5
0
    def test_process_cluster_no_change(self):
        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()

        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [b1, b2]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [b1, b2]
Ejemplo n.º 6
0
    def test_skip_topic_different_rf(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.add_topic(Topic("testTopic3", 2))
        partition = self.cluster.topics['testTopic3'].partitions[0]
        partition.add_replica(b1, 0)
        partition.add_replica(b2, 1)
        partition = self.cluster.topics['testTopic3'].partitions[1]
        partition.add_replica(b1, 0)

        action = ActionBalanceEven(self.args, self.cluster)
        assert not action.check_topic_ok(self.cluster.topics['testTopic3'])
Ejemplo n.º 7
0
    def test_skip_topic_different_rf(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.add_topic(Topic("testTopic3", 2))
        partition = self.cluster.topics['testTopic3'].partitions[0]
        partition.add_replica(b1, 0)
        partition.add_replica(b2, 1)
        partition = self.cluster.topics['testTopic3'].partitions[1]
        partition.add_replica(b1, 0)

        action = ActionBalanceEven(self.args, self.cluster)
        assert not action.check_topic_ok(self.cluster.topics['testTopic3'])
Ejemplo n.º 8
0
    def test_process_cluster_exclude(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(b1, b2)
        self.args.exclude_topics = ['testTopic1']

        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()

        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [b2, b1]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [b1, b2]
Ejemplo n.º 9
0
    def test_process_cluster_different_rf(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.add_topic(Topic("testTopic3", 2))
        partition = self.cluster.topics['testTopic3'].partitions[0]
        partition.add_replica(b1, 0)
        partition.add_replica(b2, 1)
        partition = self.cluster.topics['testTopic3'].partitions[1]
        partition.add_replica(b1, 0)
        self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(b1, b2)

        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()
        assert self.is_cluster_even(skip_topics=['testTopic3'])
Ejemplo n.º 10
0
    def test_process_cluster_different_rf(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.add_topic(Topic("testTopic3", 2))
        partition = self.cluster.topics['testTopic3'].partitions[0]
        partition.add_replica(b1, 0)
        partition.add_replica(b2, 1)
        partition = self.cluster.topics['testTopic3'].partitions[1]
        partition.add_replica(b1, 0)
        self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(b1, b2)

        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()
        assert self.is_cluster_even(skip_topics=['testTopic3'])
Ejemplo n.º 11
0
    def test_process_cluster_exclude(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(
            b1, b2)
        self.args.exclude_topics = ['testTopic1']

        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()

        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [
            b2, b1
        ]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [
            b2, b1
        ]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [
            b2, b1
        ]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [
            b1, b2
        ]
Ejemplo n.º 12
0
 def test_create_class(self):
     action = ActionBalanceEven(self.args, self.cluster)
     assert isinstance(action, ActionBalanceEven)
Ejemplo n.º 13
0
    def test_process_cluster_4broker(self):
        self.cluster = set_up_cluster_4broker()

        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()
        assert self.is_cluster_even(skip_topics=['testTopic3'])
Ejemplo n.º 14
0
 def test_skip_topic_ok(self):
     action = ActionBalanceEven(self.args, self.cluster)
     assert action.check_topic_ok(self.cluster.topics['testTopic1'])
Ejemplo n.º 15
0
    def test_process_cluster_4broker(self):
        self.cluster = set_up_cluster_4broker()

        action = ActionBalanceEven(self.args, self.cluster)
        action.process_cluster()
        assert self.is_cluster_even(skip_topics=['testTopic3'])
Ejemplo n.º 16
0
 def test_skip_topic_ok(self):
     action = ActionBalanceEven(self.args, self.cluster)
     assert action.check_topic_ok(self.cluster.topics['testTopic1'])