Debian Codegraph @

tests/f/events/20-workflow-event-handlers.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 workflow event handler, flexible interface
19 . "$(dirname "$0")/test_header"
20 set_test_number 4
21 OPT_SET=
22 if [[ "${TEST_NAME_BASE}" == *-globalcfg ]]; then
23 create_test_global_config "" "
24 [scheduler]
25 [[events]]
26 handlers = echo 'Your %(workflow)s workflow has a %(event)s event and URL %(workflow_url)s and workflow-priority as %(workflow-priority)s and workflow-UUID as %(uuid)s.'
27 handler events = startup"
28 OPT_SET='-s GLOBALCFG=True'
29 fi
30
31 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
32 # shellcheck disable=SC2086
33 run_ok "${TEST_NAME_BASE}-validate" \
34 cylc validate ${OPT_SET} "${WORKFLOW_NAME}"
35 # shellcheck disable=SC2086
36 workflow_run_ok "${TEST_NAME_BASE}-run" \
37 cylc play --reference-test --debug --no-detach ${OPT_SET} "${WORKFLOW_NAME}"
38
39 LOGD="$RUN_DIR/${WORKFLOW_NAME}/log"
40 WORKFLOW_UUID="$(sqlite3 "${LOGD}/db" "SELECT value FROM workflow_params WHERE key=='uuid_str'")"
41 LOG_FILE="${LOGD}/scheduler/log"
42 grep_ok "\\[('workflow-event-handler-00', 'startup') ret_code\\] 0" "${LOG_FILE}"
43 grep_ok "\\[('workflow-event-handler-00', 'startup') out\\] Your ${WORKFLOW_NAME} workflow has a startup event and URL http://myworkflows.com/${WORKFLOW_NAME}.html and workflow-priority as HIGH and workflow-UUID as ${WORKFLOW_UUID}." "${LOG_FILE}"
44
45 purge
46 exit