Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Mar 20, 2024
1 parent 6e4bd13 commit 841fd38
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion monitoring/prober/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def wrapper_default_scope(*args, **kwargs):
resource_type_code_descriptions: Dict[ResourceType, str] = {}


# Next code: 383
# Next code: 381
def register_resource_type(code: int, description: str) -> ResourceType:
"""Register that the specified code refers to the described resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AuthenticationValidation(TestScenario):
"""

SUB_TYPE = register_resource_type(
382, "Subscription, Operational Entity Id, Constraint"
380, "Subscription, Operational Entity Id, Constraint"
)

# Reuse the same ID for every type of entity.
Expand Down Expand Up @@ -213,7 +213,7 @@ def _ensure_test_entities_dont_exist(self):
query = qe.queries[0]
check.record_failed(
summary=f"Could not query OIR {self._test_id}",
details=f"When attempting to query OIR {self._test_id} from the DSS, received {query.response.status_code}: {qe.msg}",
details=f"When attempting to query OIR {self._test_id} from the DSS, received {query.response.status_code}: {qe}",
query_timestamps=[query.request.timestamp],
)

Expand All @@ -231,7 +231,6 @@ def _ensure_test_entities_dont_exist(self):
details=f"When attempting to remove op intent reference {self._test_id} from the DSS, received {query.status_code}: {qe.msg}",
query_timestamps=[query.request.timestamp],
)
self._dss.delete_op_intent(oir.id, oir.ovn)

test_step_fragments.cleanup_sub(self, self._dss, self._test_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _verify_oir_creation(self):
) as check:
if no_scope_q.status_code != 401:
check.record_failed(
summary=f"Expected 403, got {no_scope_q.status_code}",
summary=f"Expected 401, got {no_scope_q.status_code}",
query_timestamps=[no_scope_q.request.timestamp],
)
self._sanity_check_oir_not_created(check, no_scope_q)
Expand Down Expand Up @@ -171,9 +171,18 @@ def _verify_oir_creation(self):
query_timestamps=[valid_q.request.timestamp],
)

oir_resp = ImplicitDict.parse(
valid_q.response.json, ChangeOperationalIntentReferenceResponse
)
# TODO use fragment.
try:
oir_resp = ImplicitDict.parse(
valid_q.response.json, ChangeOperationalIntentReferenceResponse
)
except ValueError as e:
check.record_failed(
summary="Could not parse the response body",
details=f"Failed to parse the response body as a ChangeOperationalIntentReferenceResponse: {e}",
query_timestamps=[valid_q.request.timestamp],
)
return

# Save the current OIR
self._current_oir = oir_resp.operational_intent_reference
Expand Down Expand Up @@ -220,7 +229,7 @@ def _verify_oir_get(self):
) as check:
if query_missing_scope.status_code != 401:
check.record_failed(
summary=f"Expected 403, got {query_missing_scope.status_code}",
summary=f"Expected 401, got {query_missing_scope.status_code}",
query_timestamps=[query_missing_scope.request.timestamp],
)

Expand Down Expand Up @@ -332,7 +341,7 @@ def _verify_oir_mutation(self):
if valid_q.status_code != 200:
check.record_failed(
summary=f"Expected 200, got {valid_q.status_code}",
details=f"Mutation is expected to have succeeded, but got status {valid_q.status_code} with body {valid_q.response.json} instead",
details=f"Mutation is expected to have succeeded, but got status {valid_q.status_code} with error {valid_q.error_message} instead",
query_timestamps=[valid_q.request.timestamp],
)

Expand Down Expand Up @@ -455,7 +464,7 @@ def _verify_oir_search(self):
) as check:
if no_scope_q.status_code != 401:
check.record_failed(
summary=f"Expected 403, got {no_scope_q.status_code}",
summary=f"Expected 401, got {no_scope_q.status_code}",
query_timestamps=[no_scope_q.request.timestamp],
)

Expand Down Expand Up @@ -493,11 +502,8 @@ def _sanity_check_oir_not_created(
_, sanity_check = self._dss.get_op_intent_reference(self._test_id)
self._scenario.record_query(sanity_check)
except QueryError as qe:
for q in qe.queries:
self._scenario.record_query(q)
if qe.queries[0].response.status_code == 404:
pass # All is good
else:
self._scenario.record_queries(qe.queries)
if qe.queries[0].response.status_code != 404:
check.record_failed(
summary="OIR was created by an unauthorized request.",
details="The Operational Intent Reference should not have been created, as the creation attempt was not authenticated.",
Expand All @@ -523,17 +529,17 @@ def _sanity_check_oir_not_updated(
):
check.record_failed(
summary="OIR was updated by an unauthorized request.",
details="The Operational Intent Reference should not have been updated, as the update attempt was not authenticated.",
details=f"The Operational Intent Reference with id {self._test_id} should not have been updated, as the update attempt was not authenticated.",
query_timestamps=[
creation_q.request.timestamp,
sanity_check.request.timestamp,
],
)
except QueryError as qe:
for q in qe.queries:
self._scenario.record_query(q)
self._scenario.record_queries(qe.queries)
check.record_failed(
summary="Could not fetch OIR to confirm it has not been mutated",
details=f"The Operational Intent Reference with id {self._test_id} could not be fetched to confirm it has not been mutated: {qe}",
query_timestamps=[
creation_q.request.timestamp,
qe.queries[0].request.timestamp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def cleanup_sub(
if existing_sub.status_code not in [200, 404]:
check.record_failed(
summary=f"Could not query subscription {sub_id}",
details=f"When attempting to query subscription {sub_id} from the DSS, received {existing_sub.status_code} with body {existing_sub.response.json}",
details=f"When attempting to query subscription {sub_id} from the DSS, received {existing_sub.status_code} with body {existing_sub.error_message}",
query_timestamps=[existing_sub.request.timestamp],
)

Expand All @@ -64,7 +64,7 @@ def cleanup_sub(
if deleted_sub.status_code != 200:
check.record_failed(
summary=f"Could not delete subscription {sub_id}",
details=f"When attempting to delete subscription {sub_id} from the DSS, received {deleted_sub.status_code} with body {deleted_sub.response.json}",
details=f"When attempting to delete subscription {sub_id} from the DSS, received {deleted_sub.status_code} with body {deleted_sub.error_message}",
query_timestamps=[deleted_sub.request.timestamp],
)

Expand Down

0 comments on commit 841fd38

Please sign in to comment.