Debian Codegraph @

tests/f/remote/04-symlink-dirs.t

raw
1 #!/usr/bin/env 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 # Checks configured symlinks are created for run, work, share, share/cycle, log
19 # # directories on localhost and the remote platform.
20 export REQUIRE_PLATFORM='loc:remote comms:tcp fs:indep'
21 . "$(dirname "$0")/test_header"
22
23 if [[ -z ${TMPDIR:-} || -z ${USER:-} || $TMPDIR/$USER == "$HOME" ]]; then
24 skip_all '"TMPDIR" or "USER" not defined or "TMPDIR"/"USER" is "HOME"'
25 fi
26
27 set_test_number 14
28
29 create_test_global_config "" "
30 [install]
31 [[symlink dirs]]
32 [[[localhost]]]
33 run = \$TMPDIR/\$USER/cylctb_tmp_run_dir
34 share = \$TMPDIR/\$USER
35 log = \$TMPDIR/\$USER
36 log/job = \$TMPDIR/\$USER/cylctb_tmp_log_job_dir
37 share/cycle = \$TMPDIR/\$USER/cylctb_tmp_share_dir
38 work = \$TMPDIR/\$USER
39 [[[$CYLC_TEST_INSTALL_TARGET]]]
40 run = \$TMPDIR/\$USER/test_cylc_symlink/ctb_tmp_run_dir
41 share = \$TMPDIR/\$USER/test_cylc_symlink/
42 log = \$TMPDIR/\$USER/test_cylc_symlink/
43 log/job = \$TMPDIR/\$USER/cylctb_tmp_log_job_dir
44 share/cycle = \$TMPDIR/\$USER/test_cylc_symlink/ctb_tmp_share_dir
45 work = \$TMPDIR/\$USER/test_cylc_symlink/
46 "
47
48 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
49
50 run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" \
51 -s "CYLC_TEST_PLATFORM='${CYLC_TEST_PLATFORM}'"
52 workflow_run_ok "${TEST_NAME_BASE}-run-ok" cylc play "${WORKFLOW_NAME}" \
53 -s "CYLC_TEST_PLATFORM='${CYLC_TEST_PLATFORM}'" --debug
54 poll_grep_workflow_log 'remote file install complete'
55 TEST_SYM="${TEST_NAME_BASE}-run-symlink-exists-ok"
56 if [[ $(readlink "$HOME/cylc-run/${WORKFLOW_NAME}") == \
57 "$TMPDIR/$USER/cylctb_tmp_run_dir/cylc-run/${WORKFLOW_NAME}" ]]; then
58 ok "$TEST_SYM.localhost"
59 else
60 fail "$TEST_SYM.localhost"
61 fi
62
63 TEST_SYM="${TEST_NAME_BASE}-share/cycle-symlink-exists-ok"
64 if [[ $(readlink "$HOME/cylc-run/${WORKFLOW_NAME}/share/cycle") == \
65 "$TMPDIR/$USER/cylctb_tmp_share_dir/cylc-run/${WORKFLOW_NAME}/share/cycle" ]]; then
66 ok "$TEST_SYM.localhost"
67 else
68 fail "$TEST_SYM.localhost"
69 fi
70
71 TEST_SYM="${TEST_NAME_BASE}-log/job-symlink-exists-ok"
72 if [[ $(readlink "$HOME/cylc-run/${WORKFLOW_NAME}/log/job") == \
73 "$TMPDIR/$USER/cylctb_tmp_log_job_dir/cylc-run/${WORKFLOW_NAME}/log/job" ]]; then
74 ok "$TEST_SYM.localhost"
75 else
76 fail "$TEST_SYM.localhost"
77 fi
78
79 for DIR in 'work' 'share' 'log'; do
80 TEST_SYM="${TEST_NAME_BASE}-${DIR}-symlink-exists-ok"
81 if [[ $(readlink "$HOME/cylc-run/${WORKFLOW_NAME}/${DIR}") == \
82 "$TMPDIR/$USER/cylc-run/${WORKFLOW_NAME}/${DIR}" ]]; then
83 ok "$TEST_SYM.localhost"
84 else
85 fail "$TEST_SYM.localhost"
86 fi
87 done
88
89 SSH="$(cylc config -d -i "[platforms][$CYLC_TEST_PLATFORM]ssh command")"
90
91 # shellcheck disable=SC2016
92 LINK="$(${SSH} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"'"')"
93 if [[ "$LINK" == *"/test_cylc_symlink/ctb_tmp_run_dir/cylc-run/${WORKFLOW_NAME}" ]]; then
94 ok "${TEST_NAME_BASE}-run-symlink-exists-ok.remotehost"
95 else
96 fail "${TEST_NAME_BASE}-run-symlink-exists-ok.remotehost"
97 fi
98
99 # shellcheck disable=SC2016
100 LINK="$(${SSH} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"/share/cycle'"')"
101 if [[ "$LINK" == *"/test_cylc_symlink/ctb_tmp_share_dir/cylc-run/${WORKFLOW_NAME}/share/cycle" ]]; then
102 ok "${TEST_NAME_BASE}-share/cycle-symlink-exists-ok.remotehost"
103 else
104 fail "${TEST_NAME_BASE}-share/cycle-symlink-exists-ok.remotehost"
105 fi
106
107 # shellcheck disable=SC2016
108 LINK="$(${SSH} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"/log/job'"')"
109 if [[ "$LINK" == *"/cylctb_tmp_log_job_dir/cylc-run/${WORKFLOW_NAME}/log/job" ]]; then
110 ok "${TEST_NAME_BASE}-log/job-symlink-exists-ok.remotehost"
111 else
112 fail "${TEST_NAME_BASE}-log/job-symlink-exists-ok.remotehost"
113 fi
114
115 for DIR in 'work' 'share' 'log'; do
116 # shellcheck disable=SC2016
117 LINK="$(${SSH} "${CYLC_TEST_HOST}" 'readlink "$HOME/cylc-run/'"$WORKFLOW_NAME"/$DIR'"')"
118 if [[ "$LINK" == *"/test_cylc_symlink/cylc-run/${WORKFLOW_NAME}/${DIR}" ]]; then
119 ok "${TEST_NAME_BASE}-${DIR}-symlink-exists-ok.remotehost"
120 else
121 fail "${TEST_NAME_BASE}-${DIR}-symlink-exists-ok.remotehost"
122 fi
123 done
124
125 # clean up remote
126 ${SSH} "${CYLC_TEST_HOST}" rm -rf "${TMPDIR}/${USER}/test_cylc_symlink/"
127 purge
128 exit