From da22e60d99da7f464a5b986607e118248e9538ae Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 5 Aug 2024 13:11:51 -0400 Subject: [PATCH 1/3] Remove insufficiently flexible skip decorator The decorator we want is not one for a 1/0 evironment variable. Instead we want a decorator on every test method and that decorator checks if the test is supposed to be skipped for this run. Signed-off-by: mulhern --- tests/whitebox/integration/report/test_get_report.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/whitebox/integration/report/test_get_report.py b/tests/whitebox/integration/report/test_get_report.py index 5412540d4..334eda52d 100644 --- a/tests/whitebox/integration/report/test_get_report.py +++ b/tests/whitebox/integration/report/test_get_report.py @@ -35,12 +35,6 @@ class ReportTestCase(SimTestCase): _MENU = ["--propagate", "report"] - @unittest.skipIf( - os.getenv("STRATIS_SKIP_UNSTABLE_TEST") is not None, - "This test relies on the Report interface's GetReport method which " - "does not guarantee the stability, between minor versions of stratisd, " - "of the report key arguments that it supports.", - ) def test_report(self): """ Test getting stopped pool report. From 724fe053af9c5971eb7d85b584b608ec24e3cb46 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 5 Aug 2024 13:47:37 -0400 Subject: [PATCH 2/3] Skip a test if it is specified in environment variable Signed-off-by: mulhern --- tests/whitebox/_misc.py | 13 +++++++++++++ .../whitebox/integration/report/test_get_report.py | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/whitebox/_misc.py b/tests/whitebox/_misc.py index d15c42bc0..3634ed3bc 100644 --- a/tests/whitebox/_misc.py +++ b/tests/whitebox/_misc.py @@ -39,6 +39,11 @@ _OK = StratisCliErrorCodes.OK +_STRATIS_SKIP_TESTS_VALUE = os.getenv("STRATIS_SKIP_TESTS") +_STRATIS_SKIP_TESTS = ( + [] if _STRATIS_SKIP_TESTS_VALUE is None else _STRATIS_SKIP_TESTS_VALUE.split(";") +) + def device_name_list(min_devices=0, max_devices=10, unique=False): """ @@ -336,6 +341,14 @@ def test_runner(command_line, stdin=None): TEST_RUNNER = test_runner +def skip_if_requested(test_id): + """ + Return true if the test id is included in the environment variable + STRATIS_SKIP_TESTS. + """ + return any(x.endswith(test_id) for x in _STRATIS_SKIP_TESTS) + + def get_pool(proxy, pool_name): """ Get pool information given a pool name. diff --git a/tests/whitebox/integration/report/test_get_report.py b/tests/whitebox/integration/report/test_get_report.py index 334eda52d..547bd552e 100644 --- a/tests/whitebox/integration/report/test_get_report.py +++ b/tests/whitebox/integration/report/test_get_report.py @@ -16,14 +16,13 @@ """ # isort: STDLIB -import os import unittest # isort: LOCAL from stratis_cli import StratisCliErrorCodes from stratis_cli._stratisd_constants import ReportKey -from .._misc import TEST_RUNNER, SimTestCase +from .._misc import TEST_RUNNER, SimTestCase, skip_if_requested _ERROR = StratisCliErrorCodes.ERROR @@ -35,6 +34,7 @@ class ReportTestCase(SimTestCase): _MENU = ["--propagate", "report"] + @unittest.skipIf(skip_if_requested("ReportTestCase.test_report"), "skip requested") def test_report(self): """ Test getting stopped pool report. From efa1fb532188a1e4f0f91124aaaaacd8f8271e59 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 5 Aug 2024 15:12:03 -0400 Subject: [PATCH 3/3] Demonstrate adding a few more annotations Signed-off-by: mulhern --- tests/whitebox/integration/report/test_get_report.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/whitebox/integration/report/test_get_report.py b/tests/whitebox/integration/report/test_get_report.py index 547bd552e..06a8758a6 100644 --- a/tests/whitebox/integration/report/test_get_report.py +++ b/tests/whitebox/integration/report/test_get_report.py @@ -41,18 +41,28 @@ def test_report(self): """ TEST_RUNNER(self._MENU + [ReportKey.STOPPED_POOLS.value]) + @unittest.skipIf( + skip_if_requested("ReportTestCase.test_report_no_name"), "skip requested" + ) def test_report_no_name(self): """ Test getting engine state report when no name specified. """ TEST_RUNNER(self._MENU) + @unittest.skipIf( + skip_if_requested("ReportTestCase.test_engine_state_report"), "skip requested" + ) def test_engine_state_report(self): """ Test getting engine state report. """ TEST_RUNNER(self._MENU + [ReportKey.ENGINE_STATE.value]) + @unittest.skipIf( + skip_if_requested("ReportTestCase.test_managed_objects_report"), + "skip requested", + ) def test_managed_objects_report(self): """ Test getting managed_objects report.