Skip to content

[uss_qualifier] expand OIR implicit sub handling scenario #1026

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ If the newly created OIR does not mention the implicit subscription from the pre
the DSS is either improperly managing implicit subscriptions, or failing to report the subscriptions relevant to an OIR,
and therefore in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)** or **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)** respectively.

#### 🛑 No implicit subscription was attached check

If the DSS attached an implicit subscription, by either creating or re-using an existing one, to the OIR that was created in this step,
the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.
#### [OIR is not attached to an implicit subscription](./fragments/oir/oir_has_expected_subscription.md)

### Mutate OIR with implicit subscription to not overlap anymore test step

Expand Down Expand Up @@ -135,11 +132,7 @@ that were present when the test case started.
Otherwise, the DSS may be failing to properly implement **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**
or **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 No implicit subscription was attached check

If the DSS attached an implicit subscription, by either creating or re-using an existing one, to the OIR that was created in this step,
the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

#### [OIR is not attached to an implicit subscription](./fragments/oir/oir_has_expected_subscription.md)
## Implicit subscriptions are properly deleted when required by OIR mutation test case

This test case verifies that implicit subscriptions are properly removed if they become unnecessary following the mutation of an OIR.
Expand Down Expand Up @@ -271,10 +264,41 @@ Replace the first OIR's explicit subscription with the implicit one created in t

Confirm that the query to replace the second OIR's explicit subscription with the second OIR's implicit subscription succeeds.

#### 🛑 The first OIR is now attached to the specified implicit subscription check
#### [First OIR is now attached to the specified implicit subscription](fragments/oir/oir_has_expected_subscription.md)

## Existing implicit subscription can be attached to OIR without subscription test case

This test case verifies that an implicit subscription can be attached to an OIR that is not currently attached to any subscription.

### Ensure clean workspace test step

Reset the workspace for this test case.

#### [Clean any existing OIRs with known test IDs](clean_workspace_op_intents.md)

#### [Clean any existing subscriptions with known test IDs](clean_workspace_subs.md)

### [Create OIR with no subscription test step](./fragments/oir/crud/create_query.md)

#### [OIR is not attached to an implicit subscription](./fragments/oir/oir_has_expected_subscription.md)

### [Create second OIR with an implicit subscription test step](./fragments/oir/crud/create_query.md)

#### [An implicit subscription was created](./fragments/sub/implicit_create.md)

### Attach OIR without subscription to implicit subscription test step

Attach the first OIR to the implicit subscription created with the second OIR.

#### [Attach OIR to implicit subscription](./fragments/oir/crud/update_query.md)

### Confirm OIR is now attached to implicit subscription test step

Confirms that the DSS properly attached the first OIR to the implicit subscription created with the second OIR.

#### [Get OIR query](./fragments/oir/crud/read_query.md)

If the OIR is not attached to the implicit subscription specified in a successful mutation query,
the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.
#### [First OIR is now attached to the specified implicit subscription](fragments/oir/oir_has_expected_subscription.md)

## Cleanup

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from datetime import datetime, timedelta
from typing import Dict, List, Optional, Set, Tuple
from typing import List, Optional, Set, Tuple

