def test_process_partitions_at_pos_swap_partition(self, mock_pick): action = ActionBalanceRackAware(self.args, self.cluster) b1 = self.cluster.brokers[1] b2 = self.cluster.brokers[2] b3 = Broker(3, 'brokerhost3.example.com') b4 = Broker(4, 'brokerhost4.example.com') self.cluster.add_broker(b3) self.cluster.add_broker(b4) b3.rack = "a" b4.rack = "c" self.cluster.topics['testTopic2'].partitions[0].swap_replicas(b2, b3) self.cluster.topics['testTopic1'].partitions[1].swap_replicas(b1, b4) mock_pick.return_value = self.cluster.topics['testTopic1'].partitions[1] action._process_partitions_at_pos(0) assert self.cluster.topics['testTopic1'].partitions[1].replicas == [b3, b4] assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2, b1]
def test_process_partitions_at_pos_swap_partition(self, mock_pick): action = ActionBalanceRackAware(self.args, self.cluster) b1 = self.cluster.brokers[1] b2 = self.cluster.brokers[2] b3 = Broker(3, 'brokerhost3.example.com') b4 = Broker(4, 'brokerhost4.example.com') self.cluster.add_broker(b3) self.cluster.add_broker(b4) b3.rack = "a" b4.rack = "c" self.cluster.topics['testTopic2'].partitions[0].swap_replicas(b2, b3) self.cluster.topics['testTopic1'].partitions[1].swap_replicas(b1, b4) mock_pick.return_value = self.cluster.topics['testTopic1'].partitions[ 1] action._process_partitions_at_pos(0) assert self.cluster.topics['testTopic1'].partitions[1].replicas == [ b3, b4 ] assert self.cluster.topics['testTopic2'].partitions[0].replicas == [ b2, b1 ]
def test_process_partitions_at_pos_nochange(self, mock_pick): action = ActionBalanceRackAware(self.args, self.cluster) action._process_partitions_at_pos(0) mock_pick.assert_not_called()
def test_process_partitions_at_pos_nochange(self, mock_pick): action = ActionBalanceRackAware(self.args, self.cluster) action._process_partitions_at_pos(0) mock_pick.assert_not_called()