Skip to content

Commit

Permalink
Test that ipa-healthcheck human output translates error strings
Browse files Browse the repository at this point in the history
The code rather than the string was being displayed in human
output for non-SUCCESS messages. Verify that in case of an error
the right output will be present.

https://bugzilla.redhat.com/show_bug.cgi?id=1752849

Reviewed-By: Mohammad Rizwan Yusuf <myusuf@redhat.com>
Reviewed-By: Sumedh Sidhaye <ssidhaye@redhat.com>
Reviewed-By: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
  • Loading branch information
rcritten authored and flo-renaud committed Mar 21, 2020
1 parent 452ef8c commit 4a3b7ba
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions ipatests/test_integration/test_ipahealthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,15 @@
]


def run_healthcheck(host, source=None, check=None):
def run_healthcheck(host, source=None, check=None, output_type="json"):
"""
Run ipa-healthcheck on the remote host and return the result
Returns: the tuple returncode, json (if any)
Returns: the tuple returncode, output
output is:
json data if output_type == "json"
stdout if output_type == "human"
"""
data = None
cmd = ["ipa-healthcheck"]
Expand All @@ -125,10 +129,16 @@ def run_healthcheck(host, source=None, check=None):
cmd.append("--check")
cmd.append(check)

cmd.append("--output-type")
cmd.append(output_type)

result = host.run_command(cmd, raiseonerr=False)

if result.stdout_text:
data = json.loads(result.stdout_text)
if output_type == "json":
data = json.loads(result.stdout_text)
else:
data = result.stdout_text.strip()

return result.returncode, data

Expand Down Expand Up @@ -168,6 +178,28 @@ def test_run_ipahealthcheck_list_source(self):
for source in sources:
assert source in result.stdout_text

def test_human_output(self):
"""
Test that in human output the severity value is correct
Only the SUCCESS (0) value was being translated, otherwise
the numeric value was being shown (BZ 1752849)
"""
self.master.run_command(["systemctl", "stop", "sssd"])
try:
returncode, output = run_healthcheck(
self.master,
"ipahealthcheck.meta.services",
"sssd",
"human",
)
finally:
self.master.run_command(["systemctl", "start", "sssd"])

assert returncode == 1
assert output == \
"ERROR: ipahealthcheck.meta.services.sssd: sssd: not running"

def test_dogtag_ca_check_exists(self):
"""
Testcase to verify checks available in
Expand Down

0 comments on commit 4a3b7ba

Please sign in to comment.