Skip to content

Commit 13344b3

Browse files
authored
[uss_qualifier] factorize uss availability fragment (#1164)
1 parent 85c6eb4 commit 13344b3

File tree

11 files changed

+185
-269
lines changed

11 files changed

+185
-269
lines changed

.basedpyright/baseline.json

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -21683,93 +21683,13 @@
2168321683
"lineCount": 1
2168421684
}
2168521685
},
21686-
{
21687-
"code": "reportPossiblyUnboundVariable",
21688-
"range": {
21689-
"startColumn": 11,
21690-
"endColumn": 31,
21691-
"lineCount": 1
21692-
}
21693-
},
21694-
{
21695-
"code": "reportInvalidTypeVarUse",
21696-
"range": {
21697-
"startColumn": 14,
21698-
"endColumn": 30,
21699-
"lineCount": 1
21700-
}
21701-
},
21702-
{
21703-
"code": "reportPossiblyUnboundVariable",
21704-
"range": {
21705-
"startColumn": 11,
21706-
"endColumn": 31,
21707-
"lineCount": 1
21708-
}
21709-
},
2171021686
{
2171121687
"code": "reportInvalidTypeVarUse",
2171221688
"range": {
2171321689
"startColumn": 14,
2171421690
"endColumn": 30,
2171521691
"lineCount": 1
2171621692
}
21717-
},
21718-
{
21719-
"code": "reportOptionalMemberAccess",
21720-
"range": {
21721-
"startColumn": 59,
21722-
"endColumn": 70,
21723-
"lineCount": 1
21724-
}
21725-
},
21726-
{
21727-
"code": "reportOptionalMemberAccess",
21728-
"range": {
21729-
"startColumn": 47,
21730-
"endColumn": 54,
21731-
"lineCount": 1
21732-
}
21733-
},
21734-
{
21735-
"code": "reportPossiblyUnboundVariable",
21736-
"range": {
21737-
"startColumn": 15,
21738-
"endColumn": 24,
21739-
"lineCount": 1
21740-
}
21741-
},
21742-
{
21743-
"code": "reportOptionalMemberAccess",
21744-
"range": {
21745-
"startColumn": 59,
21746-
"endColumn": 70,
21747-
"lineCount": 1
21748-
}
21749-
},
21750-
{
21751-
"code": "reportOptionalMemberAccess",
21752-
"range": {
21753-
"startColumn": 47,
21754-
"endColumn": 54,
21755-
"lineCount": 1
21756-
}
21757-
},
21758-
{
21759-
"code": "reportReturnType",
21760-
"range": {
21761-
"startColumn": 11,
21762-
"endColumn": 20,
21763-
"lineCount": 1
21764-
}
21765-
},
21766-
{
21767-
"code": "reportPossiblyUnboundVariable",
21768-
"range": {
21769-
"startColumn": 11,
21770-
"endColumn": 20,
21771-
"lineCount": 1
21772-
}
2177321693
}
2177421694
],
2177521695
"./monitoring/uss_qualifier/scenarios/astm/utm/versioning/evaluate_system_versions.py": [

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:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This fragment contains the steps for the USS Availability synchronization 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)**.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Make report to DSS test step fragment
22
This step makes a report to the DSS.
33

4-
See `make_dss_report` in [test_steps.py](test_steps.py).
4+
See `make_dss_report` in [test_steps_fragments.py](../../test_step_fragments.py).
55

66
## 🛑 DSS report successfully submitted check
7-
If the submission of the report to the DSS does not succeed, this check will fail per **[astm.f3548.v21.DSS0100,2](../../../requirements/astm/f3548/v21.md)**.
7+
If the submission of the report to the DSS does not succeed, this check will fail per **[astm.f3548.v21.DSS0100,2](../../../../../../requirements/astm/f3548/v21.md)**.
88

99
## ⚠️ DSS returned a valid report ID check
10-
If the ID returned by the DSS is not present or is empty, this check will fail per **[astm.f3548.v21.DSS0100,2](../../../requirements/astm/f3548/v21.md)**.
10+
If the ID returned by the DSS is not present or is empty, this check will fail per **[astm.f3548.v21.DSS0100,2](../../../../../../requirements/astm/f3548/v21.md)**.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ A dummy `getOperationalIntentReference` query is made to a non-existent DSS in o
1717

