Exemple #1
0
 def test_main_loop_13925(
     self,
     m_setup_log_file,
     m_isdir,
     m_connect,
     m_watch_tube,
     m_fetch_teuthology,
     m_fetch_qa_suite,
     m_job,
     m_run_job,
     m_try_push_job_info,
 ):
     m_connection = Mock()
     jobs = self.build_fake_jobs(
         m_connection,
         m_job,
         [
             'name: name',
             'name: name\nstop_worker: true',
         ],
     )
     m_connection.reserve.side_effect = jobs
     m_connect.return_value = m_connection
     m_fetch_qa_suite.side_effect = [
         '/suite/path',
         MaxWhileTries(),
         MaxWhileTries(),
     ]
     worker.main(self.ctx)
     assert len(m_run_job.call_args_list) == 0
     assert len(m_try_push_job_info.call_args_list) == len(jobs)
     for i in range(len(jobs)):
         push_call = m_try_push_job_info.call_args_list[i]
         assert push_call[0][1]['status'] == 'dead'
Exemple #2
0
 def test_main_loop(
     self,
     m_setup_log_file,
     m_isdir,
     m_connect,
     m_watch_tube,
     m_fetch_teuthology,
     m_fetch_qa_suite,
     m_job,
     m_prep_job,
     m_run_job,
 ):
     m_connection = Mock()
     jobs = self.build_fake_jobs(
         m_connection,
         m_job,
         [
             'foo: bar',
             'stop_worker: true',
         ],
     )
     m_connection.reserve.side_effect = jobs
     m_connect.return_value = m_connection
     m_prep_job.return_value = (dict(), '/bin/path')
     worker.main(self.ctx)
     # There should be one reserve call per item in the jobs list
     expected_reserve_calls = [dict(timeout=60) for i in range(len(jobs))]
     got_reserve_calls = [
         call[1] for call in m_connection.reserve.call_args_list
     ]
     assert got_reserve_calls == expected_reserve_calls
     for job in jobs:
         job.bury.assert_called_once_with()
         job.delete.assert_called_once_with()