Beispiel #1
0
    def test_all_colocate(self) -> None:
        # all tasks should land in one bucket
        tasks = self.build_tasks(10)
        for task in tasks:
            task.config.colocate = True

        buckets = bucket_tasks(tasks)

        for bucket in buckets.values():
            self.assertEqual(len(bucket), 10)

        self.check_buckets(buckets, tasks, bucket_count=1)
Beispiel #2
0
    def test_all_unique_job(self) -> None:
        # everything has a unique job_id
        tasks = self.build_tasks(10)
        for task in tasks:
            job_id = uuid4()
            task.job_id = job_id
            task.config.job_id = job_id

        buckets = bucket_tasks(tasks)

        for bucket in buckets.values():
            self.assertEqual(len(bucket), 1)

        self.check_buckets(buckets, tasks, bucket_count=10)
Beispiel #3
0
    def test_multiple_job_buckets(self) -> None:
        # at most 3 tasks per bucket, by job_id
        tasks = self.build_tasks(10)
        for task_chunks in chunks(tasks, 3):
            job_id = uuid4()
            for task in task_chunks:
                task.job_id = job_id
                task.config.job_id = job_id

        buckets = bucket_tasks(tasks)

        for bucket in buckets.values():
            self.assertLessEqual(len(bucket), 3)

        self.check_buckets(buckets, tasks, bucket_count=4)
Beispiel #4
0
    def test_partial_colocate(self) -> None:
        # 2 tasks should land on their own, the rest should be colocated into a
        # single bucket.

        tasks = self.build_tasks(10)

        # a the task came before colocation was defined
        tasks[0].config.colocate = None

        # a the task shouldn't be colocated
        tasks[1].config.colocate = False

        buckets = bucket_tasks(tasks)

        lengths = []
        for bucket in buckets.values():
            lengths.append(len(bucket))
        self.assertEqual([1, 1, 8], sorted(lengths))
        self.check_buckets(buckets, tasks, bucket_count=3)
Beispiel #5
0
    def test_many_buckets(self) -> None:
        tasks = self.build_tasks(100)
        job_id = UUID(int=1)
        for i, task in enumerate(tasks):
            if i % 2 == 0:
                task.job_id = job_id
                task.config.job_id = job_id

            if i % 3 == 0:
                task.os = OS.windows

            if i % 4 == 0:
                task.config.containers[0].name = Container("setup2")

            if i % 5 == 0:
                if task.config.pool:
                    task.config.pool.pool_name = PoolName("alternate-pool")

        buckets = bucket_tasks(tasks)
        self.check_buckets(buckets, tasks, bucket_count=12)