diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/dss/oir_implicit_sub_handling.md b/monitoring/uss_qualifier/scenarios/astm/utm/dss/oir_implicit_sub_handling.md index bf9741d457..e903b9f1ce 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/dss/oir_implicit_sub_handling.md +++ b/monitoring/uss_qualifier/scenarios/astm/utm/dss/oir_implicit_sub_handling.md @@ -221,6 +221,45 @@ in which case the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../. Ensure that the attached implicit subscription has been expanded +## Existing implicit subscription can replace an OIR's explicit subscription test case +This test case verifies that an implicit subscription can be used to replace an explicit subscription attached to an OIR. + +### [Ensure clean workspace test step](clean_workspace.md) + +Reset the workspace for this test case. + +### [Create an explicit subscription test step](./fragments/sub/crud/create_query.md) + +Create an explicit subscription to be initially set on the first OIR created in this test case + +### Create first OIR with an explicit subscription test step + +Create an OIR bound to the explicit subscription created in the previous step. + +#### [Create OIR](./fragments/oir/crud/create_query.md) + +### Create second OIR with an implicit subscription test step + +Create a second OIR with an implicit subscription, which will then be used in the next step. + +#### [Create OIR](./fragments/oir/crud/create_query.md) + +#### [Valid Implicit Subscription](./fragments/sub/implicit_create.md) + +Confirm that an implicit subscription was created. + +### Replace first OIR's explicit subscription with implicit subscription test step + +Replace the first OIR's explicit subscription with the implicit one created in the previous step. + +#### [Mutate OIR](./fragments/oir/crud/update_query.md) + +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 + +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)**. ## [Cleanup](./clean_workspace.md) diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/dss/oir_implicit_sub_handling.py b/monitoring/uss_qualifier/scenarios/astm/utm/dss/oir_implicit_sub_handling.py index 64cce2b085..3ebb9254fd 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/dss/oir_implicit_sub_handling.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/dss/oir_implicit_sub_handling.py @@ -65,9 +65,6 @@ class OIRImplicitSubHandling(TestScenario): _oir_a_ovn: Optional[str] _oir_b_ovn: Optional[str] - _current_subs: Dict[SubscriptionID, Subscription] - _current_oirs: Dict[EntityID, OperationalIntentReference] - # Reference times for the subscriptions and operational intents _time_0: datetime _time_1: datetime @@ -192,6 +189,13 @@ def run(self, context: ExecutionContext): self.end_test_case() + self.begin_test_case( + "Existing implicit subscription can replace an OIR's explicit subscription" + ) + self._setup_case() + self._case_5_replace_explicit_sub_with_implicit() + self.end_test_case() + self.end_test_scenario() def _case_1_step_create_oir_1(self): @@ -336,7 +340,13 @@ def _case_2_step_create_oir_2(self): ) def _create_oir( - self, oir_id, time_start, time_end, relevant_ovns, with_implicit_sub + self, + oir_id, + time_start, + time_end, + relevant_ovns, + with_implicit_sub, + subscription_id=None, ) -> Tuple[ OperationalIntentReference, List[SubscriberToNotify], @@ -374,7 +384,7 @@ def _create_oir( base_url=DUMMY_BASE_URL, oi_id=oir_id, ovn=None, - subscription_id=None, + subscription_id=subscription_id, force_no_implicit_subscription=not with_implicit_sub, ) self.record_query(oir_q) @@ -428,7 +438,7 @@ def _create_oir( query_timestamps=[sub.request.timestamp], ) implicit_sub = sub.subscription - else: + elif subscription_id is None: with self.check( "No implicit subscription was attached", self._pid ) as check: @@ -687,6 +697,101 @@ def _case_4_expand_oir_same_implicit_sub(self): query_timestamps=[sub.request.timestamp], ) + def _case_5_replace_explicit_sub_with_implicit(self): + # TODO explicit subscription creation could be moved to a common fragment to be shared + # with the OIRSimple scenario once it has been extended with new corner cases. + self.begin_test_step("Create an explicit subscription") + sub_params = self._planning_area.get_new_subscription_params( + subscription_id=self._sub_id, + start_time=datetime.now() - timedelta(seconds=10), + duration=timedelta(minutes=20), + notify_for_op_intents=True, + notify_for_constraints=False, + ) + with self.check("Create subscription query succeeds", self._pid) as check: + try: + sub_q = self._dss.upsert_subscription(**sub_params) + self.record_query(sub_q) + except QueryError as qe: + self.record_queries(qe.queries) + check.record_failed( + summary="Could not create subscription", + details=f"Failed to create subscription with error code {qe.cause_status_code}: {qe.msg}", + query_timestamps=qe.query_timestamps, + ) + sub_explicit = sub_q.subscription + self._explicit_sub = sub_explicit + self.end_test_step() + + self.begin_test_step("Create first OIR with an explicit subscription") + oir_explicit, _, _, _ = self._create_oir( + oir_id=self._oir_a_id, + time_start=sub_explicit.time_start.value.datetime, + time_end=sub_explicit.time_end.value.datetime, + relevant_ovns=[], + with_implicit_sub=False, + subscription_id=sub_explicit.id, + ) + self._oir_a_ovn = oir_explicit.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=sub_explicit.time_start.value.datetime, + time_end=sub_explicit.time_end.value.datetime, + relevant_ovns=[oir_explicit.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( + "Replace first OIR's explicit subscription with implicit subscription" + ) + 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( + sub_explicit.time_start.value.datetime, + sub_explicit.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, + # We want to observe the behavior if the request to the DSS + # contains the implicit sub params (default when subscription_id is None) + 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.ovn + + with self.check( + "The first OIR is now attached to the specified implicit subscription", + self._pid, + ) as check: + if sub_implicit.id != oir.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.subscription_id} instead.", + ) + self.end_test_step() + def _setup_case(self): # T0 corresponds to 'now' self._time_0 = arrow.utcnow().datetime