def setup_job(self): self.scheduler = scheduler.ConstantScheduler() mock_graph = mock.Mock(autospec=True) mock_graph.get_action_map.return_value = {} mock_graph.action_map = {} self.job = mock.Mock(autospec=True) self.job.allow_overlap = False self.job.max_runtime = datetime.timedelta(days=1) self.job_scheduler = JobScheduler(job=self.job)
def build_job(self): self.test_dir = tempfile.mkdtemp() self.action = action.Action(name="Test Action") self.action.command = "Test Action Command" self.job = job.Job("Test Job", self.action) self.job.node_pool = node.NodePool("host") self.job.output_dir = self.test_dir self.action.job = self.job self.job.scheduler = scheduler.ConstantScheduler()
def build_scheduler(self): self.test_dir = tempfile.mkdtemp() self.scheduler = scheduler.ConstantScheduler() self.action = action.Action("Test Action") self.action.command = "Test Command" self.job = job.Job("Test Job", self.action) self.job.node_pool = turtle.Turtle() self.job.output_dir = self.test_dir self.job.scheduler = self.scheduler self.action.job = self.job
def test_next_run(self): assert_equals(self.job.next_runs(), []) self.action.scheduler = turtle.Turtle() self.action.scheduler.next_run = lambda j:None assert_equals(self.job.next_runs(), []) assert_equals(get_num_runs_by_state(self.job, action.ACTION_RUN_SCHEDULED), 0) self.job.scheduler = scheduler.ConstantScheduler() assert self.job.next_runs()[0] assert_equals(get_num_runs_by_state(self.job, action.ACTION_RUN_SCHEDULED), 1)
def build_scheduler(self): self.scheduler = scheduler.ConstantScheduler()