Skip to content

Commit

Permalink
tft: skip test case types that are deprecated aliases
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
thom311 committed Jan 16, 2025
1 parent b296814 commit 3b71bac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions testConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions trafficFlowTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from pathlib import Path

from ktoolbox import common
from ktoolbox import host

import testConfig
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 3b71bac

Please sign in to comment.