Skip to content

Commit 93bc25d

Browse files
committed
factorize fragments
1 parent 58cf428 commit 93bc25d

File tree

12 files changed

+104
-160
lines changed

12 files changed

+104
-160
lines changed

monitoring/uss_qualifier/resources/astm/f3548/v21/dss.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,12 @@ def get_uss_availability(
416416
def set_uss_availability(
417417
self,
418418
uss_id: str,
419-
available: bool | None,
419+
availability: UssAvailabilityState,
420420
version: str = "",
421421
) -> tuple[str, Query]:
422422
"""
423423
Set the availability for the USS identified by 'uss_id'.
424424
425-
If 'available' is None, the availability will be set to 'Unknown'.
426-
True will set it to 'Normal', and False to 'Down'.
427-
428425
Returns:
429426
A tuple composed of
430427
1) the new version of the USS availability;
@@ -433,13 +430,6 @@ def set_uss_availability(
433430
* QueryError: if request failed, if HTTP status code is different than 200, or if the parsing of the response failed.
434431
"""
435432
self._uses_scope(Scope.AvailabilityArbitration)
436-
if available is None:
437-
availability = UssAvailabilityState.Unknown
438-
elif available:
439-
availability = UssAvailabilityState.Normal
440-
else:
441-
availability = UssAvailabilityState.Down
442-
443433
req = SetUssAvailabilityStatusParameters(
444434
old_version=version,
445435
availability=availability,

monitoring/uss_qualifier/scenarios/astm/utm/dss/authentication/authentication_validation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ def _ensure_availability_is_unknown(self):
391391
with self.check("USS Availability can be updated", self._pid) as check:
392392
try:
393393
availability, q = self._availability_dss.set_uss_availability(
394-
self._test_id, available=None, version=availability.version
394+
self._test_id,
395+
UssAvailabilityState.Unknown,
396+
availability.version,
395397
)
396398
self.record_query(q)
397399
except QueryError as e:

monitoring/uss_qualifier/scenarios/astm/utm/dss/fragments/availability/read.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# USS Availability Read test step fragment
22

3-
This fragment contains the steps for the USS Availability synchronization scenario
3+
This fragment contains the steps for the USS Availability scenario
44
where we confirm that a USS availability can be correctly read from a DSS instance
55

66
## 🛑 USS Availability can be requested check

monitoring/uss_qualifier/scenarios/astm/utm/dss/fragments/availability/sync.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# USS Availability Sync test step fragment
22

3-
## 🛑USS Availability is consistent across every DSS instance check
3+
## 🛑 USS Availability is consistent across every DSS instance check
44

55
If the reported availability for a USS is not consistent, across a set of DSS instances, with the value that was previously read or set on an arbitrary DSS instance,
66
either the DSS through which the value was set or the one through which the values was retrieved is failing to meet at least one of these requirements:
@@ -11,7 +11,7 @@ either the DSS through which the value was set or the one through which the valu
1111

1212
As a consequence, the DSS also fails to meet **[astm.f3548.v21.DSS0210,A2-7-2,6](../../../../../../requirements/astm/f3548/v21.md)** and **[astm.f3548.v21.DSS0020](../../../../../../requirements/astm/f3548/v21.md)**.
1313

14-
## 🛑USS Availability version is consistent across every DSS instance check
14+
## 🛑 USS Availability version is consistent across every DSS instance check
1515

1616
If the reported availability version for a USS is not consistent, across a set of DSS instances, with the value that was previously read or set on an arbitrary DSS instance,
1717
either the DSS through which the value was set or the one through which the values was retrieved is failing to meet at least one of these requirements:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# USS Availability Read test step fragment
1+
# USS Availability Update test step fragment
22

3-
This fragment contains the steps for the USS Availability synchronization scenario
3+
This fragment contains the steps for the USS Availability scenario
44
where we confirm that a USS availability can be correctly read from a DSS instance
55

6-
## 🛑USS Availability can be updated check
6+
## 🛑 USS Availability can be updated check
77

88
If, when presented with a valid query to update the availability state of a USS, a DSS
99
responds with anything else than a 200 OK response, it is in violation of the OpenAPI specification referenced by **[astm.f3548.v21.DSS0100,1](../../../../../../requirements/astm/f3548/v21.md)**.

monitoring/uss_qualifier/scenarios/astm/utm/dss/synchronization/uss_availability_synchronization.py

Lines changed: 40 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
DSSInstancesResource,
99
)
1010
from monitoring.uss_qualifier.resources.communications import ClientIdentityResource
11+
from monitoring.uss_qualifier.scenarios.astm.utm.test_steps import (
12+
get_uss_availability,
13+
set_uss_availability,
14+
)
1115
from monitoring.uss_qualifier.scenarios.scenario import TestScenario
1216
from monitoring.uss_qualifier.suites.suite import ExecutionContext
1317

@@ -145,88 +149,51 @@ def _step_unknown_uss_reported_as_unknown(self):
145149
)
146150

