Debian Codegraph @

tests/functional/cylc-reinstall/01-file-transfer.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 #------------------------------------------------------------------------------
19 # Test workflow re-installation file transfer
20 . "$(dirname "$0")/test_header"
21 if ! command -v 'tree' >'/dev/null'; then
22 skip_all '"tree" command not available'
23 fi
24 set_test_number 13
25
26 # Need to override any symlink dirs set in global.cylc:
27 create_test_global_config "" "
28 [install]
29 [[symlink dirs]]
30 [[[localhost]]]
31 run =
32 log =
33 work =
34 share =
35 share/cycle =
36 "
37
38 # Test cylc install copies files to run dir successfully.
39 TEST_NAME="${TEST_NAME_BASE}-basic"
40 make_rnd_workflow
41 pushd "${RND_WORKFLOW_SOURCE}" || exit 1
42 mkdir .git .svn dir1 dir2-be-removed
43 touch .git/file1 .svn/file1 dir1/file1 dir2-be-removed/file1 file1 file2
44 echo '01-*' > .cylcignore # filter out test files
45 run_ok "${TEST_NAME}" cylc install
46
47 tree_excludes='*.log|01-file-transfer*|rose-suite*.conf|opt'
48
49 tree -a -v -I "${tree_excludes}" --charset=ascii --noreport "${RND_WORKFLOW_RUNDIR}/run1" > '01-file-transfer-basic-tree.out'
50
51 cmp_ok '01-file-transfer-basic-tree.out' <<__OUT__
52 ${RND_WORKFLOW_RUNDIR}/run1
53 |-- dir1
54 | \`-- file1
55 |-- dir2-be-removed
56 | \`-- file1
57 |-- file1
58 |-- file2
59 |-- flow.cylc
60 \`-- log
61 \`-- install
62 __OUT__
63 contains_ok "${TEST_NAME}.stdout" <<__OUT__
64 INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE}
65 __OUT__
66 run_ok "${TEST_NAME}" cylc install
67 mkdir new_dir
68 touch new_dir/new_file1 new_dir/new_file2
69 rm -rf dir2-be-removed file2
70 run_ok "${TEST_NAME}-reinstall" cylc reinstall "${RND_WORKFLOW_NAME}/run2"
71 REINSTALL_LOG="$(find "${RND_WORKFLOW_RUNDIR}/run2/log/install" -type f -name '*reinstall.log')"
72 grep_ok '(del\.|\*deleting) dir2-be-removed/file1' "$REINSTALL_LOG" -E
73 grep_ok '(del\.|\*deleting) file2' "$REINSTALL_LOG" -E
74 grep_ok '(send|recv) new_dir/$' "$REINSTALL_LOG" -E
75 grep_ok '(send|recv) new_dir/new_file1' "$REINSTALL_LOG" -E
76 grep_ok '(send|recv) new_dir/new_file2' "$REINSTALL_LOG" -E
77
78 tree -a -v -I "${tree_excludes}" --charset=ascii --noreport "${RND_WORKFLOW_RUNDIR}/run2" > 'after-reinstall-run2-tree.out'
79 cmp_ok 'after-reinstall-run2-tree.out' <<__OUT__
80 ${RND_WORKFLOW_RUNDIR}/run2
81 |-- dir1
82 | \`-- file1
83 |-- file1
84 |-- flow.cylc
85 |-- log
86 | \`-- install
87 \`-- new_dir
88 |-- new_file1
89 \`-- new_file2
90 __OUT__
91 contains_ok "${TEST_NAME}-reinstall.stdout" <<__OUT__
92 REINSTALLED $RND_WORKFLOW_NAME/run2 from ${RND_WORKFLOW_SOURCE}
93 __OUT__
94
95 # Test cylc reinstall affects only named run, i.e. run1 should be unaffected in this case
96 tree -a -v -I "${tree_excludes}" --charset=ascii --noreport "${RND_WORKFLOW_RUNDIR}/run1" > 'after-reinstall-run1-tree.out'
97 cmp_ok 'after-reinstall-run1-tree.out' '01-file-transfer-basic-tree.out'
98 popd || exit 1
99 purge_rnd_workflow
100
101 exit