示例#1
0
    def test_process_cluster(self):
        self.args.brokers = [1]
        action = ActionTrim(self.args, self.cluster)
        action.process_cluster()

        b2 = self.cluster.brokers[2]
        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [b2]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [b2]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [b2]
示例#2
0
    def test_process_cluster(self):
        self.args.brokers = [1]
        action = ActionTrim(self.args, self.cluster)
        action.process_cluster()

        b2 = self.cluster.brokers[2]
        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [b2]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [b2]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [b2]
示例#3
0
    def test_process_cluster_no_change(self):
        self.cluster.add_broker(Broker("brokerhost3.example.com", id=3))
        self.args.brokers = [3]
        action = ActionTrim(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]
示例#4
0
    def test_process_cluster_no_change(self):
        self.cluster.add_broker(Broker("brokerhost3.example.com", id=3))
        self.args.brokers = [3]
        action = ActionTrim(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_configure_args(self):
     ActionTrim.configure_args(self.subparsers)
     sys.argv = ['kafka-assigner', 'trim', '-b', '1']
     parsed_args = self.parser.parse_args()
     assert parsed_args.action == 'trim'
示例#6
0
 def test_process_cluster_error(self):
     self.args.brokers = [1, 2]
     action = ActionTrim(self.args, self.cluster)
     self.assertRaises(NotEnoughReplicasException, action.process_cluster)
示例#7
0
 def test_configure_args(self):
     ActionTrim.configure_args(self.subparsers)
     sys.argv = ['kafka-assigner', 'trim', '-b', '1']
     parsed_args = self.parser.parse_args()
     assert parsed_args.action == 'trim'
示例#8
0
 def test_create_class(self):
     self.args.brokers = [1]
     action = ActionTrim(self.args, self.cluster)
     assert isinstance(action, ActionTrim)