147151
def _step_update_to_unknown(self):
148-
with self.check(
149-
"USS Availability can be updated", self._dss.participant_id
150-
) as check:
151-
try:
152-
self._current_version, q = self._dss.set_uss_availability(
153-
self._uss_id, None, self._current_version
154-
)
155-
self.record_query(q)
156-
except QueryError as qe:
157-
self.record_queries(qe.queries)
158-
check.record_failed(
159-
summary="Failed to set USS availability to Unknown",
160-
details=qe.msg,
161-
query_timestamps=qe.query_timestamps,
162-
)
152+
self._current_version = set_uss_availability(
153+
self,
154+
self._dss,
155+
self._uss_id,
156+
UssAvailabilityState.Unknown,
157+
self._current_version,
158+
)
163159

164160
def _step_update_to_down(self):
165-
with self.check(
166-
"USS Availability can be updated", self._dss.participant_id
167-
) as check:
168-
try:
169-
self._current_version, q = self._dss.set_uss_availability(
170-
self._uss_id, False, self._current_version
171-
)
172-
self.record_query(q)
173-
except QueryError as qe:
174-
self.record_queries(qe.queries)
175-
check.record_failed(
176-
summary="Failed to set USS availability to Down",
177-
details=qe.msg,
178-
query_timestamps=qe.query_timestamps,
179-
)
161+
self._current_version = set_uss_availability(
162+
self,
163+
self._dss,
164+
self._uss_id,
165+
UssAvailabilityState.Down,
166+
self._current_version,
167+
)
180168

181169
def _step_update_to_normal(self):
182-
with self.check(
183-
"USS Availability can be updated", self._dss.participant_id
184-
) as check:
185-
try:
186-
self._current_version, q = self._dss.set_uss_availability(
187-
self._uss_id, True, self._current_version
188-
)
189-
self.record_query(q)
190-
except QueryError as qe:
191-
self.record_queries(qe.queries)
192-
check.record_failed(
193-
summary="Failed to set USS availability to Normal",
194-
details=qe.msg,
195-
query_timestamps=qe.query_timestamps,
196-
)
170+
self._current_version = set_uss_availability(
171+
self,
172+
self._dss,
173+
self._uss_id,
174+
UssAvailabilityState.Normal,
175+
self._current_version,
176+
)
197177

198178
def _ensure_test_uss_availability_unknown(self, check_consistency: bool = True):
199179
"""
200180
Ensure that the availability of the USS being used for the test is set to 'Unknown',
201181
the default state for USS availability when nothing else is known.
202182
We want to both start and end this scenario with this state.
203183
"""
204-
205-
with self.check(
206-
"USS Availability can be requested", self._dss.participant_id
207-
) as check:
208-
try:
209-
availability, q = self._dss.get_uss_availability(
210-
self._uss_id, Scope.AvailabilityArbitration
211-
)
212-
self.record_query(q)
213-
except QueryError as qe:
214-
self.record_queries(qe.queries)
215-
check.record_failed(
216-
summary="Failed to get USS availability",
217-
details=qe.msg,
218-
query_timestamps=qe.query_timestamps,
219-
)
220-
return
221-
222-
self._current_version = availability.version
184+
availability, version = get_uss_availability(
185+
self, self._dss, self._uss_id, Scope.AvailabilityArbitration
186+
)
187+
self._current_version = version
223188

