def test_worker_has_resources(queue): job = queue.enqueue(core4.queue.helper.job.example.DummyJob) worker = WorkerNoCPU(name="testRes") worker.at = core4.util.node.now() worker.start_job(job.serialise()) while queue.config.sys.queue.count_documents({}) > 0: time.sleep(1) data = list(queue.config.sys.log.find()) assert sum([1 for d in data if "start execution" in d["message"]]) == 1
def test_start_job(): queue = core4.queue.main.CoreQueue() worker = core4.queue.worker.CoreWorker() worker.cleanup() job = queue.enqueue(core4.queue.helper.job.example.DummyJob) assert job.identifier == job._id assert job._id is not None assert job.wall_time is None worker.at = core4.util.node.now() worker.start_job(job.serialise()) while queue.config.sys.queue.count_documents({}) > 0: time.sleep(0.5) assert queue.config.sys.queue.count_documents({}) == 0 assert queue.config.sys.journal.count_documents({}) == 1 job = queue.find_job(job._id) assert job.state == "complete" print(job.started_at) print(job.finished_at) print(job.finished_at - job.started_at) print(job.runtime)