| 1 |
[meta] |
| 2 |
title = "test workflow for broadcast functionality" |
| 3 |
description = """ |
| 4 |
The first task broadcasts an environment variable "BCAST" to various |
| 5 |
cycles and namespaces. Then each task writes its point, name, and value |
| 6 |
of BCAST to a log for comparison with the expected result. |
| 7 |
""" |
| 8 |
|
| 9 |
[scheduler] |
| 10 |
cycle point format = %Y%m%dT%H |
| 11 |
allow implicit tasks = True |
| 12 |
|
| 13 |
[scheduling] |
| 14 |
initial cycle point = 20100808T00 |
| 15 |
final cycle point = 20100809T00 |
| 16 |
# Ensure the first cycle finishes before the second (last) one, so that the |
| 17 |
# broadcast to foo in the first cycle expires before shutdown: |
| 18 |
runahead limit = P0 |
| 19 |
[[graph]] |
| 20 |
R1 = "prep => check & foo" |
| 21 |
T00 = """ |
| 22 |
foo => bar & baz & qux & wibble => ENS? |
| 23 |
ENS:finish-all => wobble |
| 24 |
""" |
| 25 |
|
| 26 |
[runtime] |
| 27 |
[[root]] |
| 28 |
pre-script = "echo $CYLC_TASK_CYCLE_POINT $CYLC_TASK_NAME BCAST is $BCAST | tee -a $BCASTLOG" |
| 29 |
script = "true" # no sleep |
| 30 |
[[[environment]]] |
| 31 |
BCAST = ${BCAST:-(not set)} |
| 32 |
BCASTLOG = ${CYLC_WORKFLOW_SHARE_DIR}/broadcast.log |
| 33 |
PREPLOG = ${CYLC_WORKFLOW_SHARE_DIR}/prep |
| 34 |
[[prep]] |
| 35 |
pre-script = "rm -f $BCASTLOG $PREPLOG" |
| 36 |
script = """ |
| 37 |
set +x |
| 38 |
{ |
| 39 |
# broadcast to all cycles and namespaces: |
| 40 |
cylc broadcast -s "[environment]BCAST = ROOT" $CYLC_WORKFLOW_ID |
| 41 |
# broadcast to 20100808T00/foo: |
| 42 |
cylc broadcast -p 20100808T00 -n foo -s "[environment]BCAST = FOO" $CYLC_WORKFLOW_ID |
| 43 |
# broadcast to bar at all cycles: |
| 44 |
cylc broadcast -n bar -s "[environment]BCAST = BAR" $CYLC_WORKFLOW_ID |
| 45 |
# broadcast to baz at 20100809T00: |
| 46 |
cylc broadcast -n baz -p 20100809T00 -s "[environment]BCAST = BAZ" $CYLC_WORKFLOW_ID |
| 47 |
# broadcast to qux at 20100809T00, then cancel it: |
| 48 |
cylc broadcast -n qux -p 20100809T00 -s "[environment]BCAST = QUX" $CYLC_WORKFLOW_ID |
| 49 |
cylc broadcast -n qux -p 20100809T00 --cancel "[environment]BCAST" $CYLC_WORKFLOW_ID |
| 50 |
# broadcast to wibble at all cycles, then clear it: |
| 51 |
cylc broadcast -n wibble -s "[environment]BCAST = WIBBLE" $CYLC_WORKFLOW_ID |
| 52 |
cylc broadcast -n wibble --clear $CYLC_WORKFLOW_ID |
| 53 |
# broadcast to all members of ENS, all cycles: |
| 54 |
cylc broadcast -n ENS -s "[environment]BCAST = ENS" $CYLC_WORKFLOW_ID |
| 55 |
# broadcast to all members of ENS1, all cycles: |
| 56 |
cylc broadcast -n ENS1 -s "[environment]BCAST = ENS1" $CYLC_WORKFLOW_ID |
| 57 |
# broadcast to a single member m2 of ENS1, in 20100809T00: |
| 58 |
cylc broadcast -n m2 -p 20100809T00 -s "[environment]BCAST = M2" $CYLC_WORKFLOW_ID |
| 59 |
# cancel broadcast to m4 of ENS1, in 20100809T00 (will not work): |
| 60 |
! cylc broadcast -n m4 -p 20100809T00 --cancel "[environment]BCAST" $CYLC_WORKFLOW_ID |
| 61 |
# cancel broadcast to m5 of ENS1 at all cycles (will not work): |
| 62 |
! cylc broadcast -n m5 --cancel "[environment]BCAST" $CYLC_WORKFLOW_ID |
| 63 |
# clear broadcast to m6 of ENS1 at all cycles (will not work): |
| 64 |
! cylc broadcast -n m6 --clear $CYLC_WORKFLOW_ID |
| 65 |
# clear, then reset, broadcast to m7 of ENS1 at all cycles: |
| 66 |
! cylc broadcast -n m7 --clear $CYLC_WORKFLOW_ID |
| 67 |
cylc broadcast -n m7 -s "[environment]BCAST = M7" $CYLC_WORKFLOW_ID |
| 68 |
# reset broadcast to m8 of ENS1 at 20100809T00 |
| 69 |
cylc broadcast -n m8 -s "[environment]BCAST = M8" $CYLC_WORKFLOW_ID |
| 70 |
# reset broadcast to m9 of ENS1 at all cycles |
| 71 |
cylc broadcast -n m9 -s "[environment]BCAST = M9" $CYLC_WORKFLOW_ID |
| 72 |
# clear broadcast for ENS3 (will not work): |
| 73 |
! cylc broadcast -n ENS3 --clear $CYLC_WORKFLOW_ID |
| 74 |
} 1>${PREPLOG}.out 2>${PREPLOG}.err |
| 75 |
""" |
| 76 |
[[check]] |
| 77 |
# Check that the broadcasts performed by the previous task were |
| 78 |
# recorded properly by the scheduler (doing this in another task |
| 79 |
# gives time for the datastore to update broadcast data). |
| 80 |
script = """ |
| 81 |
# list the result to prep task stdout: |
| 82 |
cylc broadcast --display $CYLC_WORKFLOW_ID \ |
| 83 |
1>>${PREPLOG}.out 2>>${PREPLOG}.err |
| 84 |
set -x |
| 85 |
sed -i '/DEBUG -/d' ${PREPLOG}.out |
| 86 |
sed -i '/\(DEBUG\|WARNING\|ERROR\) -/d' ${PREPLOG}.err |
| 87 |
|
| 88 |
# workaround for platforms affected by https://github.com/cylc/cylc-flow/issues/3585 |
| 89 |
sed -i '/BASH_XTRACEFD/d' ${PREPLOG}.err |
| 90 |
|
| 91 |
diff -u "${CYLC_WORKFLOW_RUN_DIR}/expected-prep.out" ${PREPLOG}.out |
| 92 |
diff -u "${CYLC_WORKFLOW_RUN_DIR}/expected-prep.err" ${PREPLOG}.err |
| 93 |
""" |
| 94 |
[[ENS]] |
| 95 |
[[ENS1]] |
| 96 |
inherit = ENS |
| 97 |
[[m1,m2,m3,m4,m5,m6,m7,m8,m9]] |
| 98 |
inherit = ENS1 |
| 99 |
[[ENS2]] |
| 100 |
inherit = ENS |
| 101 |
[[n1]] |
| 102 |
inherit = ENS2 |
| 103 |
[[ENS3]] |
| 104 |
inherit = ENS |
| 105 |
[[o1]] |
| 106 |
inherit = ENS3 |
| 107 |
[[wobble]] |
| 108 |
script = """ |
| 109 |
if [[ "${CYLC_TASK_CYCLE_POINT}" == "20100809T00" ]]; then |
| 110 |
sleep 5 |
| 111 |
fi |
| 112 |
""" |