Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify integration test #60

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 13 additions & 40 deletions tests/integration/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from cylc.flow import commands
from cylc.flow.exceptions import CylcError
from cylc.flow.flow_mgr import FLOW_ALL
from cylc.flow.parsec.exceptions import ParsecError
from cylc.flow.scheduler import Scheduler, SchedulerStop
from cylc.flow.task_state import (
Expand Down Expand Up @@ -331,9 +332,10 @@ async def test_restart_timeout(
flow,
one_conf,
scheduler,
start,
run,
log_filter
log_filter,
complete,
capture_submission,
):
"""It should wait for user input if there are no tasks in the pool.

Expand All @@ -346,60 +348,31 @@ async def test_restart_timeout(

See: https://github.com/cylc/cylc-flow/issues/5078
"""
one_conf.update(
{
'runtime': {
'one': {
'simulation': {
'default run length': 'PT5S'
}
}
}
}
)
id_ = flow(one_conf)

# run the workflow to completion
# (by setting the only task to completed)
schd = scheduler(id_, paused_start=False)
async with start(schd) as log:
for itask in schd.pool.get_tasks():
# (needed for job config in sim mode:)
schd.task_job_mgr.submit_task_jobs(
schd.workflow, [itask], None, None)
schd.pool.set_prereqs_and_outputs(
[itask.identity], None, None, ['all'])
schd: Scheduler = scheduler(id_, paused_start=False)
async with run(schd):
await complete(schd)

# restart the completed workflow
schd = scheduler(id_, paused_start=False)
async with run(schd) as log:
# allow start-up process to complete?
# without this we get KeyError from platform['install target']
await asyncio.sleep(0)

async with run(schd):
# it should detect that the workflow has completed and alert the user
assert log_filter(
logging.WARNING,
contains='This workflow already ran to completion.'
)

# it should activate a timeout
assert log_filter(
logging.WARNING,
contains='restart timer starts NOW'
)
assert log_filter(logging.WARNING, contains='restart timer starts NOW')

capture_submission(schd)
# when we trigger tasks the timeout should be cleared
schd.pool.force_trigger_tasks(['1/one'], {1})
schd.release_tasks_to_run()
schd.pool.force_trigger_tasks(['1/one'], [FLOW_ALL])

# wait for log to update
await asyncio.sleep(3)

assert log_filter(
logging.INFO,
contains='restart timer stopped'
)
await asyncio.sleep(0) # yield control to the main loop
assert log_filter(logging.INFO, contains='restart timer stopped')


@pytest.mark.parametrize("signal", ((SIGHUP), (SIGINT), (SIGTERM)))
Expand Down
Loading