Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions .basedpyright/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5191,46 +5191,6 @@
"lineCount": 1
}
},
{
"code": "reportOperatorIssue",
"range": {
"startColumn": 8,
"endColumn": 29,
"lineCount": 1
}
},
{
"code": "reportOptionalMemberAccess",
"range": {
"startColumn": 19,
"endColumn": 28,
"lineCount": 1
}
},
{
"code": "reportOptionalMemberAccess",
"range": {
"startColumn": 55,
"endColumn": 64,
"lineCount": 1
}
},
{
"code": "reportOptionalMemberAccess",
"range": {
"startColumn": 19,
"endColumn": 28,
"lineCount": 1
}
},
{
"code": "reportOptionalMemberAccess",
"range": {
"startColumn": 15,
"endColumn": 24,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
Expand All @@ -5239,30 +5199,6 @@
"lineCount": 1
}
},
{
"code": "reportOptionalMemberAccess",
"range": {
"startColumn": 38,
"endColumn": 47,
"lineCount": 1
}
},
{
"code": "reportOperatorIssue",
"range": {
"startColumn": 51,
"endColumn": 72,
"lineCount": 1
}
},
{
"code": "reportOptionalMemberAccess",
"range": {
"startColumn": 36,
"endColumn": 42,
"lineCount": 1
}
},
{
"code": "reportOptionalSubscript",
"range": {
Expand Down
3 changes: 3 additions & 0 deletions monitoring/uss_qualifier/configurations/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ class ExecutionConfiguration(ImplicitDict):
stop_when_resource_not_created: bool | None = False
"""If true, stop test execution if one of the resources cannot be created. Otherwise, resources that cannot be created due to missing prerequisites are simply treated as omitted."""

_scenarios_filter: str | None = None
"""Internal copy of regex used to filter specific test scenario."""


class TestConfiguration(ImplicitDict):
action: TestSuiteActionDeclaration
Expand Down
33 changes: 29 additions & 4 deletions monitoring/uss_qualifier/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from monitoring.monitorlib.dicts import get_element_or_default, remove_elements
from monitoring.monitorlib.versioning import get_code_version, get_commit_hash
from monitoring.uss_qualifier.configurations.configuration import (
ExecutionConfiguration,
TestConfiguration,
USSQualifierConfiguration,
USSQualifierConfigurationV1,
)
Expand Down Expand Up @@ -79,6 +81,12 @@ def parseArgs() -> argparse.Namespace:
help="When true, do not run a test configuration which would produce unredacted sensitive information in its artifacts",
)

parser.add_argument(
"--filter",
default=None,
help="Regex used to filter specific test scenario. If not set, all scenario are ran. Mainly useful to quickly debug a specifc scenario.",
)

return parser.parse_args()


Expand All @@ -101,18 +109,20 @@ def sign(self, whole_config: USSQualifierConfiguration) -> None:
baseline = whole_config
environment = []
self.baseline_signature = compute_baseline_signature(
self.codebase_version,
self.commit_hash,
compute_signature(baseline),
self.codebase_version, self.commit_hash, compute_signature(baseline)
)
self.environment_signature = compute_signature(environment)


def execute_test_run(
whole_config: USSQualifierConfiguration, description: TestDefinitionDescription
whole_config: USSQualifierConfiguration,
description: TestDefinitionDescription,
):
config = whole_config.v1.test_run

if not config:
raise Exception("Config not found")

logger.info("Instantiating resources")
stop_when_not_created = (
"execution" in config
Expand Down Expand Up @@ -172,6 +182,7 @@ def run_config(
output_path: str | None,
runtime_metadata: dict | None,
disallow_unredacted: bool,
scenarios_filter: str | None,
):
config_src = load_dict_with_references(config_name)

Expand All @@ -187,6 +198,18 @@ def run_config(

whole_config = ImplicitDict.parse(config_src, USSQualifierConfiguration)

if scenarios_filter:
# We set the scenario filter in the test run execution's object
# As parameters are optionnals, we ensure they do exists first

if not whole_config.v1:
whole_config.v1 = USSQualifierConfigurationV1()
if not whole_config.v1.test_run:
whole_config.v1.test_run = TestConfiguration()
if not whole_config.v1.test_run.execution:
whole_config.v1.test_run.execution = ExecutionConfiguration()
whole_config.v1.test_run.execution._scenarios_filter = scenarios_filter

if config_output:
logger.info("Writing flattened configuration to {}", config_output)
if config_output.lower().endswith(".json"):
Expand Down Expand Up @@ -257,6 +280,7 @@ def main() -> int:
raise ValueError("--runtime-metadata must specify a JSON dictionary")

disallow_unredacted = args.disallow_unredacted
scenarios_filter = args.filter

config_names = str(args.config).split(",")

Expand Down Expand Up @@ -285,6 +309,7 @@ def main() -> int:
output_path,
runtime_metadata,
disallow_unredacted,
scenarios_filter,
)
if exit_code != os.EX_OK:
return exit_code
Expand Down
16 changes: 16 additions & 0 deletions monitoring/uss_qualifier/suites/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def _run_test_scenario(self, context: ExecutionContext) -> TestScenarioReport:
scenario.time_context[TimeDuringTest.StartOfScenario] = Time(
arrow.utcnow().datetime
)

try:
try:
scenario.run(context)
Expand Down Expand Up @@ -630,6 +631,21 @@ def evaluate_skip(self) -> SkippedActionReport | None:
declaration=self.current_frame.action.declaration,
)

if (
"_scenarios_filter" in self.config
and self.config._scenarios_filter
and self.current_frame.action.test_scenario
):
if not re.match(
self.config._scenarios_filter,
self.current_frame.action.test_scenario.__class__.__name__,
):
return SkippedActionReport(
timestamp=StringBasedDateTime(arrow.utcnow()),
reason="Filtered scenario",
declaration=self.current_frame.action.declaration,
)

return None

def begin_action(self, action: TestSuiteAction) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"description": "Path to content that replaces the $ref",
"type": "string"
},
"_scenarios_filter": {
"description": "Internal copy of regex used to filter specific test scenario.",
"type": [
"string",
"null"
]
},
"include_action_when": {
"description": "If specified, only execute test actions if they are selected by ANY of these conditions (and not selected by any of the `skip_when` conditions).",
"items": {
Expand Down
Loading