From 3655c0277574e31c8c5d7167ada1a4544ef657e5 Mon Sep 17 00:00:00 2001 From: Aaron Whitehouse Date: Thu, 17 Mar 2022 10:54:48 +0000 Subject: [PATCH] Test output with no zpool. --- tests/0_monitoring_tests/run.sh | 20 ++++++++++---------- tests/0_monitoring_tests/test_monitoring.py | 20 +++++++++++++++----- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/tests/0_monitoring_tests/run.sh b/tests/0_monitoring_tests/run.sh index 5fa577d..b28b0af 100755 --- a/tests/0_monitoring_tests/run.sh +++ b/tests/0_monitoring_tests/run.sh @@ -10,24 +10,24 @@ set -x POOL_NAME="sanoid-test-1" POOL_TARGET="" # root -# UTC timestamp of start and end -START="1483225200" -END="1514761199" +# # UTC timestamp of start and end +# START="1483225200" +# END="1514761199" # prepare setup checkEnvironment -disableTimeSync +# disableTimeSync -# set timezone -ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime +# # set timezone +# ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime -timestamp=$START +# timestamp=$START -mkdir -p "${POOL_TARGET}" -truncate -s 5120M "${POOL_TARGET}"/zpool.img +# mkdir -p "${POOL_TARGET}" +# truncate -s 5120M "${POOL_TARGET}"/zpool.img -zpool create -f "${POOL_NAME}" "${POOL_TARGET}"/zpool.img +# zpool create -f "${POOL_NAME}" "${POOL_TARGET}"/zpool.img function cleanUp { zpool export "${POOL_NAME}" diff --git a/tests/0_monitoring_tests/test_monitoring.py b/tests/0_monitoring_tests/test_monitoring.py index 836f656..7810c1f 100644 --- a/tests/0_monitoring_tests/test_monitoring.py +++ b/tests/0_monitoring_tests/test_monitoring.py @@ -6,13 +6,23 @@ import unittest +import os -class TestNothing(unittest.TestCase): - def test_nothing(self): - """Test""" +sanoid_cmd = os.environ.get("SANOID") - # Test sanoid_snapshots_exist - self.assertEqual(1,2) +def monitor_snapshots_command(): + """Runs sanoid --monitor-snapshots and returns a CompletedProcess instance""" + return_info = subprocess.run([sanoid_cmd, "--monitor-metrics"], check=True, capture_output=True) + return return_info + + + +class TestMonitoringOutput(unittest.TestCase): + def test_no_zpool(self): + """Test what happens if there is no zpool at all""" + + return_info = monitor_snapshots_command() + self.assertEqual(return_info.stdout, "chicken") if __name__ == '__main__':