From 3b71bacc307a989e4c05e7b8de3870c54e7d3955 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 8 Jan 2025 00:25:48 +0100 Subject: [PATCH] tft: skip test case types that are deprecated aliases Some TestCaseType are identical to others. It makes no sense to run them. However, we get them easily when specifying a range or "*". If we have such a deprecated alias, then skip it if-and-only-if the original value is also present. Note that this skipping does not cover any further check for duplicates. With ranges, we can easily specify the same test multiple times, and we will run them. We only skip the aliases if the orignal is already selected. Signed-off-by: Thomas Haller --- testConfig.py | 15 +++++++++++++++ trafficFlowTests.py | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/testConfig.py b/testConfig.py index 3aee4a5f..d8bb8f0d 100644 --- a/testConfig.py +++ b/testConfig.py @@ -769,6 +769,21 @@ def get_test_case(self) -> TestCaseType: raise RuntimeError("No test_cases_idx set") return self.get_tft().test_cases[self.test_cases_idx] + def test_case_skip_deprecated_alias(self) -> bool: + tc = self.get_test_case() + if tc.info.deprecated_alias_for is None: + # This is not an alias. We process it. Note that in this case we don't + # check for duplicates and if we have duplicated (non-aliased) test cases, + # we run them twice. + return False + if tc.info.deprecated_alias_for not in self.get_tft().test_cases: + # Process this alias, because the original doesn't appear in the list. Again, + # we don't check for duplicates of the alias. + return False + # The original value for the alias is present. We skip the alias, it would + # be the same as the original, and the user possibly doesn't want that. + return True + def get_connection(self) -> ConfConnection: if self.connections_idx < 0: raise RuntimeError("No connections_idx set") diff --git a/trafficFlowTests.py b/trafficFlowTests.py index 4f12f508..cf1a820b 100644 --- a/trafficFlowTests.py +++ b/trafficFlowTests.py @@ -3,6 +3,7 @@ from pathlib import Path +from ktoolbox import common from ktoolbox import host import testConfig @@ -119,6 +120,11 @@ def _run_test_case_instance( def _run_test_case(self, cfg_descr: ConfigDescriptor) -> list[TftResult]: # TODO Allow for multiple connections / instances to run simultaneously + if cfg_descr.test_case_skip_deprecated_alias(): + logger.info( + f"Skip test case {cfg_descr.get_test_case().name}). This is an alias for {common.unwrap(cfg_descr.get_test_case().info.deprecated_alias_for).name})." + ) + return [] tft_results: list[TftResult] = [] for cfg_descr2 in cfg_descr.describe_all_connections(): connection = cfg_descr2.get_connection()