[meta]
    title = Test task retry - hold - release

[scheduling]
    [[graph]]
            R1 = """
t-retry-able:submit => t-hold-release
t-retry-able => t-analyse
"""

[runtime]
    [[t-retry-able]]
        # Note under bash 4.2 failed bare arithmetic tests such as
        # "(( VAR >= 3 ))" do not cause an abort under 'set -e'.
        script = test "${CYLC_TASK_TRY_NUMBER}" -ge 3
        [[[job]]]
            execution retry delays = PT15S, 2*PT1S
    [[t-hold-release]]
        script = """
            cylc__job__poll_grep_workflow_log -E \
                '\[1/t-retry-able:waiting\] - retrying'

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

            cylc__job__poll_grep_workflow_log -E \
                '1/t-retry-able:waiting.* retrying in PT15S'

            cylc hold "${CYLC_WORKFLOW_ID}//1/t-retry-able"

            cylc__job__poll_grep_workflow_log -E \
                '1/t-retry-able:waiting.* => waiting\(held\)'
 
            cylc release "${CYLC_WORKFLOW_ID}//1/t-retry-able"

            cylc__job__poll_grep_workflow_log -E \
                '1/t-retry-able:waiting\(held\).* => waiting'
 
            cylc__job__poll_grep_workflow_log -E \
                '1/t-retry-able:waiting.* => waiting\(queued\)'
        """
    [[t-analyse]]
        script = """
test "$(readlink "$(dirname "$0")/../../t-retry-able/NN")" = '03'
"""
