publik-dump: raise when cron are desactivated on source node
This commit is contained in:
parent
1e221eb962
commit
5aaf174412
|
@ -39,6 +39,10 @@ class PublikDump():
|
|||
tenant_infos = json.loads(line)
|
||||
tenants.append(tenant_infos)
|
||||
|
||||
if tenants == []:
|
||||
if os.path.isfile(host_path):
|
||||
os.remove(host_path)
|
||||
raise(Exception('DISABLE_CRON_JOBS is set on this node'))
|
||||
json.dump(tenants, open(host_path, "w"), indent=4)
|
||||
return tenants
|
||||
|
||||
|
|
|
@ -167,8 +167,10 @@ def get_config_pck():
|
|||
return desc.read()
|
||||
|
||||
|
||||
@mock.patch('publik_dump.publik_dump.subprocess.run', return_value=MockedCompletedProcess(get_list_tenants()))
|
||||
@mock.patch('publik_dump.publik_dump.subprocess.run')
|
||||
def test_get_host_info(mocked_run, publik_dump):
|
||||
mocked_run.return_value=MockedCompletedProcess(get_list_tenants())
|
||||
|
||||
tenants = publik_dump.get_host_info()
|
||||
assert len(mocked_run.mock_calls) == 2
|
||||
assert mocked_run.mock_calls[0][1][0] == \
|
||||
|
@ -177,6 +179,7 @@ def test_get_host_info(mocked_run, publik_dump):
|
|||
"ssh hobo.node2.test.saas.entrouvert.org"\
|
||||
" 'sudo -u hobo HOME=$HOME hobo-manage tenant_command runscript ~/list_tenants.py --all-tenants'"
|
||||
assert tenants[0] == HOST_INFO_0
|
||||
assert os.path.isfile("%s/data" % publik_dump.host_folder)
|
||||
|
||||
# result from cache
|
||||
tenants = publik_dump.get_host_info()
|
||||
|
@ -189,6 +192,12 @@ def test_get_host_info(mocked_run, publik_dump):
|
|||
assert len(mocked_run.mock_calls) == 4
|
||||
assert tenants[0] == HOST_INFO_0
|
||||
|
||||
# cron disabled error
|
||||
mocked_run.return_value=MockedCompletedProcess(b'')
|
||||
with pytest.raises(Exception, match=r'DISABLE_CRON_JOBS is set on this node'):
|
||||
tenants = publik_dump.get_host_info()
|
||||
assert not os.path.isfile("%s/data" % publik_dump.host_folder)
|
||||
|
||||
|
||||
def test_parse_service(publik_dump):
|
||||
# hobo
|
||||
|
|
Loading…
Reference in New Issue