Module: check_mk
Branch: master
Commit: 617c67ab2cccb3d341e7bdb9924b5db061c79809
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=617c67ab2cccb3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 5 17:31:02 2018 +0100
Made not existing host test handle different DNS resolver situations
Change-Id: Icf2029cea449a8ac9f0553639b61701360c0e98d
---
tests/cmk_base/test_automations.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/tests/cmk_base/test_automations.py b/tests/cmk_base/test_automations.py
index 99ed48f..cc3b6f8 100644
--- a/tests/cmk_base/test_automations.py
+++ b/tests/cmk_base/test_automations.py
@@ -2,6 +2,7 @@ import pytest
import subprocess
from testlib import web, repo_path
+import re
import ast
@@ -129,7 +130,7 @@ def test_registered_automations(site):
# '----------------------------------------------------------------------'
def _execute_automation(site, cmd, args=None, stdin=None,
- expect_stdout=None, expect_stderr="",
expect_exit_code=0,
+ expect_stdout=None, expect_stderr="",
expect_stderr_pattern="", expect_exit_code=0,
parse_data=True):
if args is None:
args = []
@@ -144,7 +145,12 @@ def _execute_automation(site, cmd, args=None, stdin=None,
stdout, stderr = p.communicate(stdin)
assert p.wait() == expect_exit_code, "Output: %r, Error: %r" % (stdout,
stderr)
- assert stderr == expect_stderr
+
+ if expect_stderr_pattern:
+ assert re.match(expect_stderr_pattern, stderr) is not None
+ else:
+ assert stderr == expect_stderr
+
if expect_stdout != None:
assert stdout == expect_stdout
@@ -237,7 +243,9 @@ def test_automation_analyse_service_no_check(test_cfg, site):
def test_automation_try_discovery_not_existing_host(test_cfg, site):
data = _execute_automation(site, "try-inventory",
args=["xxx-not-existing-host"],
- expect_stderr="Failed to lookup IPv4 address of xxx-not-existing-host via
DNS: [Errno -2] Name or service not known\n",
+ expect_stderr_pattern="Failed to lookup IPv4 address of
xxx-not-existing-host " \
+ "via DNS: (\[Errno -2\] Name or service not
known"
+ "|\[Errno -3\] Temporary failure in name
resolution)\n",
expect_stdout="",
expect_exit_code=2,
parse_data=False,