예제 #1
0
 def test_run_job_with_watchdog(self, m_tempfile, m_safe_dump, m_mkdir,
                                m_environ, m_popen, m_t_config,
                                m_run_watchdog):
     config = {
         "suite_path": "suite/path",
         "config": {
             "foo": "bar"
         },
         "verbose": True,
         "owner": "the_owner",
         "archive_path": "archive/path",
         "name": "the_name",
         "description": "the_description",
         "job_id": "1",
     }
     m_tmp = MagicMock()
     temp_file = Mock()
     temp_file.name = "the_name"
     m_tmp.__enter__.return_value = temp_file
     m_tempfile.return_value = m_tmp
     env = dict(PYTHONPATH="python/path")
     m_environ.copy.return_value = env
     m_p = Mock()
     m_p.returncode = 0
     m_popen.return_value = m_p
     m_t_config.results_server = True
     worker.run_job(config, "teuth/bin/path", "archive/dir", verbose=False)
     m_run_watchdog.assert_called_with(m_p, config)
     expected_args = [
         'teuth/bin/path/teuthology', '-v', '--lock', '--block', '--owner',
         'the_owner', '--archive', 'archive/path', '--name', 'the_name',
         '--description', 'the_description', '--', "the_name"
     ]
     m_popen.assert_called_with(args=expected_args, env=env)
예제 #2
0
 def test_run_job_no_watchdog(self, m_tempfile, m_safe_dump, m_mkdir,
                              m_environ, m_popen, m_t_config, m_symlink_log,
                              m_sleep):
     config = {
         "suite_path": "suite/path",
         "config": {
             "foo": "bar"
         },
         "verbose": True,
         "owner": "the_owner",
         "archive_path": "archive/path",
         "name": "the_name",
         "description": "the_description",
         "worker_log": "worker/log.log",
         "job_id": "1",
     }
     m_tmp = MagicMock()
     temp_file = Mock()
     temp_file.name = "the_name"
     m_tmp.__enter__.return_value = temp_file
     m_tempfile.return_value = m_tmp
     env = dict(PYTHONPATH="python/path")
     m_environ.copy.return_value = env
     m_p = Mock()
     m_p.returncode = 1
     m_popen.return_value = m_p
     m_t_config.results_server = False
     worker.run_job(config, "teuth/bin/path", "archive/dir", verbose=False)
     m_symlink_log.assert_called_with(config["worker_log"],
                                      config["archive_path"])