def test_jobs_check_heartbeat(self): job1 = JobFactory() JobStatusFactory(job=job1, status=JobLifeCycle.RUNNING) RedisHeartBeat.job_ping(job_id=job1.id) job2 = JobFactory() JobStatusFactory(job=job2, status=JobLifeCycle.RUNNING) jobs_check_heartbeat(job1.id) job1.refresh_from_db() self.assertEqual(job1.last_status, JobLifeCycle.RUNNING) jobs_check_heartbeat(job2.id) job2.refresh_from_db() self.assertEqual(job2.last_status, JobLifeCycle.FAILED)
def test_heartbeat_jobs(self): job1 = JobFactory() JobStatusFactory(job=job1, status=JobLifeCycle.SCHEDULED) job2 = JobFactory() JobStatusFactory(job=job2, status=JobLifeCycle.CREATED) job3 = JobFactory() JobStatusFactory(job=job3, status=JobLifeCycle.FAILED) job4 = JobFactory() JobStatusFactory(job=job4, status=JobLifeCycle.RUNNING) with patch('scheduler.tasks.jobs.jobs_check_heartbeat.apply_async') as mock_fct: heartbeat_jobs() assert mock_fct.call_count == 1
def _reconcile_done(self, client): JobStatusFactory(job=self.job, status='failed') with patch('k8s_events_handlers.tasks.' 'k8s_events_reconcile_job_statuses.apply_async') as mock_fct: resp = client.post(self.url, data={'status': 'succeeded'}) assert mock_fct.call_count == 0 assert resp.status_code == status.HTTP_200_OK