|
29 | 29 | from cylc.flow.scheduler import Scheduler |
30 | 30 | from cylc.flow.task_events_mgr import ( |
31 | 31 | EventKey, |
| 32 | + TaskEventsManager, |
32 | 33 | TaskJobLogsRetrieveContext, |
33 | 34 | ) |
| 35 | +from cylc.flow.task_outputs import TASK_OUTPUT_STARTED |
34 | 36 | from cylc.flow.task_state import ( |
35 | 37 | TASK_STATUS_PREPARING, |
36 | 38 | TASK_STATUS_SUBMIT_FAILED, |
| 39 | + TASK_STATUS_SUCCEEDED, |
37 | 40 | ) |
38 | 41 |
|
39 | 42 | from cylc.flow.network.resolvers import TaskMsg |
@@ -368,3 +371,42 @@ async def test_event_email_body( |
368 | 371 | assert f'host: {mod_one.host}' in email_body |
369 | 372 | assert f'port: {mod_one.server.port}' in email_body |
370 | 373 | assert f'owner: {mod_one.owner}' in email_body |
| 374 | + |
| 375 | + |
| 376 | +@pytest.mark.parametrize( |
| 377 | + 'message_flag', |
| 378 | + ( |
| 379 | + TaskEventsManager.FLAG_POLLED, |
| 380 | + TaskEventsManager.FLAG_INTERNAL, |
| 381 | + TaskEventsManager.FLAG_RECEIVED, |
| 382 | + ), |
| 383 | +) |
| 384 | +async def test_delayed_event_notification( |
| 385 | + message_flag, |
| 386 | + one_conf, |
| 387 | + flow, |
| 388 | + scheduler, |
| 389 | + run, |
| 390 | + complete, |
| 391 | +): |
| 392 | + """Delated event notification should not cause task state to rewind. |
| 393 | +
|
| 394 | + One a task reaches a state, it should not be possible for that state to |
| 395 | + re-wind as the result of a subsequent event. |
| 396 | +
|
| 397 | + In this test, a task succeeds naturally, a "started" event is then sent |
| 398 | + using one of the configured flags. The task state should not re-wind as a |
| 399 | + result. |
| 400 | +
|
| 401 | + See https://github.com/cylc/cylc-flow/issues/7269 |
| 402 | + """ |
| 403 | + id_ = flow(one_conf) |
| 404 | + schd = scheduler(id_, paused_start=False) |
| 405 | + async with run(schd): |
| 406 | + itask = schd.pool.get_tasks()[0] |
| 407 | + await complete(schd, itask.tokens.relative_id) |
| 408 | + assert itask.state.status == TASK_STATUS_SUCCEEDED |
| 409 | + schd.task_events_mgr.process_message( |
| 410 | + itask, 'INFO', TASK_OUTPUT_STARTED, flag=message_flag |
| 411 | + ) |
| 412 | + assert itask.state.status == TASK_STATUS_SUCCEEDED |
0 commit comments