Skip to content

Commit 432e3f9

Browse files
committed
[uss_qualifier] Streamline conflict validation for all entities
1 parent bac22cb commit 432e3f9

File tree

4 files changed

+52
-65
lines changed

4 files changed

+52
-65
lines changed

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

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,17 @@ def _step_attempt_delete_missing_ovn(self):
123123
# We don't expect the reach this point:
124124
check.record_failed(
125125
summary="CR Deletion with empty OVN was not expected to succeed",
126-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {q.status_code} instead",
126+
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {q.status_code}",
127127
query_timestamps=[q.request.timestamp],
128128
)
129129
except QueryError as qe:
130130
self.record_queries(qe.queries)
131-
if qe.cause_status_code in [400, 404, 409]:
132-
# An empty OVN can be seen as:
133-
# an incorrect parameter (400), a reference to a non-existing entity (404) as well as a conflict (409)
134-
pass
135-
else:
131+
# An empty OVN can be seen as:
132+
# an incorrect parameter (400), a reference to a non-existing entity (404) as well as a conflict (409)
133+
if qe.cause_status_code not in [400, 404, 409]:
136134
check.record_failed(
137135
summary="CR Deletion with empty OVN failed for unexpected reason",
138-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {qe.cause_status_code} instead",
136+
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {qe.cause_status_code}: {qe.msg}",
139137
query_timestamps=qe.query_timestamps,
140138
)
141139

@@ -155,18 +153,16 @@ def _step_attempt_delete_incorrect_ovn(self):
155153
# We don't expect the reach this point:
156154
check.record_failed(
157155
summary="CR Deletion with incorrect OVN was not expected to succeed",
158-
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {q.status_code} instead",
156+
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {q.status_code}",
159157
query_timestamps=[q.request.timestamp],
160158
)
161159
except QueryError as qe:
162160
self.record_queries(qe.queries)
163-
if qe.cause_status_code == 409:
164-
# The spec explicitly requests a 409 response code for incorrect OVNs.
165-
pass
166-
else:
161+
# The spec explicitly requests a 409 response code for incorrect OVNs.
162+
if qe.cause_status_code != 409:
167163
check.record_failed(
168164
summary="CR Deletion with incorrect OVN failed for unexpected reason",
169-
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {qe.cause_status_code} instead",
165+
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {qe.cause_status_code}: {qe.msg}",
170166
query_timestamps=qe.query_timestamps,
171167
)
172168

@@ -193,19 +189,17 @@ def _step_attempt_mutation_missing_ovn(self):
193189
# We don't expect the reach this point:
194190
check.record_failed(
195191
summary="CR mutation with empty OVN was not expected to succeed",
196-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {q.status_code} instead",
192+
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {q.status_code}",
197193
query_timestamps=[q.request.timestamp],
198194
)
199195
except QueryError as qe:
200196
self.record_queries(qe.queries)
201-
if qe.cause_status_code in [400, 404, 409]:
202-
# An empty OVN can be seen as:
203-
# an incorrect parameter (400), a reference to a non-existing entity (404) as well as a conflict (409)
204-
pass
205-
else:
197+
# An empty OVN can be seen as:
198+
# an incorrect parameter (400), a reference to a non-existing entity (404) as well as a conflict (409)
199+
if qe.cause_status_code not in [400, 404, 409]:
206200
check.record_failed(
207201
summary="CR mutation with empty OVN failed for unexpected reason",
208-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {qe.cause_status_code} instead",
202+
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {qe.cause_status_code}: {qe.msg}",
209203
query_timestamps=qe.query_timestamps,
210204
)
211205

