@patch("os.path.exists")
def test_restart_file_path_doesnt_exist(self, m_exists):
m_exists.return_value = False
- result = worker.need_restart()
+ result = worker.sentinel(worker.restart_file_path)
assert not result
@patch("os.path.getmtime")
def test_needs_restart(self, m_datetime, m_exists, m_getmtime):
m_exists.return_value = True
m_datetime.utcfromtimestamp.return_value = datetime.utcnow() + timedelta(days=1)
- result = worker.need_restart()
+ result = worker.sentinel(worker.restart_file_path)
assert result
@patch("os.path.getmtime")
def test_does_not_need_restart(self, m_datetime, m_exists, getmtime):
m_exists.return_value = True
m_datetime.utcfromtimestamp.return_value = datetime.utcnow() - timedelta(days=1)
- result = worker.need_restart()
+ result = worker.sentinel(worker.restart_file_path)
assert not result
@patch("os.symlink")
restart_file_path = '/tmp/teuthology-restart-workers'
-def need_restart():
+def sentinel(path):
if not os.path.exists(restart_file_path):
return False
- file_mtime = datetime.utcfromtimestamp(os.path.getmtime(restart_file_path))
+ file_mtime = datetime.utcfromtimestamp(os.path.getmtime(path))
if file_mtime > start_time:
return True
else:
result_proc.returncode)
result_proc = None
- if need_restart():
+ if sentinel(restart_file_path):
restart()
job = connection.reserve(timeout=60)