-
Notifications
You must be signed in to change notification settings - Fork 30
[uss_qualifier] uss availability status: version conflict #1137
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
Changes from all commits
2c5257d
2369956
5dd71cb
0a8447e
d2578aa
5db60aa
62701dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # ASTM Availability DSS: USS Availability Mutation test scenario | ||
|
|
||
| ## Overview | ||
|
|
||
| Verifies the behavior of a DSS for simple interactions pertaining to USS availability status. | ||
|
|
||
| ## Resources | ||
|
|
||
| ### dss | ||
|
|
||
| [`DSSInstanceResource`](../../../../resources/astm/f3548/v21/dss.py) the DSS instance through which entities are created, modified and deleted. | ||
|
|
||
| ### client_identity | ||
|
|
||
| [`ClientIdentityResource`](../../../../resources/communications/client_identity.py) the client identity with the `utm.availability_arbitration` scope that will be used to report the availability status. | ||
|
|
||
| ## Update USS availability state test case | ||
|
|
||
| ### Declare USS as available at DSS test step | ||
|
|
||
| #### [Availability can be read](./fragments/availability/read.md) | ||
|
|
||
| #### [Availability can be updated](./fragments/availability/update.md) | ||
|
|
||
| ## Update requires correct version test case | ||
|
|
||
| Test DSS behavior when update requests are not providing the required version. | ||
|
|
||
| ### Attempt update with missing version test step | ||
|
|
||
| This step verifies that an existing USS availability status cannot be mutated with a missing version. | ||
|
|
||
| #### 🛑 Request to update USS availability status with empty version fails check | ||
|
|
||
| If the DSS under test allows the qualifier to update the USS availability status with a request that provided an empty version, it is in violation of **[astm.f3548.v21.DSS0100,1](../../../../requirements/astm/f3548/v21.md)** | ||
|
|
||
| ### Attempt update with incorrect version test step | ||
|
|
||
| This step verifies that an existing OIR cannot be mutated with an incorrect version. | ||
|
|
||
| #### 🛑 Request to update USS availability status with incorrect version fails check | ||
|
|
||
| If the DSS under test allows the qualifier to update the USS availability status with a request that provided an incorrect version, | ||
| it is in violation of **[astm.f3548.v21.DSS0100,1](../../../../requirements/astm/f3548/v21.md)** |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| from uas_standards.astm.f3548.v21.api import UssAvailabilityState | ||
| from uas_standards.astm.f3548.v21.constants import Scope | ||
|
|
||
| from monitoring.monitorlib.fetch import QueryError | ||
| from monitoring.uss_qualifier.resources.astm.f3548.v21.dss import ( | ||
| DSSInstance, | ||
| DSSInstanceResource, | ||
| ) | ||
| from monitoring.uss_qualifier.resources.communications import ClientIdentityResource | ||
| from monitoring.uss_qualifier.scenarios.astm.utm.dss.test_step_fragments import ( | ||
| get_uss_availability, | ||
| set_uss_availability, | ||
| ) | ||
| from monitoring.uss_qualifier.scenarios.scenario import TestScenario | ||
| from monitoring.uss_qualifier.suites.suite import ExecutionContext | ||
|
|
||
|
|
||
| class UssAvailabilityMutation(TestScenario): | ||
| """ | ||
| A scenario that verifies that USS availability status cannot be updated with the incorrect version. | ||
| """ | ||
|
|
||
| _dss: DSSInstance | ||
| _pid: list[str] | ||
|
|
||
| _uss_id: str | ||
|
|
||
| def __init__( | ||
| self, | ||
| dss: DSSInstanceResource, | ||
| client_identity: ClientIdentityResource, | ||
| ): | ||
| """ | ||
| Args: | ||
| dss: dss to test | ||
| client_identity: tells us the identity we should expect as an entity's manager | ||
| """ | ||
| super().__init__() | ||
| scopes: dict[str, str] = { | ||
| Scope.AvailabilityArbitration: "read and set availability for a USS" | ||
| } | ||
|
|
||
| self._dss = dss.get_instance(scopes) | ||
| self._pid = [self._dss.participant_id] | ||
|
|
||
| self._uss_id = client_identity.subject() | ||
|
|
||
| def run(self, context: ExecutionContext): | ||
| self.begin_test_scenario(context) | ||
|
|
||
| self.begin_test_case("Update USS availability state") | ||
| self._step_declare_uss_available() | ||
| self.end_test_case() | ||
|
|
||
| self.begin_test_case("Update requires correct version") | ||
| self._step_attempt_update_missing_version() | ||
| self._step_attempt_update_incorrect_version() | ||
| self.end_test_case() | ||
|
|
||
| def _step_declare_uss_available(self): | ||
| self.begin_test_step("Declare USS as available at DSS") | ||
| _, version = get_uss_availability( | ||
| self, | ||
| self._dss, | ||
| self._uss_id, | ||
| Scope.AvailabilityArbitration, | ||
| ) | ||
| set_uss_availability( | ||
| self, self._dss, self._uss_id, UssAvailabilityState.Normal, version | ||
| ) | ||
| self.end_test_step() | ||
|
|
||
| def _step_attempt_update_missing_version(self): | ||
| self.begin_test_step("Attempt update with missing version") | ||
| with self.check( | ||
| "Request to update USS availability status with empty version fails", | ||
| self._pid, | ||
| ) as check: | ||
| try: | ||
| _, q = self._dss.set_uss_availability( | ||
| self._uss_id, | ||
| UssAvailabilityState.Down, | ||
| "", | ||
| ) | ||
| self.record_query(q) | ||
| # We don't expect the reach this point: | ||
| check.record_failed( | ||
| summary="Set USS availability with missing version was not expected to succeed", | ||
| details=f"Was expecting an HTTP 409 response because of an missing version, but got {q.status_code} instead", | ||
| query_timestamps=[q.request.timestamp], | ||
| ) | ||
| except QueryError as qe: | ||
| self.record_queries(qe.queries) | ||
| if qe.cause_status_code != 409: | ||
| check.record_failed( | ||
| summary="Set USS availability with missing version failed for unexpected reason", | ||
| details=f"Was expecting an HTTP 409 response because of an missing version, but got {qe.cause_status_code} instead", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include the message from the error response (above as well).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is consistent with other conflicts handling. Will do that in another PR |
||
| query_timestamps=qe.query_timestamps, | ||
| ) | ||
| self.end_test_step() | ||
|
|
||
| def _step_attempt_update_incorrect_version(self): | ||
| self.begin_test_step("Attempt update with incorrect version") | ||
| with self.check( | ||
| "Request to update USS availability status with incorrect version fails", | ||
| self._pid, | ||
| ) as check: | ||
| try: | ||
| _, q = self._dss.set_uss_availability( | ||
| self._uss_id, | ||
| UssAvailabilityState.Down, | ||
| "ThisIsAnIncorrectVersion", | ||
| ) | ||
| self.record_query(q) | ||
| # We don't expect the reach this point: | ||
| check.record_failed( | ||
| summary="Set USS availability with incorrect version was not expected to succeed", | ||
| details=f"Was expecting an HTTP 409 response because of an incorrect version, but got {q.status_code} instead", | ||
| query_timestamps=[q.request.timestamp], | ||
| ) | ||
| except QueryError as qe: | ||
| self.record_queries(qe.queries) | ||
| if qe.cause_status_code != 409: | ||
| check.record_failed( | ||
| summary="Set USS availability with incorrect version failed for unexpected reason", | ||
| details=f"Was expecting an HTTP 409 response because of an incorrect version, but got {qe.cause_status_code} instead", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include the message from the error response (above as well). |
||
| query_timestamps=qe.query_timestamps, | ||
| ) | ||
| self.end_test_step() | ||
Uh oh!
There was an error while loading. Please reload this page.