Skip to content

Commit

Permalink
Release-0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmeggle committed Jan 6, 2021
2 parents 7adc763 + 66a9edc commit be6391f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 28 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
### Fixed

## [v0.1.7 - 2021-01-05]

### Fixed/Changed

- Service prefix "Robot" is eliminated. By default, there is *no* prefix at all.
It can be overriden by a custom one. By installing this version, your existing Robot
services will get new descriptions (=without "Robot"), RRD data tied to the old
name will be lost. (closes #50)

## [v0.1.6 - 2021-01-05]

Expand Down
10 changes: 1 addition & 9 deletions checks/robotmk
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ def check_robot(item, checkgroup_parameters, robot_items):
# so that it can be compared to the Robot item
item_without_prefix = strip_prefix(item)
if robot_item.name == item_without_prefix:
# # find a matching pattern and use its discovery level
# setting = pattern_match(robot_discovery_settings, item_without_prefix, (0, '') )
# discovery_setting = namedtuple('DiscoverySetting', 'level blacklist_pattern')._make(setting)

# discovery_level = int(pattern_match(robot_discovery_level, item_without_prefix, 0))
item_result = robot_item.get_checkmk_result(robot_item, checkgroup_parameters)
(rc, output_lines, perfdata) = (
item_result['worststate'],
Expand All @@ -159,7 +154,6 @@ class RobotItem(object):
'test' : 'RobotTest',
'kw' : 'RobotKeyword'
}
# FIXME needed? lv_disc = 0
# list of suites/tests/kw which were discovered (depending on discovery_level)
discovered = []
indentation_char = u"\u2504"
Expand Down Expand Up @@ -541,7 +535,6 @@ class RobotItem(object):

# MERGE padded_lines and perfdata of sub-items
self._merge_sub_padded_lines()
# FIXME aktivieren !
self._merge_sub_perfdata()

# Now that all information about this node have been collected, evaluate
Expand Down Expand Up @@ -656,7 +649,6 @@ def pattern_match(patterns, name, default=None):
return True
return default

# FIXME: docs
def get_robotmk_pattern_value(setting):
setting_keyname = getattr(self, "%s_dict_key" % setting)
patterns = checkgroup_parameters.get(setting, {}).get(setting_keyname, [])
Expand Down Expand Up @@ -745,7 +737,7 @@ check_info['robotmk'] = {
"parse_function": parse_robot,
"inventory_function": inventory_robot,
"check_function": check_robot,
"service_description": "Robot",
"service_description": "",
"group": "robotmk",
"has_perfdata": True
}
Expand Down
21 changes: 18 additions & 3 deletions test/fixtures/robot/001/expected.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
[
# discovery_suite_level 0
{
'inventory_items': ['Testsuite'],
'inventory_items': {
'dl_0': {
'inventory_items': ['Testsuite'],
},
'dl_0_prefix': {
'inventory_items': ['TESTPREFIXTestsuite'],
},
},
'items' : {
'Testsuite': {
# checkgroup_parameters file
Expand Down Expand Up @@ -60,7 +67,11 @@
},
# discovery_suite_level 1
{
'inventory_items': ['Testcase 1'],
'inventory_items': {
'dl_1': {
'inventory_items': ['Testcase 1'],
},
},
'items' : {
'Testcase 1': {
# checkgroup_parameters file
Expand All @@ -73,7 +84,11 @@
},
# discovery_suite_level 2
{
'inventory_items': ['Sleep'],
'inventory_items': {
'dl_2': {
'inventory_items': ['Sleep'],
},
},
'items' : {
'Sleep': {
# checkgroup_parameters file
Expand Down
24 changes: 8 additions & 16 deletions test/test_robotmk_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,23 @@
# Info test function
def test_check_info(checks):
info = checks['robotmk'].check_info
assert info['service_description'] == "Robot"
assert info['service_description'] == ""
assert info['group'] == "robotmk"


# Inventory test function
inventory_test_params = [
('001', 'dl_0', 0),
('001', 'dl_0_prefix', 0),
('001', 'dl_1', 1),
('001', 'dl_2', 2),
]

# mk_check_input = read_mk_input('%s/input_check.json' % testsuite)
# discovery_rules = read_mk_inventory_rules(testsuite, inventory_rules)
# expected_data = read_expected_data(testsuite, discovery_level, item, checkgroup_parameters)

# patch(checks.module, monkeypatch, discovery_rules)
# params = read_mk_checkgroup_params(testsuite, checkgroup_parameters)

# result = checks['robotmk'].check_mk(item, params, mk_check_input)
# expected_output = expected_data['svc_output']

@pytest.mark.parametrize("testsuite, inventory_rules, discovery_level", inventory_test_params)
def test_inventory_mk(checks, monkeypatch, testsuite, inventory_rules, discovery_level):
mk_check_input = read_mk_input(testsuite)
discovery_rules = read_mk_inventory_rules(testsuite, inventory_rules)
expected_data = read_expected_data(testsuite, discovery_level)
expected_data = read_expected_data(testsuite, discovery_level, parameter_filename=inventory_rules)
patch(checks.module, monkeypatch, discovery_rules)
inventory = checks['robotmk'].inventory_mk(mk_check_input)
assert_inventory(inventory, expected_data['inventory_items'])
Expand Down Expand Up @@ -152,7 +143,7 @@ def read_mk_inventory_rules(testsuite, file):
# return eval(open('test/fixtures/inventory_robotmk_rules/%s.py' % rulefile).read())
return data

def read_expected_data(testsuite, discovery_level, item=None, checkgroup_parameters=None):
def read_expected_data(testsuite, discovery_level, item=None, parameter_filename=None):
datafile = "test/fixtures/robot/%s/expected.py" % testsuite
data = eval_file(datafile)
try:
Expand All @@ -162,14 +153,15 @@ def read_expected_data(testsuite, discovery_level, item=None, checkgroup_paramet
sys.exit(1)
if item != None:
try:
expected_data = expected_data_dl['items'][item][checkgroup_parameters]
expected_data = expected_data_dl['items'][item][parameter_filename]
except:
print "ERROR: %s does not contain a valid entry for either item '%s', discovery level %s and/or checkgroup_params '%s'!" % (
datafile, item, discovery_level, checkgroup_parameters)
datafile, item, discovery_level, parameter_filename)
sys.exit(1)
# for inventory
else:
expected_data = expected_data_dl
expected_data = expected_data_dl['inventory_items'][parameter_filename]
# expected_data = expected_data_dl
return expected_data

def eval_file(datafile):
Expand Down

0 comments on commit be6391f

Please sign in to comment.