Module: check_mk
Branch: master
Commit: 4d53fffefad25912817e8f0ff800316c81766754
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4d53fffefad259…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Apr 2 11:51:19 2019 +0200
Add simple service tags query to livestatus
CMK-1815
Change-Id: I60f3ebb3019ee7424a3e9258027bcdc0b9861bf3
---
tests/integration/livestatus/test_livestatus.py | 32 +++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tests/integration/livestatus/test_livestatus.py
b/tests/integration/livestatus/test_livestatus.py
index b44d2e4..4435e5a 100644
--- a/tests/integration/livestatus/test_livestatus.py
+++ b/tests/integration/livestatus/test_livestatus.py
@@ -116,3 +116,35 @@ def test_service_table(default_cfg, site):
assert "Check_MK Discovery" in descriptions
assert "CPU load" in descriptions
assert "Memory" in descriptions
+
+
+(a)pytest.fixture()
+def configure_service_tags(site, web):
+ web.set_ruleset(
+ "service_tag_rules", {
+ "ruleset": {
+ "": [{
+ "value": [("criticality", "prod")],
+ "conditions": {
+ "host_tags": [],
+ "host_specs": ["livestatus-test-host"],
+ "service_specs": ["CPU load$"],
+ },
+ },],
+ }
+ })
+ web.activate_changes()
+ yield
+ web.set_ruleset("service_tag_rules", {"ruleset": {"":
[],}})
+ web.activate_changes()
+
+
+def test_service_custom_variables(configure_service_tags, default_cfg, site):
+ rows = site.live.query("GET services\n"
+ "Columns: custom_variables tags\n"
+ "Filter: host_name = livestatus-test-host\n"
+ "Filter: description = CPU load\n")
+ assert isinstance(rows, list)
+ custom_variables, tags = rows[0]
+ assert custom_variables == {}
+ assert tags == {u'criticality': u'prod'}