forked from interuss/monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[uss_qualifier] Add report evaluation to uss_qualifier (interuss#257)
* Add report validation to uss_qualifier * Fix missing resource in dss_probing dev configuration * Fix lint
- Loading branch information
1 parent
5f05b3c
commit efddd75
Showing
27 changed files
with
304 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ v1: | |
participant_requirements: | ||
uss1: scd | ||
uss2: scd | ||
validation: | ||
$ref: ./library/validation.yaml#/normal_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,9 @@ | |
} | ||
} | ||
} | ||
}, | ||
"validation": { | ||
"$ref": "./library/validation.yaml#/normal_test" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
monitoring/uss_qualifier/configurations/dev/library/validation.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
normal_test: | ||
$content_schema: monitoring/uss_qualifier/reports/validation/report_validation/ValidationConfiguration.json | ||
criteria: | ||
- full_success: {} | ||
- no_skipped_actions: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
28 changes: 28 additions & 0 deletions
28
monitoring/uss_qualifier/reports/validation/definitions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import Optional, List | ||
|
||
from implicitdict import ImplicitDict | ||
|
||
|
||
class FullSuccessCriterion(ImplicitDict): | ||
"""Validation criterion that every element of the report must indicate success.""" | ||
|
||
pass | ||
|
||
|
||
class NoSkippedActionsCriterion(ImplicitDict): | ||
"""Validation criterion that no actions in the entire test run may be skipped.""" | ||
|
||
pass | ||
|
||
|
||
class ValidationCriterion(ImplicitDict): | ||
"""Wrapper for all the potential types of validation criteria.""" | ||
|
||
full_success: Optional[FullSuccessCriterion] = None | ||
no_skipped_actions: Optional[NoSkippedActionsCriterion] = None | ||
|
||
|
||
class ValidationConfiguration(ImplicitDict): | ||
"""Complete set of validation criteria that a test run report must satisfy.""" | ||
|
||
criteria: List[ValidationCriterion] |
103 changes: 103 additions & 0 deletions
103
monitoring/uss_qualifier/reports/validation/report_validation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from loguru import logger | ||
|
||
from monitoring.monitorlib.dicts import JSONAddress | ||
from monitoring.uss_qualifier.reports.report import TestRunReport, TestSuiteActionReport | ||
from monitoring.uss_qualifier.reports.validation.definitions import ( | ||
ValidationConfiguration, | ||
) | ||
|
||
|
||
def _validate_action_full_success( | ||
report: TestSuiteActionReport, context: JSONAddress | ||
) -> bool: | ||
test_suite, test_scenario, action_generator = report.get_applicable_report() | ||
if test_scenario: | ||
success = report.test_scenario.successful | ||
if not success: | ||
logger.error( | ||
f"Full success not achieved because {context}.test_scenario.successful was False" | ||
) | ||
elif test_suite: | ||
if report.test_suite.successful: | ||
success = True | ||
else: | ||
success = False | ||
logger.error( | ||
f"Full success not achieved because {context}.test_suite.successful was False" | ||
) | ||
for i, a in enumerate(report.test_suite.actions): | ||
success = success and _validate_action_full_success( | ||
a, JSONAddress(context + f".test_suite.actions[{i}]") | ||
) | ||
elif action_generator: | ||
if report.action_generator.successful: | ||
success = True | ||
else: | ||
success = False | ||
logger.error( | ||
f"Full success not achieved because {context}.action_generator.successful was False" | ||
) | ||
for i, a in enumerate(report.action_generator.actions): | ||
success = success and _validate_action_full_success( | ||
a, JSONAddress(context + f".action_generator.actions[{i}]") | ||
) | ||
return success | ||
|
||
|
||
def _validate_full_success(report: TestRunReport) -> bool: | ||
return _validate_action_full_success(report.report, JSONAddress("$")) | ||
|
||
|
||
def _validate_action_no_skipped_actions( | ||
report: TestSuiteActionReport, context: JSONAddress | ||
) -> bool: | ||
test_suite, test_scenario, action_generator = report.get_applicable_report() | ||
if test_scenario: | ||
success = True | ||
elif test_suite: | ||
if ( | ||
"skipped_actions" not in report.test_suite | ||
or not report.test_suite.skipped_actions | ||
): | ||
success = True | ||
else: | ||
success = False | ||
for sa in report.test_suite.skipped_actions: | ||
logger.error( | ||
f"No skipped actions not achieved because {context}.test_suite had a skipped action for action index {sa.action_declaration_index}: {sa.reason}" | ||
) | ||
for i, a in enumerate(report.test_suite.actions): | ||
success = success and _validate_action_no_skipped_actions( | ||
a, JSONAddress(context + f".test_suite.actions[{i}]") | ||
) | ||
elif action_generator: | ||
success = True | ||
for i, a in enumerate(report.action_generator.actions): | ||
success = success and _validate_action_no_skipped_actions( | ||
a, JSONAddress(context + f".action_generator.actions[{i}]") | ||
) | ||
return success | ||
|
||
|
||
def _validate_no_skipped_actions(report: TestRunReport) -> bool: | ||
return _validate_action_no_skipped_actions(report.report, JSONAddress("$")) | ||
|
||
|
||
def validate_report(report: TestRunReport, validation: ValidationConfiguration) -> bool: | ||
"""Validate that the provided report meets all the specified validation criteria. | ||
Validation failures are logged as errors. | ||
Args: | ||
report: Report to validate. | ||
validation: Validation criteria. | ||
Returns: True if the report satisfies all criteria, False otherwise. | ||
""" | ||
success = True | ||
for criterion in validation.criteria: | ||
if criterion.full_success is not None: | ||
success = success and _validate_full_success(report) | ||
if criterion.no_skipped_actions is not None: | ||
success = success and _validate_no_skipped_actions(report) | ||
return success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.