From 762548bde22f3469e7c86ad18212ab1254878203 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 12 Sep 2023 09:25:55 +0200 Subject: [PATCH] Add a test for plugin smartctl This test checks that the plugin returns a JSON string as expected. Signed-off-by: Guillaume --- .../plugin_smartctl/test_smartctl.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/xapi-plugins/plugin_smartctl/test_smartctl.py diff --git a/tests/xapi-plugins/plugin_smartctl/test_smartctl.py b/tests/xapi-plugins/plugin_smartctl/test_smartctl.py new file mode 100644 index 000000000..9efb50a75 --- /dev/null +++ b/tests/xapi-plugins/plugin_smartctl/test_smartctl.py @@ -0,0 +1,21 @@ +import json +import pytest + +# Requirements: +# From --hosts parameter: +# - host(A1): first XCP-ng host >= 8.3. + +def _call_plugin(host, fn): + ret = host.call_plugin("smartctl.py", fn) + try: + json.loads(ret) + except ValueError: + pytest.fail("JSON string was expected but ValueError was raised") + +@pytest.mark.usefixtures("host_at_least_8_3") +def test_smartctl_information(host): + _call_plugin(host, "information") + +@pytest.mark.usefixtures("host_at_least_8_3") +def test_smartctl_health(host): + _call_plugin(host, "health")