From afa91c115a7e9eb5477ed82f6e12e7f24fc622d6 Mon Sep 17 00:00:00 2001 From: Julien Perrochet Date: Thu, 7 Sep 2023 04:10:29 +0200 Subject: [PATCH] [uss_qualifier] Test DSS Subscription limitations (too many subscriptions) (#177) [uss-qualifier] test for too many created subscriptions --- monitoring/monitorlib/rid.py | 9 +++ .../common/dss/subscription_validation.py | 67 +++++++++++++++---- .../netrid/v19/dss/subscription_validation.md | 16 +++-- .../v22a/dss/subscription_validation.md | 16 +++-- 4 files changed, 87 insertions(+), 21 deletions(-) diff --git a/monitoring/monitorlib/rid.py b/monitoring/monitorlib/rid.py index 5354577549..c24023f49b 100644 --- a/monitoring/monitorlib/rid.py +++ b/monitoring/monitorlib/rid.py @@ -182,6 +182,15 @@ def sp_data_resp_percentile99_s(self) -> float: else: raise ValueError("Unsupported RID version '{}'".format(self)) + @property + def dss_max_subscriptions_per_area(self) -> int: + if self == RIDVersion.f3411_19: + return v19.constants.NetDSSMaxSubscriptionPerArea + elif self == RIDVersion.f3411_22a: + return v22a.constants.NetDSSMaxSubscriptionPerArea + else: + raise ValueError("Unsupported RID version '{}'".format(self)) + def flights_url_of(self, base_url: str) -> str: if self == RIDVersion.f3411_19: return base_url diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/subscription_validation.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/subscription_validation.py index 1c2e3027de..6aa7f45c44 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/subscription_validation.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/subscription_validation.py @@ -58,6 +58,7 @@ def run(self): self.begin_test_scenario() self._setup_case() + self._subscription_limitations_case() self.end_test_scenario() @@ -69,38 +70,75 @@ def _setup_case(self): self.end_test_case() - def _clean_any_sub(self): - with self.check( - "Successful subscription query and cleanup", [self._dss.participant_id] - ) as check: - fetched = self._dss_wrapper.search_subs( - check, self._isa.footprint.to_vertices() - ) - - for sub_id in fetched.subscriptions.keys(): - self._dss_wrapper.cleanup_sub(check, sub_id=sub_id) + def _clean_any_sub(self, check: PendingCheck): + fetched = self._dss_wrapper.search_subs( + check, self._isa.footprint.to_vertices() + ) + for sub_id in fetched.subscriptions.keys(): + self._dss_wrapper.cleanup_sub(check, sub_id=sub_id) def _ensure_clean_workspace_step(self): self.begin_test_step("Ensure clean workspace") - self._clean_any_sub() + with self.check( + "Successful subscription query and cleanup", [self._dss.participant_id] + ) as check: + self._clean_any_sub(check) self.end_test_step() def _subscription_limitations_case(self): self.begin_test_case("Subscription limitations") - self.begin_test_step("Subscription limitations") + + self.begin_test_step("Subscription duration limitations") self._create_too_long_subscription() + self.end_test_step() + + self.begin_test_step("Subscription quantity limitations") + + self._create_too_many_subscriptions() + self.end_test_step() self.end_test_case() + def _create_too_many_subscriptions(self): + + with self.check( + "Create up to the maximum allowed number of subscriptions in an area", + [self._dss.participant_id], + ) as check: + self._clean_any_sub(check) + # Create 10 subscriptions with different ID's + for i in range(self._dss.rid_version.dss_max_subscriptions_per_area): + sub_id = f"{self._sub_id[:-3]}1{i:02d}" + self._dss_wrapper.put_sub( + check, + sub_id=sub_id, + **self._default_subscription_params(datetime.timedelta(minutes=30)), + ) + + with self.check( + "Enforce maximum number of subscriptions for an area", + [self._dss.participant_id], + ) as check: + self._dss_wrapper.put_sub_expect_response_code( + check=check, + sub_id=f"{self._sub_id[:-3]}200", + expected_error_codes={ + 400, # Expecting a 429 but a 400 is acceptable too + 429, + }, + **self._default_subscription_params(datetime.timedelta(minutes=30)), + ) + def _create_too_long_subscription(self): with self.check( "Enforce maximum duration of subscriptions for an area", [self._dss.participant_id], ) as check: + self._clean_any_sub(check) # Sub with this ID does not exist and too long: we expect either a failure, or # that any subscription that is effectively created to be truncated at 24 hours. creation_attempt = self._dss_wrapper.put_sub_expect_response_code( @@ -173,6 +211,9 @@ def _default_subscription_params(self, duration: datetime.timedelta) -> Dict: def cleanup(self): self.begin_cleanup() - self._clean_any_sub() + with self.check( + "Successful subscription query and cleanup", [self._dss.participant_id] + ) as check: + self._clean_any_sub(check) self.end_cleanup() diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/v19/dss/subscription_validation.md b/monitoring/uss_qualifier/scenarios/astm/netrid/v19/dss/subscription_validation.md index 35a8038949..75e04682e6 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/v19/dss/subscription_validation.md +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/v19/dss/subscription_validation.md @@ -30,17 +30,25 @@ We expect to be allowed to query for existing subscriptions in order to clean th ## Subscription limitations test case -### Subscription limitations test step +### Subscription quantity limitations test step + +The test will attempt to create 10 identical subscriptions for the same area and expect this to succeed, then create an 11th one and expect it to fail. + +#### Create up to the maximum allowed number of subscriptions in an area check + +As per **[astm.f3411.v19.DSS0030](../../../../../requirements/astm/f3411/v19.md)**, the DSS API is expected to allow us +to create multiple subscriptions. #### Enforce maximum number of subscriptions for an area check -**[astm.f3411.v22a.DSS0050](../../../../../requirements/astm/f3411/v22a.md)** for a given area for which the DSS is responsible, there may be at most NetDSSMaxSubscriptionPerArea (10) subscriptions per USS. +If the DSS successfully creates an 11th Subscription in the same area instead of rejecting it, +it will not have performed the Subscription count validation as defined in **[astm.f3411.v19.DSS0050](../../../../../requirements/astm/f3411/v19.md)** -The test will attempt to create 10 subscriptions for the same area and expect this to succeed, then create an 11th one and expect it to fail. +### Subscription duration limitations test step #### Enforce maximum duration of subscriptions for an area check -**[astm.f3411.v22a.DSS0060](../../../../../requirements/astm/f3411/v22a.md)** any subscription to the DSS may not exceed NetDSSMaxSubscriptionDuration (24 hours). +**[astm.f3411.v19.DSS0060](../../../../../requirements/astm/f3411/v19.md)** any subscription to the DSS may not exceed NetDSSMaxSubscriptionDuration (24 hours). The test will attempt to create a subscription for 24 hours and 10 minutes, and expect this to fail with an HTTP 400 error. diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/v22a/dss/subscription_validation.md b/monitoring/uss_qualifier/scenarios/astm/netrid/v22a/dss/subscription_validation.md index ab91011169..1c5fcfeaee 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/v22a/dss/subscription_validation.md +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/v22a/dss/subscription_validation.md @@ -26,17 +26,25 @@ This step ensures that we remove any subscription that may already exist for the #### Successful subscription query and cleanup check -We expect to be allowed ro query for existing subscriptions in order to clean them up +We expect to be allowed to query for existing subscriptions in order to clean them up ## Subscription limitations test case -### Subscription limitations test step +### Subscription quantity limitations test step + +The test will attempt to create 10 identical subscriptions for the same area and expect this to succeed, then create an 11th one and expect it to fail. + +#### Create up to the maximum allowed number of subscriptions in an area check + +As per **[astm.f3411.v22a.DSS0030](../../../../../requirements/astm/f3411/v22a.md)**, the DSS API is expected to allow us +to create multiple subscriptions. #### Enforce maximum number of subscriptions for an area check -**[astm.f3411.v22a.DSS0050](../../../../../requirements/astm/f3411/v22a.md)** for a given area for which the DSS is responsible, there may be at most NetDSSMaxSubscriptionPerArea (10) subscriptions per USS. +If the DSS successfully creates an 11th Subscription in the same area instead of rejecting it, +it will not have performed the Subscription count validation as defined in **[astm.f3411.v22a.DSS0050](../../../../../requirements/astm/f3411/v22a.md)** -The test will attempt to create 10 subscriptions for the same area and expect this to succeed, then create an 11th one and expect it to fail. +### Subscription duration limitations test step #### Enforce maximum duration of subscriptions for an area check