コード例 #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
ファイル: test_even.py プロジェクト: ambroff/kafka-tools
    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
ファイル: test_even.py プロジェクト: ab212/kafka-tools
    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
ファイル: test_even.py プロジェクト: ambroff/kafka-tools
    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
ファイル: test_even.py プロジェクト: ab212/kafka-tools
    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
ファイル: test_even.py プロジェクト: xuwenyihust/kafka-tools
    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
ファイル: test_even.py プロジェクト: ambroff/kafka-tools
    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
ファイル: test_even.py プロジェクト: ambroff/kafka-tools
    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
ファイル: test_even.py プロジェクト: ambroff/kafka-tools
    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
ファイル: test_even.py プロジェクト: ab212/kafka-tools
    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
ファイル: test_even.py プロジェクト: xuwenyihust/kafka-tools
    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
ファイル: test_even.py プロジェクト: xuwenyihust/kafka-tools
 def test_create_class(self):
     action = ActionBalanceEven(self.args, self.cluster)
     assert isinstance(action, ActionBalanceEven)
コード例 #13
0
ファイル: test_even.py プロジェクト: xuwenyihust/kafka-tools
    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
ファイル: test_even.py プロジェクト: xuwenyihust/kafka-tools
 def test_skip_topic_ok(self):
     action = ActionBalanceEven(self.args, self.cluster)
     assert action.check_topic_ok(self.cluster.topics['testTopic1'])
コード例 #15
0
ファイル: test_even.py プロジェクト: ambroff/kafka-tools
    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
ファイル: test_even.py プロジェクト: ambroff/kafka-tools
 def test_skip_topic_ok(self):
     action = ActionBalanceEven(self.args, self.cluster)
     assert action.check_topic_ok(self.cluster.topics['testTopic1'])