def test_submit_status(self): env = get_environment() sched = env.scheduler_type() sched.reset() project = self.mock_project() for job in project: list(project.classify(job)) self.assertEqual(project.next_operation(job).name, 'a_op') self.assertEqual(project.next_operation(job).job, job) with suspend_logging(): with redirect_stdout(StringIO()): project.submit(env) self.assertEqual(len(list(sched.jobs())), len(project)) for job in project: self.assertEqual( project.next_operation(job).get_status(), JobStatus.submitted) sched.step() sched.step() project._fetch_scheduler_status(file=StringIO()) for job in project: self.assertEqual( project.next_operation(job).get_status(), JobStatus.queued)
def test_run_operations_implicit_argument(self): project = self.mock_project() for job in project: ops = project.next_operations(job) with suspend_logging(): with redirect_stderr(StringIO()): project.run(ops) for job in project: self.assertIn('said_hello', list(project.labels(job)))
def test_submit(self): env = get_environment() sched = env.scheduler_type() sched.reset() project = self.mock_project() self.assertEqual(len(list(sched.jobs())), 0) with suspend_logging(): with redirect_stdout(StringIO()): project.submit(env) self.assertEqual(len(list(sched.jobs())), len(project)) sched.reset()
def test_single_submit(self): env = get_environment() env.scheduler_type.reset() self.assertTrue(issubclass(env, MockEnvironment)) sscript = env.script() with suspend_logging(): with redirect_stdout(StringIO()): env.submit(sscript, _id='test') scheduler = env.get_scheduler() self.assertEqual(len(list(scheduler.jobs())), 1) for job in scheduler.jobs(): self.assertEqual(job.status(), JobStatus.submitted)
def test_resubmit(self): env = get_environment() sched = env.scheduler_type() sched.reset() project = self.mock_project() self.assertEqual(len(list(sched.jobs())), 0) with suspend_logging(): with redirect_stdout(StringIO()): project.submit(env) for i in range(5): # push all jobs through the queue self.assertEqual(len(list(sched.jobs())), len(project)) project.submit(env) sched.step() self.assertEqual(len(list(sched.jobs())), 0)
def test_bundles(self): env = get_environment() sched = env.scheduler_type() sched.reset() project = self.mock_project() self.assertEqual(len(list(sched.jobs())), 0) with suspend_logging(): with redirect_stderr(StringIO()): project.submit(bundle_size=2, num=2) self.assertEqual(len(list(sched.jobs())), 1) project.submit(bundle_size=2, num=4) self.assertEqual(len(list(sched.jobs())), 3) sched.reset() project._fetch_scheduler_status(file=StringIO()) project.submit(bundle_size=0) self.assertEqual(len(list(sched.jobs())), 1)
def test_submit_operations(self): env = get_environment() sched = env.scheduler_type() sched.reset() project = self.mock_project() operations = [] for job in project: operations.extend(project.next_operations(job)) self.assertEqual(len(list(sched.jobs())), 0) cluster_job_id = project._store_bundled(operations) with suspend_logging(): with redirect_stderr(StringIO()): project.submit_operations(_id=cluster_job_id, env=env, operations=operations) self.assertEqual(len(list(sched.jobs())), 1) sched.reset()