224189
# If the state is not currently unknown, we set it to unknown
225-
if availability.status.availability != UssAvailabilityState.Unknown:
190+
if availability != UssAvailabilityState.Unknown:
226191
with self.check("USS Availability can be set to Unknown") as check:
227192
try:
228193
self._current_version, q = self._dss.set_uss_availability(
229-
self._uss_id, None, self._current_version
194+
self._uss_id,
195+
UssAvailabilityState.Unknown,
196+
self._current_version,
230197
)
231198
self.record_query(q)
232199
except QueryError as qe:
@@ -252,40 +219,27 @@ def _query_and_expect_on_secondary(
252219
expected_availability: UssAvailabilityState,
253220
expected_version: str,
254221
):
255-
with self.check(
256-
"USS Availability can be requested", dss.participant_id
257-
) as check:
258-
try:
259-
availability, q = dss.get_uss_availability(
260-
uss_id, Scope.StrategicCoordination
261-
)
262-
self.record_query(q)
263-
except QueryError as qe:
264-
self.record_queries(qe.queries)
265-
check.record_failed(
266-
summary="Failed to get USS availability",
267-
details=qe.msg,
268-
query_timestamps=qe.query_timestamps,
269-
)
270-
return
222+
availability, version = get_uss_availability(
223+
self, dss, uss_id, Scope.StrategicCoordination
224+
)
271225

272226
with self.check(
273227
"USS Availability is consistent across every DSS instance", participants
274228
) as check:
275-
if availability.status.availability != expected_availability:
229+
if availability != expected_availability:
276230
check.record_failed(
277231
summary="USS availability not as expected on secondary DSS",
278-
details=f"Expected {expected_availability}, got {availability.status.availability}",
232+
details=f"Expected {expected_availability}, got {availability}",
279233
)
280234

281235
with self.check(
282236
"USS Availability version is consistent across every DSS instance",
283237
participants,
284238
) as check:
285-
if availability.version != expected_version:
239+
if version != expected_version:
286240
check.record_failed(
287241
summary="USS availability version not as expected on secondary DSS",
288-
details=f"Expected {expected_version}, got {availability.version}",
242+
details=f"Expected {expected_version}, got {version}",
289243
)
290244

291245
def _query_and_expect_on_secondaries(

monitoring/uss_qualifier/scenarios/astm/utm/dss/uss_availability_simple.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Verifies the behavior of a DSS for simple interactions pertaining to USS availab
1212

1313
### client_identity
1414

15-
[`ClientIdentityResource`](../../../../resources/communications/client_identity.py) the client identity that will be used to report the availability status.
15+
[`ClientIdentityResource`](../../../../resources/communications/client_identity.py) the client identity with the `utm.availability_arbitration` scope that will be used to report the availability status.
1616

1717
## Setup test case
1818

monitoring/uss_qualifier/scenarios/astm/utm/dss/uss_availability_simple.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from uas_standards.astm.f3548.v21.api import UssAvailabilityState
12
from uas_standards.astm.f3548.v21.constants import Scope
23

34
from monitoring.monitorlib.fetch import QueryError
@@ -73,7 +74,7 @@ def _step_attempt_update_missing_version(self):
7374
try:
7475
_, q = self._dss.set_uss_availability(
7576
self._uss_id,
76-
False,
77+
UssAvailabilityState.Down,
7778
"",
7879
)
7980
self.record_query(q)
@@ -105,7 +106,7 @@ def _step_attempt_update_incorrect_version(self):
105106
try:
106107
_, q = self._dss.set_uss_availability(
107108
self._uss_id,
108-
False,
109+
UssAvailabilityState.Down,
109110
"ThisIsAnIncorrectVersion",
110111
)
111112
self.record_query(q)

monitoring/uss_qualifier/scenarios/astm/utm/off_nominal_planning/down_uss.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from uas_standards.astm.f3548.v21.api import (
33
OperationalIntentReference,
44
OperationalIntentState,
5+
UssAvailabilityState,
56
)
67
from uas_standards.astm.f3548.v21.constants import Scope
78

@@ -319,7 +320,7 @@ def cleanup(self):
319320
try:
320321
availability_version, avail_query = self.dss.set_uss_availability(
321322
self.uss_qualifier_sub,
322-
True,
323+
UssAvailabilityState.Normal,
323324
)
324325
self.record_query(avail_query)
325326
except QueryError as e:

monitoring/uss_qualifier/scenarios/astm/utm/set_uss_available.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ This step sets the USS availability to 'Available' at the DSS.
44

55
See `set_uss_available` in [test_steps.py](test_steps.py).
66

7-
## 🛑 USS availability successfully set to 'Available' check
8-
**[astm.f3548.v21.DSS0100,1](../../../requirements/astm/f3548/v21.md)**
7+
## [Availability can be read](./dss/fragments/availability/read.md)
8+
9+
## [Availability can be updated](./dss/fragments/availability/update.md)

0 commit comments

Comments
 (0)