Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uss_qualifier] Add local test suite resources #279

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,3 @@ locality_che:
resource_type: resources.interuss.mock_uss.locality.LocalityResource
specification:
locality_code: CHE

# ===== System versioning =====

uspace_system_identity:
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
resource_type: resources.versioning.SystemIdentityResource
specification:
system_identity: uspace.ussp
3 changes: 0 additions & 3 deletions monitoring/uss_qualifier/configurations/dev/uspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ v1:
resources:
resource_declarations:
locality_che: {$ref: 'library/resources.yaml#/locality_che'}
uspace_system_identity: {$ref: 'library/resources.yaml#/uspace_system_identity'}
che_conflicting_flights: {$ref: 'library/resources.yaml#/che_conflicting_flights'}
che_invalid_flight_intents: {$ref: 'library/resources.yaml#/che_invalid_flight_intents'}
che_invalid_flight_auth_flights: {$ref: 'library/resources.yaml#/che_invalid_flight_auth_flights'}
Expand Down Expand Up @@ -41,7 +40,6 @@ v1:
locality: locality_che

version_providers: scd_version_providers
system_identity: uspace_system_identity

conflicting_flights: che_conflicting_flights
priority_preemption_flights: che_conflicting_flights
Expand All @@ -67,7 +65,6 @@ v1:
suite_type: suites.uspace.required_services
resources:
version_providers: version_providers
system_identity: system_identity

conflicting_flights: conflicting_flights
priority_preemption_flights: priority_preemption_flights
Expand Down
23 changes: 21 additions & 2 deletions monitoring/uss_qualifier/suites/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
from monitoring.uss_qualifier.reports.capability_definitions import (
ParticipantCapabilityDefinition,
)
from monitoring.uss_qualifier.resources.definitions import ResourceID, ResourceTypeName
from monitoring.uss_qualifier.resources.definitions import (
ResourceID,
ResourceTypeName,
ResourceCollection,
ResourceDeclaration,
)
from monitoring.uss_qualifier.scenarios.definitions import (
TestScenarioDeclaration,
)
Expand All @@ -24,7 +29,7 @@ class TestSuiteDeclaration(ImplicitDict):
suite_definition: Optional[TestSuiteDefinition]
"""Definition of test suite internal to the configuration -- specified instead of `suite_type`."""

