Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmeggle committed Dec 7, 2021
2 parents bcbf69e + 2186395 commit 376ab05
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 53 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.2.4 - 2021-12-07

* Check: Check crashes when the suite never ran. In this case, no XML is present
and no data can be parsed. The corrected behaviour now is to skip the discovery
of suites but to let the "Robotmk" service report that suites are missing results. (#178)

## 1.2.3 - 2021-11-29

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion agents_plugins/robotmk.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

local_tz = datetime.utcnow().astimezone().tzinfo

ROBOTMK_VERSION = 'v1.2.3'
ROBOTMK_VERSION = 'v1.2.4'

class RMKConfig():
_PRESERVED_WORDS = [
Expand Down
2 changes: 1 addition & 1 deletion bakery/v1/robotmk.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.

ROBOTMK_VERSION = 'v1.2.3'
ROBOTMK_VERSION = 'v1.2.4'

import cmk.utils.paths
import os
Expand Down
2 changes: 1 addition & 1 deletion bakery/v2/robotmk.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.

ROBOTMK_VERSION = 'v1.2.3'
ROBOTMK_VERSION = 'v1.2.4'

from typing import Iterable, TypedDict, List
from pathlib import Path
Expand Down
51 changes: 26 additions & 25 deletions checks/v1/robotmk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ from collections import namedtuple
iam = "robotmk"
# DO NOT DELETE
inventory_robotmk_rules = []
ROBOTMK_VERSION = 'v1.2.3'
ROBOTMK_VERSION = 'v1.2.4'
DEFAULT_SVC_PREFIX = 'Robot Framework E2E $SUITEID$SPACE-$SPACE'
HTML_LOG_DIR = "%s/%s" % (os.environ['OMD_ROOT'], 'local/share/addons/robotmk')

Expand Down Expand Up @@ -85,7 +85,7 @@ def parse_robot(info):
else:
d_decomp = d
json_suite[k] = d_decomp
try:
if 'xml' in json_suite:
# TODO: his should not be done for HTML
# Leave the XML data binary here, because ElementTree has its own decoding
# mechaism, see https://stackoverflow.com/a/12349894/14845044
Expand All @@ -94,19 +94,19 @@ def parse_robot(info):
xml_str = re.sub(".*(<robot generator=.*)", r"\1", json_suite['xml'], flags=re.DOTALL)
xml = ET.fromstring(xml_str)
xml_root_suite = xml.find('./suite')
except Exception:
continue
setting = pattern_match(robot_discovery_settings,
xml_root_suite.attrib['name'], (0, ''))
discovery_setting = namedtuple(
'DiscoverySetting', 'level blacklist_pattern')._make(setting)
# now process the root suite
st_dict['suites'][idx]['parsed'] = parse_suite_xml(
xml_root_suite, discovery_setting)
else:
pass
# Seems to be a good idea not to raise an exception here.
# The Robotmk service can report this error, too.
#raise MKGeneralException("Fatal parsing error. Robotmk cannot " +\
# "find XML/HTML data. %s" % suite.get('error', ''))
setting = pattern_match(robot_discovery_settings,
xml_root_suite.attrib['name'], (0, ''))
discovery_setting = namedtuple(
'DiscoverySetting', 'level blacklist_pattern')._make(setting)
# now process the root suite
st_dict['suites'][idx]['parsed'] = parse_suite_xml(
xml_root_suite, discovery_setting)
return (st_dict, robot_discovery_settings)


Expand Down Expand Up @@ -281,20 +281,21 @@ def check_robot(item, checkgroup_parameters, parsed):
# see Ref. 8nIZ5J
fflines = []
for root_suite in parsed_section['suites']:
if len(root_suite['parsed'].robotmk_messages) > 0:
firstline_messages = []
fflines.append("Messages from suite '%s':" % root_suite['parsed'].name)
suite_rc = 0
for data in root_suite['parsed'].robotmk_messages:
stateid = STATES_NO[data['nagios_state']]
badge = STATE_BADGES[stateid]
fflines.append(" %s %s %s" % (u"\u25cf", badge, data['msg']))
rc = max(rc, stateid)
suite_rc = max(suite_rc, stateid)
first_line.append("Suite '%s' has messages %s" % (
root_suite['parsed'].name,
STATE_BADGES[suite_rc],
))
if 'parsed' in root_suite:
if len(root_suite['parsed'].robotmk_messages) > 0:
firstline_messages = []
fflines.append("Messages from suite '%s':" % root_suite['parsed'].name)
suite_rc = 0
for data in root_suite['parsed'].robotmk_messages:
stateid = STATES_NO[data['nagios_state']]
badge = STATE_BADGES[stateid]
fflines.append(" %s %s %s" % (u"\u25cf", badge, data['msg']))
rc = max(rc, stateid)
suite_rc = max(suite_rc, stateid)
first_line.append("Suite '%s' has messages %s" % (
root_suite['parsed'].name,
STATE_BADGES[suite_rc],
))
out_lines.append('\n'.join(fflines))


Expand Down
51 changes: 26 additions & 25 deletions checks/v2/robotmk.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from cmk.base.plugins.agent_based.agent_based_api.v1 import *
from cmk.utils.exceptions import MKGeneralException

ROBOTMK_VERSION = 'v1.2.3'
ROBOTMK_VERSION = 'v1.2.4'
DEFAULT_SVC_PREFIX = 'Robot Framework E2E $SUITEID$SPACE-$SPACE'
HTML_LOG_DIR = "%s/%s" % (os.environ['OMD_ROOT'], 'local/share/addons/robotmk')

Expand Down Expand Up @@ -86,22 +86,22 @@ def parse_robotmk(params, string_table):
else:
d_decomp = d
json_suite[k] = d_decomp
try:
if 'xml' in json_suite:
xml = ET.fromstring(json_suite['xml'])
xml_root_suite = xml.find('./suite')
except Exception:
continue
setting = pattern_match(robot_discovery_settings,
xml_root_suite.attrib['name'], (0, ''))
discovery_setting = namedtuple(
'DiscoverySetting', 'level blacklist_pattern')._make(setting)
# now process the root suite
st_dict['suites'][idx]['parsed'] = parse_suite_xml(
xml_root_suite, discovery_setting)
else:
pass
# Seems to be a good idea not to raise an exception here.
# The Robotmk service can report this error, too.
#raise MKGeneralException("Fatal parsing error. Robotmk cannot " +\
# "find XML/HTML data. %s" % suite.get('error', ''))
setting = pattern_match(robot_discovery_settings,
xml_root_suite.attrib['name'], (0, ''))
discovery_setting = namedtuple(
'DiscoverySetting', 'level blacklist_pattern')._make(setting)
# now process the root suite
st_dict['suites'][idx]['parsed'] = parse_suite_xml(
xml_root_suite, discovery_setting)
return (st_dict, params.__dict__['_data'])


Expand Down Expand Up @@ -277,20 +277,21 @@ def check_robotmk(item, params, section):
# see Ref. 8nIZ5J
fflines = []
for root_suite in parsed_section['suites']:
if len(root_suite['parsed'].robotmk_messages) > 0:
firstline_messages = []
fflines.append("Messages from suite '%s':" % root_suite['parsed'].name)
suite_rc = 0
for data in root_suite['parsed'].robotmk_messages:
stateid = STATES_NO[data['nagios_state']]
badge = STATE_BADGES[stateid]
fflines.append(" %s %s %s" % (u"\u25cf", badge, data['msg']))
rc = max(rc, stateid)
suite_rc = max(suite_rc, stateid)
first_line.append("Suite '%s' has messages %s" % (
root_suite['parsed'].name,
STATE_BADGES[suite_rc],
))
if 'parsed' in root_suite:
if len(root_suite['parsed'].robotmk_messages) > 0:
firstline_messages = []
fflines.append("Messages from suite '%s':" % root_suite['parsed'].name)
suite_rc = 0
for data in root_suite['parsed'].robotmk_messages:
stateid = STATES_NO[data['nagios_state']]
badge = STATE_BADGES[stateid]
fflines.append(" %s %s %s" % (u"\u25cf", badge, data['msg']))
rc = max(rc, stateid)
suite_rc = max(suite_rc, stateid)
first_line.append("Suite '%s' has messages %s" % (
root_suite['parsed'].name,
STATE_BADGES[suite_rc],
))
out_lines.append('\n'.join(fflines))


Expand Down

0 comments on commit 376ab05

Please sign in to comment.