Skip to content

Commit de7a921

Browse files
committed
Extend integration tests.
1 parent 7328b7c commit de7a921

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tests/integration/test_job_runner_mgr.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from cylc.flow.pathutil import get_workflow_run_job_dir
2525
from cylc.flow.task_state import TASK_STATUS_RUNNING
2626
from cylc.flow.subprocctx import SubProcContext
27+
from cylc.flow.task_job_logs import JOB_LOG_OUT, JOB_LOG_ERR
2728

2829

2930
async def test_kill_error(one, start, test_dir, capsys, log_filter):
@@ -82,3 +83,59 @@ async def test_kill_error(one, start, test_dir, capsys, log_filter):
8283
level=logging.WARNING,
8384
)
8485
assert itask.state(TASK_STATUS_RUNNING)
86+
87+
88+
async def test_create_nn_new(one, start, test_dir, capsys, log_filter):
89+
"""Test _create_nn.
90+
91+
It should the NN symlink.
92+
"""
93+
async with start(one):
94+
# make it look like the task is running
95+
itask = one.pool.get_tasks()[0]
96+
97+
workflow_job_log_dir = Path(get_workflow_run_job_dir(one.workflow))
98+
job_id = itask.tokens.duplicate(job='01').relative_id
99+
job_log_dir = Path(workflow_job_log_dir, job_id)
100+
job_log_dir.mkdir(parents=True)
101+
102+
# call _create_nn
103+
JobRunnerManager()._create_nn(job_log_dir / 'job.out')
104+
105+
# check the symlink exists
106+
assert (job_log_dir.parent / "NN").is_symlink()
107+
108+
109+
async def test_create_nn_old(one, start, test_dir, capsys, log_filter):
110+
"""Test _create_nn.
111+
112+
It should remove existing job logs, if the dir already exists.
113+
"""
114+
async with start(one):
115+
itask = one.pool.get_tasks()[0]
116+
117+
# fake some old job logs
118+
workflow_job_log_dir = Path(get_workflow_run_job_dir(one.workflow))
119+
job_id = itask.tokens.duplicate(job='01').relative_id
120+
job_log_dir = Path(workflow_job_log_dir, job_id)
121+
job_log_dir.mkdir(parents=True)
122+
123+
job_logs = []
124+
for name in JOB_LOG_OUT, JOB_LOG_ERR:
125+
job_logs.append(job_log_dir / name)
126+
127+
# create the logs
128+
for job_log in job_logs:
129+
job_log.touch()
130+
131+
# check they exist
132+
for job_log in job_logs:
133+
assert job_log.is_file()
134+
135+
# call _create_nn
136+
for job_log in job_logs:
137+
JobRunnerManager()._create_nn(job_log)
138+
139+
# check they were removed
140+
for job_log in job_logs:
141+
assert not job_log.is_file()

0 commit comments

Comments
 (0)