@@ -232,19 +226,16 @@ def _step_attempt_mutation_incorrect_ovn(self):
232226
# We don't expect the reach this point:
233227
check.record_failed(
234228
summary="CR mutation with incorrect OVN was not expected to succeed",
235-
details=f"Was expecting an HTTP 400 or 409 response because of an incorrect OVN, but got {q.status_code} instead",
229+
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {q.status_code}",
236230
query_timestamps=[q.request.timestamp],
237231
)
238232
except QueryError as qe:
239233
self.record_queries(qe.queries)
240-
if qe.cause_status_code in [400, 409]:
241-
# An empty OVN cen be seen as both an incorrect parameter as well as a conflict
242-
# because the value is incorrect: we accept both a 400 and 409 return code here.
243-
pass
244-
else:
234+
# The spec explicitly requests a 409 response code for incorrect OVNs.
235+
if qe.cause_status_code != 409:
245236
check.record_failed(
246237
summary="CR mutation with incorrect OVN failed for unexpected reason",
247-
details=f"Was expecting an HTTP 400 or 409 response because of an incorrect OVN, but got {qe.cause_status_code} instead",
238+
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {qe.cause_status_code}: {qe.msg}",
248239
query_timestamps=qe.query_timestamps,
249240
)
250241
self.end_test_step()

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ def _attempt_creation_expect_conflict(
189189
self.record_query(q)
190190
check.record_failed(
191191
summary="Operational intent reference with OVN missing in key was created",
192-
details=f"Was expecting an HTTP 409 response because of a conflict with OIR {conflicting_ids}, but got a successful response ({q.status_code}) instead",
192+
details=f"Was expecting an HTTP 409 response because of a conflict with OIR {conflicting_ids}, but got {q.status_code}",
193193
query_timestamps=[q.request.timestamp],
194194
)
195195
return
196196
except QueryError as qe:
197197
self.record_queries(qe.queries)
198-
_expect_conflict_code(check, conflicting_ids, qe.cause)
198+
_expect_conflict_code(check, conflicting_ids, qe)
199199
conflicting_query = qe.cause
200200

201201
self._validate_conflict_response(conflicting_ids, conflicting_query)
@@ -222,13 +222,13 @@ def _attempt_update_expect_conflict(
222222
self.record_query(q)
223223
check.record_failed(
224224
summary="Operational intent reference with OVN missing in key was mutated",
225-
details=f"Was expecting an HTTP 409 response because of a conflict with OIR {conflicting_ids}, but got a successful response ({q.status_code}) instead",
225+
details=f"Was expecting an HTTP 409 response because of a conflict with OIR {conflicting_ids}, but got {q.status_code}",
226226
query_timestamps=[q.request.timestamp],
227227
)
228228
return
229229
except QueryError as qe:
230230
self.record_queries(qe.queries)
231-
_expect_conflict_code(check, conflicting_ids, qe.cause)
231+
_expect_conflict_code(check, conflicting_ids, qe)
232232
conflicting_query = qe.cause
233233

234234
self._validate_conflict_response(conflicting_ids, conflicting_query)
@@ -431,11 +431,11 @@ def cleanup(self):
431431

432432

433433
def _expect_conflict_code(
434-
check: PendingCheck, conflicting_ids: list[EntityID], query: fetch.Query
434+
check: PendingCheck, conflicting_ids: list[EntityID], qe: fetch.QueryError
435435
):
436-
if query.status_code != 409:
436+
if qe.case_status_code != 409:
437437
check.record_failed(
438438
summary="OIR Creation failed for the unexpected reason",
439-
details=f"Was expecting an HTTP 409 response because of a conflict with OIR {conflicting_ids}, but got a {query.status_code} instead",
440-
query_timestamps=[query.request.timestamp],
439+
details=f"Was expecting an HTTP 409 response because of a conflict with OIR {conflicting_ids}, but got {qe.case_status_code}: {qe.msg}",
440+
query_timestamps=qe.query_timestamps,
441441
)

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

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,17 @@ def _step_attempt_delete_missing_ovn(self):
120120
# We don't expect to reach this point:
121121
check.record_failed(
122122
summary="OIR Deletion with empty OVN was not expected to succeed",
123-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {q.status_code} instead",
123+
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {q.status_code}",
124124
query_timestamps=[q.request.timestamp],
125125
)
126126
except QueryError as qe:
127127
self.record_queries(qe.queries)
128-
if qe.cause_status_code in [400, 404, 409]:
129-
# An empty OVN can be seen as:
130-
# an incorrect parameter (400), a reference to a non-existing entity (404) as well as a conflict (409)
131-
pass
132-
else:
128+
# An empty OVN can be seen as:
129+
# an incorrect parameter (400), a reference to a non-existing entity (404) as well as a conflict (409)
130+
if qe.cause_status_code not in [400, 404, 409]:
133131
check.record_failed(
134132
summary="OIR Deletion with empty OVN failed for unexpected reason",
135-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {qe.cause_status_code} instead",
133+
details=f"Was expecting an HTTP 400, 404 or 409 response because of an empty OVN, but got {qe.cause_status_code}: {qe.msg}",
136134
query_timestamps=qe.query_timestamps,
137135
)
138136

@@ -152,18 +150,16 @@ def _step_attempt_delete_incorrect_ovn(self):
152150
# We don't expect to reach this point:
153151
check.record_failed(
154152
summary="OIR Deletion with incorrect OVN was not expected to succeed",
155-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an incorrect OVN, but got {q.status_code} instead",
153+
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {q.status_code}",
156154
query_timestamps=[q.request.timestamp],
157155
)
158156
except QueryError as qe:
159157
self.record_queries(qe.queries)
160-
if qe.cause_status_code in [400, 404, 409]:
161-
# The spec explicitly requests a 409 response code for incorrect OVNs.
162-
pass
163-
else:
158+
# The spec explicitly requests a 409 response code for incorrect OVNs.
159+
if qe.cause_status_code != 409:
164160
check.record_failed(
165161
summary="OIR Deletion with incorrect OVN failed for unexpected reason",
166-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an incorrect OVN, but got {qe.cause_status_code} instead",
162+
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {qe.cause_status_code}: {qe.msg}",
167163
query_timestamps=qe.query_timestamps,
168164
)
169165

@@ -189,19 +185,17 @@ def _step_attempt_mutation_missing_ovn(self):
189185
# We don't expect to reach this point:
190186
check.record_failed(
191187
summary="OIR Mutation with missing OVN was not expected to succeed",
192-
details=f"Was expecting an HTTP 400, 404 or 409 response because of a missing OVN, but got {query.status_code} instead",
188+
details=f"Was expecting an HTTP 400, 404 or 409 response because of a missing OVN, but got {query.status_code}",
193189
query_timestamps=[query.request.timestamp],
194190
)
195191
except QueryError as qe:
196192
self.record_queries(qe.queries)
197-
if qe.cause_status_code in [400, 404, 409]:
198-
# An empty OVN can be seen as:
199-
# an incorrect parameter (400), a reference to a non-existing entity (404) as well as a conflict (409)
200-
pass
201-
else:
193+
# An empty OVN can be seen as:
194+
# an incorrect parameter (400), a reference to a non-existing entity (404) as well as a conflict (409)
195+
if qe.cause_status_code not in [400, 404, 409]:
202196
check.record_failed(
203197
summary="OIR Mutation with missing OVN failed for unexpected reason",
204-
details=f"Was expecting an HTTP 400, 404 or 409 response because of a missing OVN, but got {qe.cause_status_code} instead",
198+
details=f"Was expecting an HTTP 400, 404 or 409 response because of a missing OVN, but got {qe.cause_status_code}: {qe.msg}",
205199
query_timestamps=qe.query_timestamps,
206200
)
207201
self.end_test_step()
@@ -226,17 +220,16 @@ def _step_attempt_mutation_incorrect_ovn(self):
226220
# We don't expect to reach this point:
227221
check.record_failed(
228222
summary="OIR Mutation with incorrect OVN was not expected to succeed",
229-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an incorrect OVN, but got {query.status_code} instead",
223+
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {query.status_code}",
230224
query_timestamps=[query.request.timestamp],
231225
)
232226
except QueryError as qe:
233227
self.record_queries(qe.queries)
234-
if qe.cause_status_code in [400, 404, 409]:
235-
pass
236-
else:
228+
# The spec explicitly requests a 409 response code for incorrect OVNs.
229+
if qe.cause_status_code != 409:
237230
check.record_failed(
238231
summary="OIR Mutation with incorrect OVN failed for unexpected reason",
239-
details=f"Was expecting an HTTP 400, 404 or 409 response because of an incorrect OVN, but got {qe.cause_status_code} instead",
232+
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {qe.cause_status_code}: {qe.msg}",
240233
query_timestamps=qe.query_timestamps,
241234
)
242235

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,17 @@ def _step_attempt_update_missing_version(self):
8686
# We don't expect the reach this point:
8787
check.record_failed(
8888
summary="Set USS availability with missing version was not expected to succeed",
89-
details=f"Was expecting an HTTP 409 response because of an missing version, but got {q.status_code} instead",
89+
details=f"Was expecting an HTTP 400, 404 or 409 response because of an missing version, but got {q.status_code}",
9090
query_timestamps=[q.request.timestamp],
9191
)
9292
except QueryError as qe:
9393
self.record_queries(qe.queries)
94-
if qe.cause_status_code != 409:
94+
# An empty version can be seen as:
95+
# an incorrect parameter (400), a reference to a non-existing entity (404) as well as a conflict (409)
96+
if qe.cause_status_code not in [400, 404, 409]:
9597
check.record_failed(
9698
summary="Set USS availability with missing version failed for unexpected reason",
97-
details=f"Was expecting an HTTP 409 response because of an missing version, but got {qe.cause_status_code} instead",
99+
details=f"Was expecting an HTTP 400, 404 or 409 response because of an missing version, but got {qe.cause_status_code}: {qe.msg}",
98100
query_timestamps=qe.query_timestamps,
99101
)
100102
self.end_test_step()
@@ -115,15 +117,16 @@ def _step_attempt_update_incorrect_version(self):
115117
# We don't expect the reach this point:
116118
check.record_failed(
117119
summary="Set USS availability with incorrect version was not expected to succeed",
118-
details=f"Was expecting an HTTP 409 response because of an incorrect version, but got {q.status_code} instead",
120+
details=f"Was expecting an HTTP 409 response because of an incorrect version, but got {q.status_code}",
119121
query_timestamps=[q.request.timestamp],
120122
)
121123
except QueryError as qe:
122124
self.record_queries(qe.queries)
125+
# The spec explicitly requests a 409 response code for incorrect version.
123126
if qe.cause_status_code != 409:
124127
check.record_failed(
125128
summary="Set USS availability with incorrect version failed for unexpected reason",
126-
details=f"Was expecting an HTTP 409 response because of an incorrect version, but got {qe.cause_status_code} instead",
129+
details=f"Was expecting an HTTP 409 response because of an incorrect version, but got {qe.cause_status_code}: {qe.msg}",
127130
query_timestamps=qe.query_timestamps,
128131
)
129132
self.end_test_step()

0 commit comments

Comments
 (0)