def _testClusterScaling(self, config, numJobs, numPreemptableJobs):
        # First do simple test of creating 100 preemptable and non-premptable jobs and check the
        # jobs are completed okay, then print the amount of worker time expended and the total
        # number of worker nodes used.

        logger.info("Creating dummy batch system and scalar")

        mock = MockBatchSystemAndProvisioner(config, secondsPerJob=2.0)
        clusterScaler = ClusterScaler(mock, mock, config)

        # Add 100 jobs to complete 
        logger.info("Creating test jobs")
        map(lambda x: mock.addJob(), range(numJobs))
        map(lambda x: mock.addJob(preemptable=True), range(numPreemptableJobs))

        # Add some completed jobs
        for preemptable in (True, False):
            if preemptable and numPreemptableJobs > 0 or not preemptable and numJobs > 0:
                # Add a 1000 random jobs
                for i in xrange(1000):
                    x = mock.getNodeShape(preemptable)
                    iJ = IssuedJob(1, memory=random.choice(range(1, x.memory)),
                                   cores=random.choice(range(1, x.cores)),
                                   disk=random.choice(range(1, x.disk)),
                                   preemptable=preemptable)
                    clusterScaler.addCompletedJob(iJ, random.choice(range(1, x.wallTime)))

        logger.info("Waiting for jobs to be processed")
        startTime = time.time()
        # Wait while the cluster the process chunks through the jobs
        while (mock.getNumberOfJobsIssued(preemptable=False) > 0 or
                       mock.getNumberOfJobsIssued(preemptable=True) > 0 or
                       mock.getNumberOfNodes() > 0 or mock.getNumberOfNodes(
            preemptable=True) > 0):
            logger.info("Running, non-preemptable queue size: %s, non-preemptable workers: %s, "
                        "preemptable queue size: %s, preemptable workers: %s",
                        mock.getNumberOfJobsIssued(preemptable=False),
                        mock.getNumberOfNodes(preemptable=False),
                        mock.getNumberOfJobsIssued(preemptable=True),
                        mock.getNumberOfNodes(preemptable=True))
            time.sleep(0.5)
        logger.info("We waited %s for cluster to finish" % (time.time() - startTime))
        clusterScaler.shutdown()

        # Print some info about the autoscaling
        for i, bs in enumerate(mock.delegates):
            preemptable = bool(i)
            logger.info("Preemptable: %s, Total-jobs: %s: Max-workers: %s,"
                        " Total-worker-time: %s, Worker-time-per-job: %s" %
                        (preemptable, bs.totalJobs, bs.maxWorkers,
                         bs.totalWorkerTime,
                         bs.totalWorkerTime / bs.totalJobs if bs.totalJobs > 0 else 0.0))
Iterating over a tag iterates over its contents.
dataset/ETHPy150Open BD2KGenomics/toil/src/toil/test/provisioners/clusterScalerTest.py/ClusterScalerTest._testClusterScaling--crossover with--dataset/ETHPy150Open socketubs/pyhn/pyhn/lib/bs4_py3/element.py/Tag.__iter__