Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store unhandled task messages in runtime DB #1889

Merged
merged 1 commit into from
Jun 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/cylc/task_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

from collections import namedtuple
from copy import copy
from logging import getLogger, CRITICAL, ERROR, WARNING, INFO, DEBUG
from logging import (
getLevelName, getLogger, CRITICAL, ERROR, WARNING, INFO, DEBUG)
import os
from pipes import quote
import Queue
Expand Down Expand Up @@ -1512,6 +1513,10 @@ def process_incoming_message(
# Note that all messages are logged already at the top.
self.log(DEBUG, '(current: %s) unhandled: %s' % (
self.state.status, msg))
if priority in [CRITICAL, ERROR, WARNING, INFO, DEBUG]:
priority = getLevelName(priority)
self.db_events_insert(
event=("message %s" % str(priority).lower()), message=msg)

def spawn(self, state):
"""Spawn the successor of this task proxy."""
Expand Down
47 changes: 47 additions & 0 deletions tests/database/06-task-message.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) 2008-2016 NIWA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Suite database content, "task_events" table contains unhandled task messages
. "$(dirname "$0")/test_header"
set_test_number 3
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"

run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"
suite_run_ok "${TEST_NAME_BASE}-run" \
cylc run --debug --reference-test "${SUITE_NAME}"

DB_FILE="$(cylc get-global-config '--print-run-dir')/${SUITE_NAME}/cylc-suite.db"

NAME='select-task-events.out'
sqlite3 "${DB_FILE}" '
SELECT
cycle, name, event, message
FROM
task_events
WHERE
event GLOB "message *"
ORDER BY
event
' >"${NAME}"
cmp_ok "${NAME}" <<'__SELECT__'
1|t1|message critical|You are being critical
1|t1|message normal|You are normal
1|t1|message warning|You have been warned
__SELECT__

purge_suite "${SUITE_NAME}"
exit
5 changes: 5 additions & 0 deletions tests/database/06-task-message/reference.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
2015-06-10T21:54:26Z INFO - Run mode: live
2015-06-10T21:54:26Z INFO - Initial point: 1
2015-06-10T21:54:26Z INFO - Final point: 1
2015-06-10T21:54:26Z INFO - Cold Start 1
2015-06-10T21:54:26Z INFO - [t1.1] -triggered off []
19 changes: 19 additions & 0 deletions tests/database/06-task-message/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[cylc]
UTC mode = True
[[reference test]]
required run mode = live
live mode suite timeout = PT30S
[scheduling]
[[dependencies]]
graph = t1
[runtime]
[[t1]]
script = """
sleep 1
cylc message -p 'WARNING' 'You have been warned'
sleep 1
cylc message -p 'CRITICAL' 'You are being critical'
sleep 1
cylc message 'You are normal'
sleep 1
"""