| 1 |
#!/bin/bash |
| 2 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 3 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
set -euxo pipefail |
| 19 |
|
| 20 |
test_one () { |
| 21 |
ID="$(< /dev/urandom tr -dc A-Za-z | head -c6 || true)" |
| 22 |
|
| 23 |
# start the workflow |
| 24 |
cylc vip \ |
| 25 |
--check-circular \ |
| 26 |
--no-detach \ |
| 27 |
--final-cycle-point=P0D \ |
| 28 |
--no-run-name \ |
| 29 |
--workflow-name "$ID" \ |
| 30 |
./one |
| 31 |
|
| 32 |
# the start task should have expired |
| 33 |
grep 'start.*(internal)expired' "$HOME/cylc-run/$ID/log/scheduler/log" |
| 34 |
|
| 35 |
# the following task(s) should not have run |
| 36 |
grep 'a.*running' "$HOME/cylc-run/$ID/log/scheduler/log" && exit 1 |
| 37 |
grep 'b.*running' "$HOME/cylc-run/$ID/log/scheduler/log" && exit 1 |
| 38 |
|
| 39 |
# lint |
| 40 |
cylc lint "$ID" |
| 41 |
|
| 42 |
# clean up |
| 43 |
cylc clean "$ID" |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
test_two () { |
| 48 |
ID="$(< /dev/urandom tr -dc A-Za-z | head -c6 || true)" |
| 49 |
|
| 50 |
# start the workflow |
| 51 |
cylc vip \ |
| 52 |
--check-circular \ |
| 53 |
--no-detach \ |
| 54 |
--final-cycle-point=P0D \ |
| 55 |
--no-run-name \ |
| 56 |
--workflow-name "$ID" \ |
| 57 |
./two |
| 58 |
|
| 59 |
# the start task should run |
| 60 |
grep 'start.*running' "$HOME/cylc-run/$ID/log/scheduler/log" |
| 61 |
|
| 62 |
# some other task in the chain should expire |
| 63 |
grep '(internal)expired' "$HOME/cylc-run/$ID/log/scheduler/log" |
| 64 |
|
| 65 |
# the housekeep task at the end of the cycle should not run |
| 66 |
grep 'housekeep.*running' "$HOME/cylc-run/$ID/log/scheduler/log" && exit 1 |
| 67 |
|
| 68 |
# lint |
| 69 |
cylc lint "$ID" |
| 70 |
|
| 71 |
# clean up |
| 72 |
cylc clean "$ID" |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
test_three () { |
| 77 |
ID="$(< /dev/urandom tr -dc A-Za-z | head -c6 || true)" |
| 78 |
|
| 79 |
# start the workflow |
| 80 |
cylc vip \ |
| 81 |
--check-circular \ |
| 82 |
--no-detach \ |
| 83 |
--final-cycle-point=P0D \ |
| 84 |
--no-run-name \ |
| 85 |
--workflow-name "$ID" \ |
| 86 |
./three |
| 87 |
|
| 88 |
# the start task should expire |
| 89 |
grep 'start.*(internal)expired' "$HOME/cylc-run/$ID/log/scheduler/log" |
| 90 |
# shellcheck disable=SC2125 # could only ever be one matching file |
| 91 |
local job_file="$HOME/cylc-run/$ID/log/job/"*"/a/NN/job" |
| 92 |
[[ ! -f "$job_file" ]] |
| 93 |
|
| 94 |
# only the "a" and "housekeep" tasks should run |
| 95 |
[[ $(cd "$HOME/cylc-run/$ID/log/job/"*; echo *) == 'a housekeep' ]] |
| 96 |
|
| 97 |
# tasks b, c and d should skip |
| 98 |
grep '\/b.*run mode=skip' "$HOME/cylc-run/$ID/log/scheduler/log" |
| 99 |
grep '\/c.*run mode=skip' "$HOME/cylc-run/$ID/log/scheduler/log" |
| 100 |
grep '\/d.*run mode=skip' "$HOME/cylc-run/$ID/log/scheduler/log" |
| 101 |
|
| 102 |
# lint |
| 103 |
cylc lint "$ID" |
| 104 |
|
| 105 |
# clean up |
| 106 |
cylc clean "$ID" |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
test_one |
| 111 |
test_two |
| 112 |
test_three |