예제 #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]
예제 #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()
예제 #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()
예제 #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]
예제 #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]
예제 #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'])
예제 #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'])
예제 #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]
예제 #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'])
예제 #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'])
예제 #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
        ]
예제 #12
0
 def test_create_class(self):
     action = ActionBalanceEven(self.args, self.cluster)
     assert isinstance(action, ActionBalanceEven)
예제 #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'])
예제 #14
0
 def test_skip_topic_ok(self):
     action = ActionBalanceEven(self.args, self.cluster)
     assert action.check_topic_ok(self.cluster.topics['testTopic1'])
예제 #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'])
예제 #16
0
 def test_skip_topic_ok(self):
     action = ActionBalanceEven(self.args, self.cluster)
     assert action.check_topic_ok(self.cluster.topics['testTopic1'])