Debian Codegraph @

tests/f/cylc-ping/04-check-keys-remote.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 remote ZMQ keys are created and deleted on shutdown.
19 export REQUIRE_PLATFORM='loc:remote'
20 . "$(dirname "$0")/test_header"
21 set_test_number 5
22
23 create_test_global_config '' "
24 [platforms]
25 [[$CYLC_TEST_PLATFORM]]
26 retrieve job logs = True
27 "
28
29 init_workflow "${TEST_NAME_BASE}" <<__FLOW_CONFIG__
30 [scheduling]
31 [[graph]]
32 R1 = keys
33
34 [runtime]
35 [[keys]]
36 platform = $CYLC_TEST_PLATFORM
37 script = """
38 find \
39 "\${CYLC_WORKFLOW_RUN_DIR}" \
40 -type f \
41 -name "*key*" \
42 | awk -F/ '{print \$NF}'|sort > "\${CYLC_TASK_LOG_ROOT}-find-out"
43 """
44 [[[environment]]]
45 LANG = C
46 __FLOW_CONFIG__
47
48 run_ok "${TEST_NAME_BASE}-validate" cylc validate \
49 "${WORKFLOW_NAME}"
50 workflow_run_ok "${TEST_NAME_BASE}-run" cylc play \
51 "${WORKFLOW_NAME}" \
52 --no-detach
53
54 KEYS_FILE="$(cylc cat-log -m p "$WORKFLOW_NAME//1/keys" -f job-find-out)"
55 if [[ "$CYLC_TEST_PLATFORM" == *shared* ]]; then
56 cmp_ok "$KEYS_FILE" <<__OUT__
57 client.key_secret
58 client_${CYLC_TEST_INSTALL_TARGET}.key
59 server.key
60 server.key_secret
61 __OUT__
62 else
63 cmp_ok "$KEYS_FILE" <<__OUT__
64 client.key_secret
65 client_${CYLC_TEST_INSTALL_TARGET}.key
66 server.key
67 __OUT__
68 fi
69
70 if [[ "$CYLC_TEST_PLATFORM" == *shared* ]]; then
71 skip 1
72 else
73 # NOTE: remote tidy happens on a random platform picked from the install
74 # target so might not be $CYLC_TEST_PLATFORM
75 grep_ok \
76 "platform: .* - remote tidy (on $CYLC_TEST_HOST)" \
77 "${WORKFLOW_RUN_DIR}/log/scheduler/log"
78 fi
79
80 # ensure the keys got removed again afterwards
81 SSH='ssh -n -oBatchMode=yes -oConnectTimeout=5'
82 ${SSH} "${CYLC_TEST_HOST}" \
83 LANG=C find "cylc-run/${WORKFLOW_NAME}" -type f -name "*key*"|awk -F/ '{print $NF}'|sort >'find.out'
84 cmp_ok 'find.out' </dev/null
85
86 purge
87 exit