[meta]
    title = Test: run task - pause workflow - task job retry - resume workflow

[scheduler]
    [[events]]
        abort on stall timeout = True
        stall timeout = PT0S
        abort on inactivity timeout = True
        inactivity timeout = PT3M

[scheduling]
    [[graph]]
        R1 = """
            t-retry-able:start => t-pause
            t-submit-retry-able:submit => t-pause
        """

[runtime]
    [[t-pause]]
        script = """
            cylc pause "${CYLC_WORKFLOW_ID}"
            cylc__job__poll_grep_workflow_log 'Command "pause" actioned'

            # Poll t-submit-retry-able, should return submit-fail
            cylc poll "${CYLC_WORKFLOW_ID}//*/t-submit-retry-able"
            # Allow t-retry-able to continue
            rm -f "${CYLC_WORKFLOW_RUN_DIR}/file"

            cylc__job__poll_grep_workflow_log -E \
                '1/t-retry-able/01:running.* => waiting'

            cylc__job__poll_grep_workflow_log -E \
                '1/t-submit-retry-able/01:submitted.* => waiting'

            # Resume the workflow
            cylc play "${CYLC_WORKFLOW_ID}"

            cylc__job__poll_grep_workflow_log -E \
                '1/t-retry-able:waiting.* => waiting\(queued\)'

            cylc__job__poll_grep_workflow_log -E \
                '1/t-submit-retry-able:waiting.* => waiting\(queued\)'
        """
    [[t-retry-able]]
        script = """
            if ((CYLC_TASK_SUBMIT_NUMBER == 1)); then
                touch "${CYLC_WORKFLOW_RUN_DIR}/file"
                while [[ -e "${CYLC_WORKFLOW_RUN_DIR}/file" ]]; do
                    sleep 1
                done
                false
            fi
        """
        execution retry delays = PT5S
    [[t-submit-retry-able]]
        init-script = """
            if [[ "${CYLC_TASK_JOB}" == *"/01" ]]; then
                cylc__job__disable_fail_signals ERR EXIT
                exit 1
            fi
        """
        script = true
        submission retry delays = PT5S
