def test_ple(self, mock_execute, mock_sleep): cluster = set_up_cluster() args = argparse.Namespace(ple_wait=0, zookeeper='zkconnect', tools_path='/path/to/tools') batches = [ ReplicaElection(cluster.brokers[1].partitions, args.ple_wait), ReplicaElection(cluster.brokers[2].partitions, args.ple_wait) ] run_preferred_replica_elections(batches, args, args.tools_path, [], False) mock_sleep.assert_called_once_with(0) mock_execute.assert_has_calls([ call(1, 2, 'zkconnect', '/path/to/tools', [], False), call(2, 2, 'zkconnect', '/path/to/tools', [], False) ])
def setUp(self): self.topic = Topic('testTopic', 10) self.broker = Broker(1, 'brokerhost1.example.com') for i in range(10): self.topic.partitions[i].replicas = [self.broker] self.replica_election = ReplicaElection(self.topic.partitions, pause_time=0)