diff --git a/monitoring/mock_uss/tracer/subscriptions.py b/monitoring/mock_uss/tracer/subscriptions.py index dfc6285494..23508fa074 100644 --- a/monitoring/mock_uss/tracer/subscriptions.py +++ b/monitoring/mock_uss/tracer/subscriptions.py @@ -151,7 +151,7 @@ def unsubscribe_rid( def unsubscribe_scd(subscription_id: str, scd_client: UTMClientSession) -> None: logger = context.tracer_logger get_result = fetch.scd.get_subscription(scd_client, subscription_id) - if not get_result.success: + if not (get_result.success or get_result.was_not_found): logfile = logger.log_new( SCDUnsubscribe( existing_subscription=get_result, diff --git a/monitoring/monitorlib/fetch/scd.py b/monitoring/monitorlib/fetch/scd.py index d66927fb10..9aa8841556 100644 --- a/monitoring/monitorlib/fetch/scd.py +++ b/monitoring/monitorlib/fetch/scd.py @@ -375,12 +375,21 @@ def constraints( class FetchedSubscription(fetch.Query): @property def success(self) -> bool: + """Returns true if a subscription could be successfully fetched.""" return not self.errors + @property + def was_not_found(self) -> bool: + """ + Returns true if the subscription was not found. + Any http return code different from 404 will cause this to be False. + """ + return self.status_code == 404 + @property def errors(self) -> List[str]: if self.status_code == 404: - return [] + return ["Subscription not found"] if self.status_code != 200: return ["Request to get Subscription failed ({})".format(self.status_code)] if self.json_result is None: diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_interactions.py b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_interactions.py index 210e3dbacd..fa4f0080c8 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_interactions.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_interactions.py @@ -325,7 +325,7 @@ def _steps_create_subs_at_each_dss(self): "Get Subscription by ID", other_dss.participant_id, ) as check: - if not other_dss_sub.success: + if not (other_dss_sub.success or other_dss_sub.was_not_found): check.record_failed( summary="Get subscription query failed", details=f"Failed to retrieved a subscription from DSS with code {other_dss_sub.status_code}: {other_dss_sub.error_message}", diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_interactions_deletion.py b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_interactions_deletion.py index feab4ed5e7..ace6613fa6 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_interactions_deletion.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_interactions_deletion.py @@ -140,7 +140,7 @@ def _case_subs_deletion(self): ) as check: other_dss_sub = other_dss.get_subscription(sub_id) self.record_query(other_dss_sub) - if not other_dss_sub.success: + if not (other_dss_sub.success or other_dss_sub.was_not_found): check.record_failed( summary="Get subscription query failed", details=f"Failed to retrieved a subscription from DSS with code {other_dss_sub.status_code}: {other_dss_sub.error_message}", diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.py b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.py index d60fe8b876..70ec6a4ae7 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.py @@ -417,7 +417,7 @@ def _test_get_sub(self): fetched_sub = self._dss.get_subscription(sub_id) self.record_query(fetched_sub) with self.check("Get subscription query succeeds", self._pid) as check: - if not fetched_sub.success: + if not (fetched_sub.success or fetched_sub.was_not_found): check.record_failed( "Get subscription by ID failed", details=f"Get subscription by ID failed with status code {fetched_sub.status_code}",