Debian Codegraph @

tests/functional/intelligent-host-selection/01-periodic-clear-badhosts.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 # Test mainloop plugin periodically clears badhosts:
19 # * simulate remote-init failure due to SSH issues
20 # * ensure that "reset bad hosts" allows this task to auto "submit retry"
21 # once the bad host is cleared
22
23 . "$(dirname "$0")/test_header"
24
25 #-------------------------------------------------------------------------------
26 set_test_number 3
27
28 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
29
30 # Install the fake background job runner.
31 cp -r "${TEST_SOURCE_DIR}/lib" "${WORKFLOW_RUN_DIR}"
32
33 create_test_global_config '' "
34 [scheduler]
35 [[main loop]]
36 [[[reset bad hosts]]]
37 interval = PT1S
38 [platforms]
39 [[fake-platform]]
40 hosts = localhost
41 # we set the install target to make it look like a remote platform
42 # (and so trigger remote-init)
43 install target = fake-install-target
44 # we botch the SSH command so we can simulate SSH failure
45 ssh command = $HOME/cylc-run/$WORKFLOW_NAME/bin/mock-ssh
46 "
47 #-------------------------------------------------------------------------------
48
49 run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}"
50
51 workflow_run_fail "${TEST_NAME_BASE}-run" \
52 cylc play \
53 --debug \
54 --no-detach \
55 --abort-if-any-task-fails \
56 "${WORKFLOW_NAME}"
57
58 # scrape platform events from the log
59 sed -n \
60 's/.* - \(platform: .*\)/\1/p' \
61 "${WORKFLOW_RUN_DIR}/log/scheduler/log" \
62 > platform-log
63
64 # check this matches expectations
65 # we would expect:
66 # * the task will attempt to remote-init
67 # * this will fail (because we made it fail)
68 # * the task will retry (because of the retry delays)
69 # * the task will attempt to remote-init again
70 # * the remote init will succeed this time
71 # * the task will attempt file-installation
72 # * file installation will fail because the install target is incorrect
73 cmp_ok platform-log <<__HERE__
74 platform: fake-platform - remote init (on localhost)
75 platform: fake-platform - initialisation did not complete
76 platform: fake-platform - remote init (on localhost)
77 platform: fake-platform - remote file install (on localhost)
78 platform: fake-platform - initialisation did not complete
79 platform: fake-platform - remote tidy (on localhost)
80 __HERE__
81
82 purge
83 exit 0