Skip to content

Commit

Permalink
Merge remote-tracking branch 'interuss/main' into query-settings-reso…
Browse files Browse the repository at this point in the history
…urce
  • Loading branch information
BenjaminPelletier committed Sep 30, 2024
2 parents 094c2d8 + 5cfb1ca commit 11afa5c
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Implicit subscription cover validity test step fragment

This test step fragment validates the time-bounds of an implicit subscription
with respect to the OIRs it needs to cover.

## 🛑 Implicit subscription has wide enough temporal parameters check

If the implicit subscription's time boundaries do not cover every OIR attached to it, the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../../requirements/astm/f3548/v21.md)**.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ is expected to trigger the creation of a new implicit subscription.

If the DSS does not create the implicit subscription, it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../../requirements/astm/f3548/v21.md)**.

## [Correct temporal parameters](implicit_correct.md)
## [Correct temporal parameters](implicit_correct_exact.md)
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The implicit subscription attached to the mutated OIR should be able to be queri
If it cannot, the DSS is either improperly managing implicit subscriptions for OIRs, or failing to report the subscriptions relevant to an OIR,
in which case the DSS is 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.

#### [Correct temporal bounds](fragments/sub/implicit_correct.md)
#### [Correct temporal bounds](fragments/sub/implicit_correct_exact.md)

#### 🛑 Non-mutated implicit subscription is deleted check

Expand Down Expand Up @@ -144,7 +144,7 @@ This test case verifies that implicit subscriptions are properly removed if they

### [Ensure clean workspace test step](clean_workspace.md)

This test step resets the workspace for this test case.
Reset the workspace for this test case.

### Create two OIRs with implicit subscription test step

Expand Down Expand Up @@ -186,5 +186,41 @@ This step updates the OIR to not use any subscription, and expects the implicit
If the implicit subscription that was attached to the OIR is still present after the OIR is updated to use another subscription,
the DSS is failing to properly manage implicit subscriptions for OIRs, and is therefore in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

## Implicit subscriptions are expanded as needed test case

This test case checks that a DSS will properly expand an implicit subscription to cover an OIR that is being attached to it.

### [Ensure clean workspace test step](clean_workspace.md)

Reset the workspace for this test case.

### Create an OIR with implicit subscription test step

Create an OIR with which interactions will be tested and request an implicit
subscription to be created.

#### [Create OIR](./fragments/oir/crud/create_query.md)

#### [Valid Implicit Subscription](./fragments/sub/implicit_create.md)

### Expand the OIR while keeping the same implicit subscription test step

Expand the previously created OIR's duration while explicitly specifying the implicit subscription that
was automatically created for it.

#### [Mutate OIR](./fragments/oir/crud/update_query.md)

#### 🛑 The implicit subscription can be queried check

The implicit subscription attached to the mutated OIR should be able to be queried.

If it cannot, the DSS is either improperly managing implicit subscriptions for OIRs, or failing to report the subscriptions relevant to an OIR,
in which case the DSS is 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.

#### [Correct temporal bounds](fragments/sub/implicit_correct_cover.md)

Ensure that the attached implicit subscription has been expanded



## [Cleanup](./clean_workspace.md)
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ def run(self, context: ExecutionContext):

self.end_test_case()

self.begin_test_case("Implicit subscriptions are expanded as needed")
self._setup_case()
self.begin_test_step("Create an OIR with implicit subscription")
self._case_4_create_oir()
self.end_test_step()

self.begin_test_step(
"Expand the OIR while keeping the same implicit subscription"
)
self._case_4_expand_oir_same_implicit_sub()
self.end_test_step()

self.end_test_case()

self.end_test_scenario()

"""
Expand Down Expand Up @@ -603,6 +617,79 @@ def _case_3_update_oir_with_no_sub(self):
query_timestamps=[sub_exp_fail.request.timestamp],
)

def _case_4_create_oir(self):
oir_a, _, impl_sub_1, _ = self._create_oir(
self._oir_a_id, self._time_0, self._time_1, [], with_implicit_sub=True
)

self._oir_a_ovn = oir_a.ovn
self._implicit_sub_1 = impl_sub_1

def _case_4_expand_oir_same_implicit_sub(self):
# Mutate the OIR so it is slightly longer and
# specify the implicit sub previously created for that OIR
with self.check(
"Mutate operational intent reference query succeeds", self._pid
) as check:
try:
oir, subs, q = self._dss.put_op_intent(
extents=[
self._planning_area.get_volume4d(
self._time_0, self._time_2
).to_f3548v21()
],
key=[],
state=OperationalIntentState.Accepted,
base_url=DUMMY_BASE_URL,
oi_id=self._oir_a_id,
ovn=self._oir_a_ovn,
subscription_id=self._implicit_sub_1.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,
)

with self.check("The implicit subscription can be queried", self._pid) as check:
sub = self._dss.get_subscription(self._implicit_sub_1.id)
self.record_query(sub)
if sub.status_code != 200:
check.record_failed(
summary="Subscription query failed",
details=f"Failed to query previously created implicit subscription {oir.subscription_id} with code {sub.response.status_code}. Message: {sub.error_message}",
query_timestamps=sub.query_timestamps,
)

with self.check(
"Implicit subscription has wide enough temporal parameters", self._pid
) as check:
if (
abs(
sub.subscription.time_start.value.datetime - self._time_0
).total_seconds()
> TIME_TOLERANCE_SEC
):
check.record_failed(
summary="Subscription time_start does not match OIR",
details=f"Subscription time_start is {sub.subscription.time_start.value.datetime}, expected {self._time_0}",
query_timestamps=[sub.request.timestamp],
)
if (
abs(
sub.subscription.time_end.value.datetime - self._time_2
).total_seconds()
> TIME_TOLERANCE_SEC
):
check.record_failed(
summary="Subscription time_end does not match OIR",
details=f"Subscription time_end is {sub.subscription.time_end.value.datetime}, expected {self._time_0}",
query_timestamps=[sub.request.timestamp],
)

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

0 comments on commit 11afa5c

Please sign in to comment.