Skip to content

Commit

Permalink
DSS0210,2 sync entity references
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Mar 11, 2024
1 parent b6b14fe commit 0911c44
Show file tree
Hide file tree
Showing 29 changed files with 1,123 additions and 44 deletions.
13 changes: 13 additions & 0 deletions monitoring/monitorlib/fetch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,19 @@ def __init__(self, msg: str, queries: Optional[Union[Query, List[Query]]] = None
else:
self.queries = queries

@property
def last_status_code(self) -> int:
"""Returns the status code of the last query present in this QueryError,
or 999 if this error contains no queries."""
if len(self.queries) == 0:
return 999
return self.queries[-1].status_code

@property
def query_timestamps(self) -> List[datetime.datetime]:
"""Returns the timestamps of all queries present in this QueryError."""
return [q.request.timestamp for q in self.queries]

@property
def stacktrace(self) -> str:
return stacktrace_string(self)
Expand Down
10 changes: 10 additions & 0 deletions monitoring/monitorlib/schema_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ class F3548_21(str, Enum):
QuerySubscriptionsResponse = "components.schemas.QuerySubscriptionsResponse"
DeleteSubscriptionResponse = "components.schemas.DeleteSubscriptionResponse"

ChangeOperationalIntentReferenceResponse = (
"components.schemas.ChangeOperationalIntentReferenceResponse"
)
GetOperationalIntentReferenceResponse = (
"components.schemas.GetOperationalIntentReferenceResponse"
)
QueryOperationalIntentReferenceResponse = (
"components.schemas.QueryOperationalIntentReferenceResponse"
)


_openapi_content_cache: Dict[str, dict] = {}

Expand Down
2 changes: 1 addition & 1 deletion monitoring/prober/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def wrapper_default_scope(*args, **kwargs):
resource_type_code_descriptions: Dict[ResourceType, str] = {}


# Next code: 380
# Next code: 382
def register_resource_type(code: int, description: str) -> ResourceType:
"""Register that the specified code refers to the described resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ v1:
dss_instances: dss_instances
mock_uss: mock_uss
second_utm_auth: second_utm_auth
utm_client_identity: utm_client_identity
planning_area: planning_area
problematically_big_area: problematically_big_area

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ v1:
dss_instances: scd_dss_instances
id_generator: id_generator
second_utm_auth: second_utm_auth
utm_client_identity: utm_client_identity
planning_area: che_planning_area
problematically_big_area: che_problematically_big_area
execution:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
from typing import List, Dict, Any, Optional, Self

from implicitdict import ImplicitDict, StringBasedDateTime
from uas_standards.astm.f3548.v21.api import Volume4D
from uas_standards.astm.f3548.v21.api import (
EntityOVN,
OperationalIntentState,
UssBaseURL,
EntityID,
PutOperationalIntentReferenceParameters,
ImplicitSubscriptionParameters,
)

from monitoring.monitorlib.geo import LatLngPoint, make_latlng_rect, Volume3D, Polygon
from monitoring.monitorlib.geotemporal import Volume4D
from monitoring.monitorlib.temporal import Time
from monitoring.uss_qualifier.resources.astm.f3548.v21.subscription_params import (
SubscriptionParams,
)
Expand Down Expand Up @@ -52,6 +61,46 @@ def get_new_subscription_params(
notify_for_constraints=notify_for_constraints,
)

def get_new_operational_intent_ref_params(
self,
key: List[EntityOVN],
state: OperationalIntentState,
uss_base_url: UssBaseURL,
time_start: datetime.datetime,
time_end: datetime.datetime,
oir_id: Optional[EntityID],
implicit_sub_base_url: Optional[UssBaseURL] = None,
implicit_sub_for_constraints: Optional[bool] = None,
) -> PutOperationalIntentReferenceParameters:
"""
Build a PutOperationalIntentReferenceParameters object that can be used against the DSS OIR API.
The extents contained in these parameters contain a single 4DVolume, which may not be entirely realistic,
but is sufficient in situations where the content of the OIR is irrelevant as long as it is valid, such
as for testing authentication or parameter validation.
Note that this method allows building inconsistent parameters.
"""
return PutOperationalIntentReferenceParameters(
extents=[
Volume4D(
volume=self.volume,
time_start=Time(time_start),
time_end=Time(time_end),
).to_f3548v21()
],
key=key,
state=state,
uss_base_url=uss_base_url,
subscription_id=oir_id,
new_subscription=ImplicitSubscriptionParameters(
uss_base_url=implicit_sub_base_url,
notify_for_constraints=implicit_sub_for_constraints,
)
if implicit_sub_base_url
else None,
)


class PlanningAreaResource(Resource[PlanningAreaSpecification]):
specification: PlanningAreaSpecification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This page describes the content of a common test step that ensures a clean works

## 🛑 Operational intent references can be queried by ID check

If an existing operational intent reference cannot directly be queried by its ID, the DSS implementation is in violation of
**[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.
If an existing operational intent reference cannot directly be queried by its ID, or if for a non-existing one the DSS replies with a status code different than 404,
the DSS implementation is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Operational intent references can be searched for check

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# CRUD operational intent reference test step fragment

This test step fragment validates that operational intent references can be created, updated, read and modified.

## 🛑 Create operational intent reference query succeeds check

As per **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**, the DSS API must allow callers to create an operational intent reference with either one or both of the
start and end time missing, provided all the required parameters are valid.

## 🛑 Create operational intent reference response is correct check

A successful operational intent reference creation query is expected to return a well-defined body, the content of which reflects the created operational intent reference.
If the format and content of the response are not conforming, the DSS is failing to implement **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Create operational intent reference response format conforms to spec check

The response to a successful operational intent reference creation query is expected to conform to the format defined by the OpenAPI specification under the `A3.1` Annex of ASTM F3548−21.

If it does not, the DSS is failing to implement **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Response to operational intent reference creation contains correct body check

As per **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**, upon creation of a operational intent reference,
the newly created operational intent reference must be part of its response.

## 🛑 Get operational intent reference by ID check

If an operational intent reference cannot be queried using its ID, the DSS is failing to meet **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Get operational intent reference response format conforms to spec check

The response to a successful get operational intent reference query is expected to conform to the format defined by the OpenAPI specification under the `A3.1` Annex of ASTM F3548−21.

If it does not, the DSS is failing to implement **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Successful operational intent reference search query check

If the DSS fails to let us search in the area for which the OIR was created, it is failing to meet **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Created operational intent reference is in search results check

If the existing operational intent reference is not returned in a search that covers the area it was created for, the DSS is not properly implementing **[astm.f3548.v21.DSS0005,2](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Search operational intent reference response format conforms to spec check

The response to a successful operational intent reference search query is expected to conform to the format defined by the OpenAPI specification under the `A3.1` Annex of ASTM F3548−21.

If it does not, the DSS is failing to implement **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Mutate operational intent reference query succeeds check

As per **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**, the DSS API must allow callers to mutate an operational intent reference.

## 🛑 Mutate operational intent reference query succeeds check

A successful operational intent reference mutation query is expected to return a well-defined body, the content of which reflects the updated operational intent reference.
If the format and content of the response are not conforming, the DSS is failing to implement **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Mutate operational intent reference response format conforms to spec check

The response to a successful operational intent reference mutation query is expected to conform to the format defined by the OpenAPI specification under the `A3.1` Annex of ASTM F3548−21.

If it does not, the DSS is failing to implement **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Delete operational intent reference query succeeds check

A query to delete an operational intent reference, by its owner and when the correct OVN is provided, should succeed, otherwise the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Delete operational intent reference response is correct check

A successful operational intent reference deletion query is expected to return a well-defined body, the content of which reflects the operational intent reference at the moment of deletion.
If the format and content of the response are not conforming, the DSS is failing to implement **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Delete operational intent reference response format conforms to spec check

The response to a successful operational intent reference deletion query is expected to conform to the format defined by the OpenAPI specification under the `A3.1` Annex of ASTM F3548−21.

If it does not, the DSS is failing to implement **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Synchronize operational intent reference test step fragment

This test step fragment validates that operational intent references are properly synchronized across a set of DSS instances.

## 🛑 Operational intent reference can be found at every DSS check

If the previously created or mutated operational intent reference cannot be found at a DSS, either one of the instances at which the operational intent reference was created or the one that was queried,
may be failing to implement **[astm.f3548.v21.DSS0210,2a](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Propagated operational intent reference contains the correct manager check

If the operational intent reference returned by a DSS to which the operational intent reference was synchronized to does not contain the correct manager,
either one of the instances at which the operational intent reference was created or the one that was queried, may be failing to implement **[astm.f3548.v21.DSS0210,2b](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Propagated operational intent reference contains the correct USS base URL check

If the operational intent reference returned by a DSS to which the operational intent reference was synchronized to does not contain the correct USS base URL,
either one of the instances at which the operational intent reference was created or the one that was queried, may be failing to implement **[astm.f3548.v21.DSS0210,2c](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Propagated operational intent reference contains the correct state check

If the operational intent reference returned by a DSS to which the operational intent reference was synchronized to does not contain the correct state,
either one of the instances at which the operational intent reference was created or the one that was queried, may be failing to implement **[astm.f3548.v21.DSS0210,2d](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Propagated operational intent reference contains the correct start time check

If the operational intent reference returned by a DSS to which the operational intent reference was synchronized to does not contain the correct start time,
either one of the instances at which the operational intent reference was created or the one that was queried, may be failing to implement **[astm.f3548.v21.DSS0210,2f](../../../../../requirements/astm/f3548/v21.md)**.

## 🛑 Propagated operational intent reference contains the correct end time check

If the operational intent reference returned by a DSS to which the operational intent reference was synchronized to does not contain the correct end time,
either one of the instances at which the operational intent reference was created or the one that was queried, may be failing to implement **[astm.f3548.v21.DSS0210,2f](../../../../../requirements/astm/f3548/v21.md)**.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Validate operational intent reference test step fragment

This test step fragment attempts to validate a single operational intent reference returned by the DSS.

The code for these checks lives in the [oir_validator.py](../validators/oir_validator.py) class.

## ⚠️ Returned operational intent reference ID is correct check

If the returned operational intent reference ID does not correspond to the one specified in the creation parameters,
**[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)** is not respected.

## ⚠️ Returned operational intent reference has a manager check

If the returned operational intent reference has no manager defined, **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)** is not respected.

## ⚠️ Returned operational intent reference manager is correct check

The returned manager must correspond to the identity of the client that created the operational intent at the DSS,
otherwise the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Returned operational intent reference state is correct check

The returned state must be the same as the provided one, otherwise the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Returned operational intent reference has an USS base URL check

If the returned operational intent reference has no USS base URL defined, **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)** is not respected.

## ⚠️ Returned operational intent reference base URL is correct check

The returned USS base URL must be prefixed with the USS base URL that was provided at operational intent reference creation, otherwise the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Returned operational intent reference has a start time check

If the returned operational intent reference has no start time defined, **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)** is not respected.

## ⚠️ Returned start time is correct check

The returned start time must be the same as the provided one, otherwise the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Returned operational intent reference has an end time check

Operational intent references need a defined end time in order to limit their duration: if the DSS omits to set the end time, it will be in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Returned end time is correct check

The returned end time must be the same as the provided one, otherwise the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Returned operational intent reference has a version check

If the returned operational intent reference has no version defined, **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)** is not respected.

## ⚠️ Non-mutated operational intent reference keeps the same version check

If the version of the operational intent reference is updated without there having been any mutation of the operational intent reference, the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Non-mutated operational intent reference keeps the same OVN check

If the OVN of the operational intent reference is updated without there having been any mutation of the operational intent reference, the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Mutated operational intent reference version is updated check

Following a mutation, the DSS needs to update the operational intent reference version, otherwise it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

## ⚠️ Mutated operational intent reference OVN is updated check

Following a mutation, the DSS needs to update the operational intent reference OVN, otherwise it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .subscription_synchronization import SubscriptionSynchronization
from .op_intent_ref_synchronization import OIRSynchronization
Loading

0 comments on commit 0911c44

Please sign in to comment.