resources: Dict[ResourceID, ResourceID]
resources: Optional[Dict[ResourceID, ResourceID]]
"""Mapping of the ID a resource will be known by in the child test suite -> the ID a resource is known by in the parent test suite.

The child suite resource <key> is supplied by the parent suite resource <value>.
Expand Down Expand Up @@ -136,6 +141,9 @@ class TestSuiteDefinition(ImplicitDict):
resources: Dict[ResourceID, ResourceTypeNameSpecifyingOptional]
"""Enumeration of the resources used by this test suite"""

local_resources: Optional[Dict[ResourceID, ResourceDeclaration]]
"""Declarations of resources originating in this test suite."""

actions: List[TestSuiteActionDeclaration]
"""The actions to take when running the test suite. Components will be executed in order."""

Expand All @@ -145,6 +153,17 @@ class TestSuiteDefinition(ImplicitDict):
participant_verifiable_capabilities: Optional[List[ParticipantCapabilityDefinition]]
"""Definitions of capabilities verified by this test suite for individual participants."""

def __init__(self, *args, **kwargs):
super(TestSuiteDefinition, self).__init__(*args, **kwargs)
inherits_resources = "resources" in self and self.resources
local_resources = "local_resources" in self and self.local_resources
if inherits_resources and local_resources:
for k in self.resources:
if k in self.local_resources:
raise ValueError(
f"Resource '{k}' found in both `resources` and `local_resources`; resource IDs must be unique"
)

@staticmethod
def load_from_declaration(
declaration: TestSuiteDeclaration,
Expand Down
17 changes: 13 additions & 4 deletions monitoring/uss_qualifier/suites/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ResourceType,
make_child_resources,
MissingResourceError,
create_resources,
)
from monitoring.uss_qualifier.scenarios.scenario import (
TestScenario,
Expand Down Expand Up @@ -185,10 +186,18 @@ def __init__(

self.declaration = declaration
self.definition = TestSuiteDefinition.load_from_declaration(declaration)
self.local_resources = {
local_resource_id: resources[parent_resource_id]
for local_resource_id, parent_resource_id in declaration.resources.items()
}
if "resources" in declaration and declaration.resources:
self.local_resources = {
local_resource_id: resources[parent_resource_id]
for local_resource_id, parent_resource_id in declaration.resources.items()
}
else:
self.local_resources = {}
if "local_resources" in self.definition and self.definition.local_resources:
local_resources = create_resources(self.definition.local_resources)
for local_resource_id, resource in local_resources.items():
self.local_resources[local_resource_id] = resource

for resource_id, resource_type in self.definition.resources.items():
is_optional = resource_type.endswith("?")
if is_optional:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: U-space required services
resources:
version_providers: resources.versioning.VersionProvidersResource
system_identity: resources.versioning.SystemIdentityResource

conflicting_flights: resources.flight_planning.FlightIntentsResource
priority_preemption_flights: resources.flight_planning.FlightIntentsResource
Expand All @@ -19,6 +18,11 @@ resources:
id_generator: resources.interuss.IDGeneratorResource
service_area: resources.netrid.ServiceAreaResource
problematically_big_area: resources.VerticesResource
local_resources:
system_identity:
resource_type: resources.versioning.SystemIdentityResource
specification:
system_identity: uspace.ussp
actions:
- test_scenario:
scenario_type: scenarios.versioning.GetSystemVersions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
{
"$id": "https://github.com/interuss/monitoring/blob/main/schemas/monitoring/uss_qualifier/suites/definitions/TestSuiteDeclaration.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"description": "monitoring.uss_qualifier.suites.definitions.TestSuiteDeclaration, as defined in monitoring/uss_qualifier/suites/definitions.py",
"properties": {
"$ref": {
"type": "string",
"description": "Path to content that replaces the $ref"
"description": "Path to content that replaces the $ref",
"type": "string"
},
"resources": {
"additionalProperties": {
"type": "string"
},
"description": "Mapping of the ID a resource will be known by in the child test suite -> the ID a resource is known by in the parent test suite.\n\nThe child suite resource <key> is supplied by the parent suite resource <value>.",
"properties": {
"$ref": {
"description": "Path to content that replaces the $ref",
"type": "string"
}
},
"type": [
"object",
"null"
]
},
"suite_definition": {
"description": "Definition of test suite internal to the configuration -- specified instead of `suite_type`.",
"oneOf": [
{
"type": "null"
},
{
"$ref": "TestSuiteDefinition.json"
}
],
"description": "Definition of test suite internal to the configuration -- specified instead of `suite_type`."
},
"resources": {
"type": "object",
"properties": {
"$ref": {
"type": "string",
"description": "Path to content that replaces the $ref"
}
},
"additionalProperties": {
"type": "string"
},
"description": "Mapping of the ID a resource will be known by in the child test suite -> the ID a resource is known by in the parent test suite.\n\nThe child suite resource <key> is supplied by the parent suite resource <value>."
]
},
"suite_type": {
"description": "Type/location of test suite. Usually expressed as the file name of the suite definition (without extension) qualified relative to the `uss_qualifier` folder",
"type": [
"string",
"null"
],
"description": "Type/location of test suite. Usually expressed as the file name of the suite definition (without extension) qualified relative to the `uss_qualifier` folder"
]
}
},
"$id": "https://github.com/interuss/monitoring/blob/main/schemas/monitoring/uss_qualifier/suites/definitions/TestSuiteDeclaration.json",
"description": "monitoring.uss_qualifier.suites.definitions.TestSuiteDeclaration, as defined in monitoring/uss_qualifier/suites/definitions.py",
"required": [
"resources"
]
"type": "object"
}
Original file line number Diff line number Diff line change
@@ -1,62 +1,78 @@
{
"$id": "https://github.com/interuss/monitoring/blob/main/schemas/monitoring/uss_qualifier/suites/definitions/TestSuiteDefinition.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"description": "Schema for the definition of a test suite, analogous to the Python TestScenario subclass for scenarios\n\nmonitoring.uss_qualifier.suites.definitions.TestSuiteDefinition, as defined in monitoring/uss_qualifier/suites/definitions.py",
"properties": {
"$ref": {
"type": "string",
"description": "Path to content that replaces the $ref"
"description": "Path to content that replaces the $ref",
"type": "string"
},
"actions": {
"description": "The actions to take when running the test suite. Components will be executed in order.",
"items": {
"$ref": "TestSuiteActionDeclaration.json"
},
"type": "array"
},
"local_resources": {
"additionalProperties": {
"$ref": "../../resources/definitions/ResourceDeclaration.json"
},
"description": "Declarations of resources originating in this test suite.",
"properties": {
"$ref": {
"description": "Path to content that replaces the $ref",
"type": "string"
}
},
"type": [
"object",
"null"
]
},
"name": {
"type": "string",
"description": "Name of the test suite"
"description": "Name of the test suite",
"type": "string"
},
"participant_verifiable_capabilities": {
"description": "Definitions of capabilities verified by this test suite for individual participants.",
"items": {
"$ref": "../../reports/capability_definitions/ParticipantCapabilityDefinition.json"
},
"type": [
"array",
"null"
]
},
"report_evaluation_scenario": {
"description": "The scenario executed after all the actions that evaluates the test suite report. Must be a ReportEvaluationScenario.",
"oneOf": [
{
"type": "null"
},
{
"$ref": "../../scenarios/definitions/TestScenarioDeclaration.json"
}
],
"description": "The scenario executed after all the actions that evaluates the test suite report. Must be a ReportEvaluationScenario."
},
"participant_verifiable_capabilities": {
"type": [
"array",
"null"
],
"items": {
"$ref": "../../reports/capability_definitions/ParticipantCapabilityDefinition.json"
},
"description": "Definitions of capabilities verified by this test suite for individual participants."
]
},
"resources": {
"type": "object",
"properties": {
"$ref": {
"type": "string",
"description": "Path to content that replaces the $ref"
}
},
"additionalProperties": {
"type": "string"
},
"description": "Enumeration of the resources used by this test suite"
},
"actions": {
"type": "array",
"items": {
"$ref": "TestSuiteActionDeclaration.json"
"description": "Enumeration of the resources used by this test suite",
"properties": {
"$ref": {
"description": "Path to content that replaces the $ref",
"type": "string"
}
},
"description": "The actions to take when running the test suite. Components will be executed in order."
"type": "object"
}
},
"$id": "https://github.com/interuss/monitoring/blob/main/schemas/monitoring/uss_qualifier/suites/definitions/TestSuiteDefinition.json",
"description": "Schema for the definition of a test suite, analogous to the Python TestScenario subclass for scenarios\n\nmonitoring.uss_qualifier.suites.definitions.TestSuiteDefinition, as defined in monitoring/uss_qualifier/suites/definitions.py",
"required": [
"actions",
"name",
"resources"
]
],
"type": "object"
}
Loading