1818
### Make valid DSS report test step
1919

20-
#### [Make report to DSS](../make_dss_report.md)
20+
#### [Make report to DSS](./fragments/report/report.md)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
from monitoring.monitorlib.fetch import QueryType, query_and_describe
77
from monitoring.monitorlib.testing import make_fake_url
88
from monitoring.uss_qualifier.resources.astm.f3548.v21.dss import DSSInstanceResource
9-
from monitoring.uss_qualifier.scenarios.astm.utm.test_steps import make_dss_report
9+
from monitoring.uss_qualifier.scenarios.astm.utm.dss.test_step_fragments import (
10+
make_dss_report,
11+
)
1012
from monitoring.uss_qualifier.scenarios.scenario import (
1113
TestScenario,
1214
)
@@ -58,5 +60,6 @@ def gen_record() -> ExchangeRecord:
5860
self.begin_test_step("Make valid DSS report")
5961
dummy_record = gen_record()
6062
report_id = make_dss_report(self, self._dss, dummy_record)
61-
self.record_note(f"{self._dss.participant_id}/report_id", report_id)
63+
if report_id:
64+
self.record_note(f"{self._dss.participant_id}/report_id", report_id)
6265
self.end_test_step()

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

Lines changed: 37 additions & 84 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.dss.test_step_fragments 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,55 +149,31 @@ 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, UssAvailabilityState.Unknown, 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, UssAvailabilityState.Down, 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, UssAvailabilityState.Normal, 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
"""
@@ -202,27 +182,13 @@ def _ensure_test_uss_availability_unknown(self, check_consistency: bool = True):
202182
We want to both start and end this scenario with this state.
203183
"""
204184

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
185+
availability, version = get_uss_availability(
186+
self, self._dss, self._uss_id, Scope.AvailabilityArbitration
187+
)
188+
self._current_version = version
223189

224190
# If the state is not currently unknown, we set it to unknown
225-
if availability.status.availability != UssAvailabilityState.Unknown:
191+
if availability != UssAvailabilityState.Unknown:
226192
with self.check("USS Availability can be set to Unknown") as check:
227193
try:
228194
self._current_version, q = self._dss.set_uss_availability(
@@ -254,40 +220,27 @@ def _query_and_expect_on_secondary(
254220
expected_availability: UssAvailabilityState,
255221
expected_version: str,
256222
):
257-
with self.check(
258-
"USS Availability can be requested", dss.participant_id
259-
) as check:
260-
try:
261-
availability, q = dss.get_uss_availability(
262-
uss_id, Scope.StrategicCoordination
263-
)
264-
self.record_query(q)
265-
except QueryError as qe:
266-
self.record_queries(qe.queries)
267-
check.record_failed(
268-
summary="Failed to get USS availability",
269-
details=qe.msg,
270-
query_timestamps=qe.query_timestamps,
271-
)
272-
return
223+
availability, version = get_uss_availability(
224+
self, dss, uss_id, Scope.StrategicCoordination
225+
)
273226

274227
with self.check(
275228
"USS Availability is consistent across every DSS instance", participants
276229
) as check:
277-
if availability.status.availability != expected_availability:
230+
if availability != expected_availability:
278231
check.record_failed(
279232
summary="USS availability not as expected on secondary DSS",
280-
details=f"Expected {expected_availability}, got {availability.status.availability}",
233+
details=f"Expected {expected_availability}, got {availability}",
281234
)
282235

283236
with self.check(
284237
"USS Availability version is consistent across every DSS instance",
285238
participants,
286239
) as check:
287-
if availability.version != expected_version:
240+
if version != expected_version:
288241
check.record_failed(
289242
summary="USS availability version not as expected on secondary DSS",
290-
details=f"Expected {expected_version}, got {availability.version}",
243+
details=f"Expected {expected_version}, got {version}",
291244
)
292245

293246
def _query_and_expect_on_secondaries(

0 commit comments

Comments
 (0)