Skip to content

Commit ab3b59f

Browse files
authored
[uss_qualifier] dss_wrapper's handle_query_result function is made public (#335)
1 parent 23abfd1 commit ab3b59f

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _isa_missing_outline(self, create_isa_url: str, json_body: Dict[str, Any]):
256256

257257
rid_query.set_participant_id(self._dss_wrapper.participant_id)
258258

259-
self._dss_wrapper._handle_query_result(
259+
self._dss_wrapper.handle_query_result(
260260
check=check,
261261
q=rid_query,
262262
fail_msg="ISA Creation with missing outline has unexpected result code",
@@ -290,7 +290,7 @@ def _isa_missing_volume(self, create_isa_url: str, json_body: Dict[str, Any]):
290290

291291
rid_query.set_participant_id(self._dss_wrapper.participant_id)
292292

293-
self._dss_wrapper._handle_query_result(
293+
self._dss_wrapper.handle_query_result(
294294
check=check,
295295
q=rid_query,
296296
fail_msg="ISA Creation with missing outline has unexpected result code",
@@ -319,7 +319,7 @@ def _isa_missing_extents(self, create_isa_url: str, json_body: Dict[str, Any]):
319319
else:
320320
raise ValueError(f"Unknown RID version: {self._dss.rid_version}")
321321

322-
self._dss_wrapper._handle_query_result(
322+
self._dss_wrapper.handle_query_result(
323323
check=check,
324324
q=rid_query,
325325
fail_msg="ISA Creation with missing outline has unexpected result code",

monitoring/uss_qualifier/scenarios/astm/netrid/dss_wrapper.py

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _handle_query_error(
7676
query_timestamps=[q.request.timestamp for q in e.queries],
7777
)
7878

79-
def _handle_query_result(
79+
def handle_query_result(
8080
self,
8181
check: PendingCheck,
8282
q: RIDQuery,
@@ -86,7 +86,23 @@ def _handle_query_result(
8686
fail_details: Optional[str] = None,
8787
):
8888
"""
89-
:param required_status_code: one of those status code is expected, overrides the success check
89+
Handle the result of the query, based on the expected result codes versus the actual one,
90+
and fail the specified check accordingly if the query's HTTP response code is not a success or, if specified,
91+
it is not present in `required_status_code`.
92+
93+
Note that this won't check anything about the response payloads: this is left to the discretion of the caller.
94+
95+
The passed query will be properly recorded in the scenario and in case of check failure, its timestamp will
96+
be associated with the check.
97+
98+
Additionally, upon failure, the participant_id of the underlying DSS is set as the check's participants.
99+
100+
:param check: the check to fail if q is not successful (or, when applicable, its response code is not in required_status_code)
101+
:param q: the query to check
102+
:param fail_msg: the message to use when failing the check
103+
:param required_status_code: the set of status codes that are considered successful. If this is None then success is defined by `q.success`
104+
:param severity: the severity of the check failure
105+
:param fail_details: the details passed to check.record_fail
90106
"""
91107
self._scenario.record_query(q.query)
92108
if (required_status_code is None and not q.success) or (
@@ -127,7 +143,7 @@ def search_isas(
127143
session=self._dss.client,
128144
participant_id=self._dss.participant_id,
129145
)
130-
self._handle_query_result(
146+
self.handle_query_result(
131147
main_check,
132148
isas,
133149
f"Failed to search ISAs in {area} from {start_time} to {end_time}",
@@ -178,7 +194,7 @@ def search_isas_expect_response_code(
178194
participant_id=self._dss.participant_id,
179195
)
180196

181-
self._handle_query_result(
197+
self.handle_query_result(
182198
check=main_check,
183199
q=isas,
184200
required_status_code=expected_error_codes,
@@ -208,7 +224,7 @@ def get_isa(
208224
participant_id=self._dss.participant_id,
209225
)
210226

211-
self._handle_query_result(check, isa, f"Failed to get ISA {isa_id}")
227+
self.handle_query_result(check, isa, f"Failed to get ISA {isa_id}")
212228

213229
if isa_id != isa.isa.id:
214230
check.record_failed(
@@ -247,7 +263,7 @@ def get_isa_expect_response_code(
247263
participant_id=self._dss.participant_id,
248264
)
249265

250-
self._handle_query_result(
266+
self.handle_query_result(
251267
check=check,
252268
q=isa,
253269
required_status_code=expected_error_codes,
@@ -284,7 +300,7 @@ def put_isa_expect_response_code(
284300
participant_id=self._dss.participant_id,
285301
)
286302

287-
self._handle_query_result(
303+
self.handle_query_result(
288304
check=check,
289305
q=mutated_isa.dss_query,
290306
fail_msg="ISA Put succeeded when expecting a failure",
@@ -327,7 +343,7 @@ def put_isa(
327343
utm_client=self._dss.client,
328344
participant_id=self._dss.participant_id,
329345
)
330-
self._handle_query_result(
346+
self.handle_query_result(
331347
main_check, mutated_isa.dss_query, f"Failed to insert ISA {isa_id}"
332348
)
333349
for notification_query in mutated_isa.notifications.values():
@@ -458,7 +474,7 @@ def del_isa(
458474
utm_client=self._dss.client,
459475
participant_id=self._dss.participant_id,
460476
)
461-
self._handle_query_result(
477+
self.handle_query_result(
462478
main_check, del_isa.dss_query, f"Failed to delete ISA {isa_id}"
463479
)
464480
for notification_query in del_isa.notifications.values():
@@ -544,7 +560,7 @@ def del_isa_expect_response_code(
544560
participant_id=self._dss.participant_id,
545561
)
546562

547-
self._handle_query_result(
563+
self.handle_query_result(
548564
check=main_check,
549565
q=del_isa.dss_query,
550566
required_status_code=expected_error_codes,
@@ -572,7 +588,7 @@ def cleanup_isa(
572588
participant_id=self._dss.participant_id,
573589
)
574590

575-
self._handle_query_result(
591+
self.handle_query_result(
576592
check, isa, f"Failed to get ISA {isa_id}", {404, 200}, Severity.Medium
577593
)
578594

@@ -587,7 +603,7 @@ def cleanup_isa(
587603
participant_id=self._dss.participant_id,
588604
)
589605

590-
self._handle_query_result(
606+
self.handle_query_result(
591607
check,
592608
del_isa.dss_query,
593609
f"Failed to delete ISA {isa_id}",
@@ -621,7 +637,7 @@ def search_subs_expect_response_code(
621637
participant_id=self._dss.participant_id,
622638
)
623639

624-
self._handle_query_result(
640+
self.handle_query_result(
625641
check=check,
626642
q=subs,
627643
fail_msg=f"Search for subscriptions in area {area} failed to yield a result code in {expected_codes}",
@@ -654,7 +670,7 @@ def search_subs(
654670
participant_id=self._dss.participant_id,
655671
)
656672

657-
self._handle_query_result(
673+
self.handle_query_result(
658674
check, subs, f"Failed to search subscriptions in {area}"
659675
)
660676
return subs
@@ -683,7 +699,7 @@ def get_sub_expect_response_code(
683699
participant_id=self._dss.participant_id,
684700
)
685701

686-
self._handle_query_result(
702+
self.handle_query_result(
687703
check=check,
688704
q=sub,
689705
fail_msg=f"The request to get subscription with ID {sub_id} yielded a response code that wasn't in {expected_response_codes}",
@@ -718,9 +734,7 @@ def get_sub(
718734
participant_id=self._dss.participant_id,
719735
)
720736

721-
self._handle_query_result(
722-
check, sub, f"Failed to get subscription {sub_id}"
723-
)
737+
self.handle_query_result(check, sub, f"Failed to get subscription {sub_id}")
724738

725739
if sub_id != sub.subscription.id:
726740
check.record_failed(
@@ -758,7 +772,7 @@ def no_sub(
758772
participant_id=self._dss.participant_id,
759773
)
760774

761-
self._handle_query_result(
775+
self.handle_query_result(
762776
check, sub, f"Failed to get subscription {sub_id}", {404}
763777
)
764778
return
@@ -801,7 +815,7 @@ def put_sub_expect_response_code(
801815
participant_id=self._dss.participant_id,
802816
)
803817

804-
self._handle_query_result(
818+
self.handle_query_result(
805819
check=check,
806820
q=created_sub,
807821
required_status_code=expected_error_codes,
@@ -850,7 +864,7 @@ def put_sub(
850864
participant_id=self._dss.participant_id,
851865
)
852866

853-
self._handle_query_result(
867+
self.handle_query_result(
854868
check, created_sub, f"Failed to insert subscription {sub_id}"
855869
)
856870
return created_sub
@@ -883,7 +897,7 @@ def del_sub_expect_response_code(
883897
participant_id=self._dss.participant_id,
884898
)
885899

886-
self._handle_query_result(
900+
self.handle_query_result(
887901
check=check,
888902
q=del_sub,
889903
fail_msg=f"Query to delete subscription with ID {sub_id} wit not yield a response code in {expected_response_codes}",
@@ -918,7 +932,7 @@ def del_sub(
918932
participant_id=self._dss.participant_id,
919933
)
920934

921-
self._handle_query_result(
935+
self.handle_query_result(
922936
check, del_sub, f"Failed to delete subscription {sub_id}"
923937
)
924938

@@ -963,7 +977,7 @@ def cleanup_subs_in_area(
963977
participant_id=self._dss.participant_id,
964978
)
965979

966-
self._handle_query_result(
980+
self.handle_query_result(
967981
check,
968982
del_sub,
969983
f"Failed to delete subscription {sub}",
@@ -996,7 +1010,7 @@ def cleanup_sub(
9961010
participant_id=self._dss.participant_id,
9971011
)
9981012

999-
self._handle_query_result(
1013+
self.handle_query_result(
10001014
check,
10011015
sub,
10021016
f"Failed to get subscription {sub_id}",
@@ -1018,7 +1032,7 @@ def cleanup_sub(
10181032
participant_id=self._dss.participant_id,
10191033
)
10201034

1021-
self._handle_query_result(
1035+
self.handle_query_result(
10221036
check,
10231037
del_sub,
10241038
f"Failed to delete subscription {sub_id}",
@@ -1075,7 +1089,7 @@ def raw_request_with_expected_code(
10751089
else:
10761090
raise ValueError(f"Unknown RID version: {self._dss.rid_version}")
10771091

1078-
self._handle_query_result(
1092+
self.handle_query_result(
10791093
check,
10801094
rid_query,
10811095
fail_msg,

0 commit comments

Comments
 (0)