import arrow
from uas_standards.astm.f3548.v21.api import (
EntityID,
OperationalIntentReference,
OperationalIntentState,
SubscriberToNotify,
Expand Down Expand Up @@ -191,6 +190,12 @@ def run(self, context: ExecutionContext):
self._case_5_replace_explicit_sub_with_implicit()
self.end_test_case()

self.begin_test_case(
"Existing implicit subscription can be attached to OIR without subscription"
)
self._setup_case()
self._case_6_attach_implicit_sub_to_oir_without_subscription()
self.end_test_case()
self.end_test_scenario()

def _case_1_step_create_oir_1(self):
Expand Down Expand Up @@ -435,7 +440,7 @@ def _create_oir(
implicit_sub = sub.subscription
elif subscription_id is None:
with self.check(
"No implicit subscription was attached", self._pid
"OIR is attached to expected subscription", self._pid
) as check:
# The official DSS implementation will set the subscription ID to 00000000-0000-4000-8000-000000000000
# Other implementations may use a different value, as the OpenAPI spec does not allow the value to be empty
Expand Down Expand Up @@ -777,7 +782,7 @@ def _case_5_replace_explicit_sub_with_implicit(self):
self._oir_a_ovn = oir.ovn

with self.check(
"The first OIR is now attached to the specified implicit subscription",
"OIR is attached to expected subscription",
self._pid,
) as check:
if sub_implicit.id != oir.subscription_id:
Expand All @@ -787,6 +792,100 @@ def _case_5_replace_explicit_sub_with_implicit(self):
)
self.end_test_step()

def _case_6_attach_implicit_sub_to_oir_without_subscription(self):
self.begin_test_step("Create OIR with no subscription")
oir_no_sub, _, _, _ = self._create_oir(
oir_id=self._oir_a_id,
time_start=self._time_2,
time_end=self._time_3,
relevant_ovns=[],
with_implicit_sub=False,
)
self._oir_a_ovn = oir_no_sub.ovn
self.end_test_step()

self.begin_test_step("Create second OIR with an implicit subscription")
oir_implicit, _, sub_implicit, _ = self._create_oir(
oir_id=self._oir_b_id,
time_start=oir_no_sub.time_start.value.datetime,
time_end=oir_no_sub.time_end.value.datetime,
relevant_ovns=[oir_no_sub.ovn],
with_implicit_sub=True,
)
self._oir_b_ovn = oir_implicit.ovn
self._implicit_sub_1 = sub_implicit
self.end_test_step()

self.begin_test_step("Attach OIR without subscription to implicit subscription")
with self.check(
"Mutate operational intent reference query succeeds", self._pid
) as check:
try:
oir_updated, subs, q = self._dss.put_op_intent(
extents=[
self._planning_area.get_volume4d(
oir_no_sub.time_start.value.datetime,
oir_no_sub.time_end.value.datetime,
).to_f3548v21()
],
key=[oir_implicit.ovn],
state=OperationalIntentState.Accepted,
base_url=DUMMY_BASE_URL,
oi_id=self._oir_a_id,
ovn=self._oir_a_ovn,
subscription_id=sub_implicit.id,
)
self.record_query(q)
except QueryError as e:
self.record_queries(e.queries)
check.record_failed(
summary="OIR Creation failed",
details=str(e),
query_timestamps=e.query_timestamps,
)

self._oir_a_ovn = oir_updated.ovn

self.end_test_step()

self.begin_test_step("Confirm OIR is now attached to implicit subscription")

# First, sanity check of the value reported by the DSS at the previous step
with self.check(
"OIR is attached to expected subscription",
self._pid,
) as check:
if sub_implicit.id != oir_updated.subscription_id:
check.record_failed(
summary="Implicit subscription not attached to OIR",
details=f"The subscription {sub_implicit.id} was attached to the OIR, but it reports being attached to subscription {oir_no_sub.subscription_id} instead.",
)

# Then, do an actual query of the OIR
with self.check("Get operational intent reference by ID", self._pid) as check:
try:
oir_queried, _ = self._dss.get_op_intent_reference(self._oir_a_id)

except QueryError as e:
self.record_queries(e.queries)
check.record_failed(
summary="OIR query failed",
details=str(e),
query_timestamps=e.query_timestamps,
)

with self.check(
"OIR is attached to expected subscription",
self._oir_a_id,
) as check:
if sub_implicit.id != oir_queried.subscription_id:
check.record_failed(
summary="Implicit subscription not attached to OIR",
details=f"The subscription {sub_implicit.id} was attached to the OIR, but it reports being attached to subscription {oir_queried.subscription_id} instead.",
)

self.end_test_step()

def _setup_case(self):
# T0 corresponds to 'now'
self._time_0 = arrow.utcnow().datetime
Expand Down
Loading