def test_process_cluster_no_change(self): action = ActionReorder(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]
def test_process_cluster(self): b1 = self.cluster.brokers[1] b2 = self.cluster.brokers[2] self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(b1, b2) action = ActionReorder(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 == [b1, b2] assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2, b1] assert self.cluster.topics['testTopic2'].partitions[1].replicas == [b1, b2]
class ActionBalanceLeader(ActionBalanceModule): name = "leader" helpstr = "Balance the cluster leadership by reordering the partition replica lists" def __init__(self, args, cluster): super(ActionBalanceLeader, self).__init__(args, cluster) # This module merely calls the main "reorder" module, so we're going to instantiate a copy of that self._reorder = ActionReorder(args, cluster) def process_cluster(self): # Call the reorder module self._reorder.process_cluster()
def test_process_cluster_no_change(self): action = ActionReorder(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 ]
def test_process_cluster(self): b1 = self.cluster.brokers[1] b2 = self.cluster.brokers[2] self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions( b1, b2) action = ActionReorder(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 == [ b1, b2 ] assert self.cluster.topics['testTopic2'].partitions[0].replicas == [ b2, b1 ] assert self.cluster.topics['testTopic2'].partitions[1].replicas == [ b1, b2 ]