def test_estimate_schedule(plan1): netmodel = SimpleNetModel(1) workers = [SchedulerWorker(i, cpus=4) for i in range(4)] tg = create_scheduler_graph(plan1) tasks = tg.tasks.values() schedule = [TaskAssignment(w, t) for (w, t) in zip(itertools.cycle(workers), tasks)] assert estimate_schedule(schedule, netmodel) == 16
def test_worker_estimate_earliest_time_offset_now(): now = 0 tg = TaskGraph() t0 = tg.new_task(expected_duration=3, cpus=1) t1 = tg.new_task(expected_duration=5, cpus=1) t2 = tg.new_task(expected_duration=3, cpus=2) tg = create_scheduler_graph(tg) tg.tasks[t0.id].start_time = now tg.tasks[t1.id].start_time = now worker = SchedulerWorker(0, cpus=2) worker.scheduled_tasks = [] worker.running_tasks.update((tg.tasks[t0.id], tg.tasks[t1.id])) assert worker_estimate_earliest_time(worker, tg.tasks[t2.id], now + 2) == 3