Skip to content

Commit

Permalink
Release-v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmeggle committed Apr 6, 2021
2 parents dbd9a99 + 621eb6a commit 648c5f6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated


## [v1.0.1 - 2021-04-06

## [v1.0.0-beta - 2021-03-11]
### Fixed

- Two suites on same host were not inventorized correctly (#117)

### Removed

- Removed EXEC_MODE from discovery naming variables - useless


## [v1.0.0-beta - 2021-03-25]

WARNING: This first major release is 100% incompatible with former versions.
**WARNING: This first major release is 100% incompatible with former versions.**
Make sure to export all WATO rules because this version is not able to read the
old data structures.

Expand Down
4 changes: 2 additions & 2 deletions agents/plugins/robotmk
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import platform
import xml.etree.ElementTree as ET

local_tz = datetime.utcnow().astimezone().tzinfo
ROBOTMK_VERSION = 'v1.0.0'
ROBOTMK_VERSION = 'v1.0.1'


class RMKConfig():
Expand Down Expand Up @@ -1047,7 +1047,7 @@ def xml_remove_html(content):
if 'html' in s.attrib:
s.text = '(Robotmk has removed this HTML content for safety reasons)'
content_wo_html = ET.tostring(
xml, encoding='UTF-8', method='xml', xml_declaration=True).decode()
xml, encoding='utf8', method='xml').decode()
return content_wo_html


Expand Down
47 changes: 25 additions & 22 deletions checks/robotmk
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ except:

utc = pytz.utc

ROBOTMK_VERSION = 'v1.0.0'
ROBOTMK_VERSION = 'v1.0.1'

DEFAULT_SVC_PREFIX = 'Robot Framework E2E $SUITEID$SPACE-$SPACE'

Expand Down Expand Up @@ -81,11 +81,11 @@ def parse_robot(info):
"Can not load Robotmk JSON data! (json.loads())")

runner_data = info_dict['runner']
for idx, suite in enumerate(info_dict['suites']):
for idx, json_suite in enumerate(info_dict['suites']):
for k in keys_to_decode:
if k in suite:
if bool(suite[k]):
d = suite[k]
if k in json_suite:
if bool(json_suite[k]):
d = json_suite[k]
if runner_data['encoding'] == 'zlib_codec':
d = d.encode('utf-8')
d_byte = base64.b64decode(d)
Expand All @@ -95,9 +95,9 @@ def parse_robot(info):
d_decomp = base64.b64decode(d)
else:
d_decomp = d
suite[k] = d_decomp
json_suite[k] = d_decomp
try:
xml = ET.fromstring(suite['xml'])
xml = ET.fromstring(json_suite['xml'])
xml_root_suite = xml.find('./suite')
except Exception:
continue
Expand All @@ -110,24 +110,20 @@ def parse_robot(info):
discovery_setting = namedtuple(
'DiscoverySetting', 'level blacklist_pattern')._make(setting)
# now process the root suite
# root_item = parse_suite_xml(xml_root_suite, discovery_setting)
# and reveal the items in the discovery level:
# suite['discovered_items'] = root_item.discovered
# suite['parsed'] = copy.deepcopy(root_item)
# suite['parsed'] = parse_suite_xml(xml_root_suite, discovery_setting)
info_dict['suites'][idx]['parsed'] = parse_suite_xml(
xml_root_suite, discovery_setting)
# info_dict['suites'][idx]['parsed'] = idx
return info_dict


def inventory_robot(parsed):
def inventory_robot(info_dict):

# TODO: Error handling for no suites/runner_data keys?
for root_suite in parsed['suites']:
if 'parsed' in root_suite:
for discovered_item in root_suite['parsed'].discovered:
for json_suite in info_dict['suites']:
if 'parsed' in json_suite:
for discovered_item in json_suite['parsed'].discovered:
item_svc_name = add_svc_prefix(discovered_item.name,
root_suite)
json_suite)
yield item_svc_name, None
# The meta service reporting overall runtimes, stale spool files etc.
svc_robotmk = get_setting('robotmk_service_name', 'Robotmk')
Expand Down Expand Up @@ -382,6 +378,7 @@ def get_svc_prefix(itemname, root_suite):
TAG=root_suite['tag'],
SUITEID=root_suite['id'],
SUITENAME=root_suite['parsed'].name,
# EXEC_MODE=
SPACE=' ')
return prefix

Expand Down Expand Up @@ -410,8 +407,7 @@ class RobotItem(object):
'test': 'RobotTest',
'kw': 'RobotKeyword'
}
# list of suites/tests/kw which were discovered (depending on discovery_level)
discovered = []

indentation_char = u"\u2504"

# Indentation chars.
Expand Down Expand Up @@ -453,6 +449,12 @@ class RobotItem(object):
# list containing all messages from cmk_runtime, cmk_metric of sub nodes
self.sub_messages = []

if self.parent is None:
# list of suites/tests/kw which were discovered (depending on discovery_level)
# Ref: yoczO3
RobotItem.root_suite = self
self.discovered = []

# Bool flag to indicate whether this is a node where messages should be added
# (not needed for Keywords)
self.is_topnode = False
Expand All @@ -466,7 +468,8 @@ class RobotItem(object):
# Empty blacklist = inventorize all
if self.discovery_setting.blacklist_pattern == '' or not re.match(
self.discovery_setting.blacklist_pattern, self.name):
self.discovered.append(self)
# Ref: yoczO3
self.root_suite.discovered.append(self)

def _get_id(self, xmlnode, index):
"""suites and tests have a id attribute. Fake this for keywords.
Expand Down Expand Up @@ -943,8 +946,8 @@ class RobotKeyword(RobotItem):
def parse_suite_xml(root_xml, discovery_setting):
# Store discovery level
RobotItem.discovery_setting = discovery_setting
# clear the class var
RobotItem.discovered = []
# # clear the class var
# RobotItem.discovered = []
# create the topmost suite from the root XML
root_suite = RobotSuite(root_xml, 0, 0, None, None)
return root_suite
Expand Down
1 change: 0 additions & 1 deletion web/plugins/wato/robotmk_wato_params_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def _valuespec_inventory_robotmk_rules():
<tt>${SUITENAME}</tt> - Name of top level suite (usually same name as path)<br>
<tt>${TAG}</tt> - Suite tag<br>
<tt>${SUITEID}</tt> - short for <tt>${PATH}_${TAG}</tt><br>
<tt>${EXEC_MODE}</tt> - Execution mode<br>
<tt>${SPACE}</tt> - Use this if there should be a space between the prefix and the item name<br><br>
The default format string is "<tt>Robot Framework E2E $SUITEID$SPACE-$SPACE</tt>".
""")),
Expand Down

0 comments on commit 648c5f6

Please sign in to comment.