From fd3366a5da11a9dd14ae875834b9d28b1e0ef1fc Mon Sep 17 00:00:00 2001 From: Deezzir Date: Thu, 14 Nov 2024 21:15:40 -0500 Subject: [PATCH] Add test to check if smartctl-exporter snap is being installed --- tests/functional/test_charm.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/functional/test_charm.py b/tests/functional/test_charm.py index b3d4bb0d..ead3b921 100644 --- a/tests/functional/test_charm.py +++ b/tests/functional/test_charm.py @@ -262,6 +262,19 @@ async def test_redfish_client_timeout_config(self, app, unit, ops_test, provided assert config["redfish_client_timeout"] == int(new_timeout) await app.reset_config(["collect-timeout"]) + + async def test_smarctl_exporter_snap_available(self, ops_test, app, unit): + """Test if smartctl exporter snap is installed and ranning on the unit.""" + snap_name = "smartctl-exporter" + cmd = f"snap list {snap_name}" + results = await run_command_on_unit(ops_test, unit.name, cmd) + assert results.get("return-code") == 0 + assert snap_name in results.get("stdout").strip() + + check_active_cmd = "systemctl is-active snap.smartctl-exporter.smartctl-exporter" + results = await run_command_on_unit(ops_test, unit.name, check_active_cmd) + assert results.get("return-code") == 0 + assert results.get("stdout").strip() == "active" async def test_metrics_available(self, app, unit, ops_test): """Test if metrics are available at the expected endpoint on unit."""