Skip to content

Commit dd0fd46

Browse files
committed
[uss_qualifier] constraints sync: verify secondary DSS instances are clean
1 parent 83ac485 commit dd0fd46

File tree

4 files changed

+60
-10
lines changed

4 files changed

+60
-10
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Verify secondary DSS contains no CRs with a test ID test step fragment
2+
3+
Ensures that a secondary DSS is ready to be used for testing by confirming that no CR bearing an ID used for testing exists on it.
4+
5+
## 🛑 Constraint references can be queried by ID check
6+
7+
If an existing constraint reference cannot directly be queried by its ID, or if for a non-existing one the DSS replies with a status code different than 404,
8+
the DSS implementation is in violation of **[astm.f3548.v21.DSS0005,3](../../../../../../requirements/astm/f3548/v21.md)**.
9+
10+
## 🛑 Constraint reference with test ID does not exist check
11+
12+
If a CR that was deleted from the primary DSS can still be found on a secondary DSS, either one of them may be improperly pooled
13+
and in violation of **[astm.f3548.v21.DSS0020](../../../../../../requirements/astm/f3548/v21.md)**.
14+

monitoring/uss_qualifier/scenarios/astm/utm/dss/synchronization/constraint_ref_synchronization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ are properly propagated to every other DSS instance participating in the deploym
2929

3030
## Setup test case
3131

32-
### Ensure clean workspace test step
32+
### [Ensure clean workspace test step](../clean_workspace_constraints.md)
3333

34-
#### [Clean any existing constraint references with known test IDs](../clean_workspace_constraints.md)
34+
### [Verify secondary DSS instances are clean test step](../fragments/cr/verify_clean_secondary_workspace.md)
3535

3636
## CR synchronization test case
3737

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ def _setup_case(self):
176176
time_end=datetime.now() + timedelta(minutes=20),
177177
)
178178
self.begin_test_step("Ensure clean workspace")
179-
self._ensure_clean_workspace_step()
179+
self._ensure_clean_primary_workspace_step()
180180
self.end_test_step()
181181
self.end_test_case()
182182

183-
def _ensure_clean_workspace_step(self):
183+
def _ensure_clean_primary_workspace_step(self):
184184
# Delete any active CRs we might own
185185
test_step_fragments.cleanup_active_constraint_refs(
186186
self,
@@ -192,6 +192,13 @@ def _ensure_clean_workspace_step(self):
192192
# Make sure the CR ID we are going to use is available
193193
test_step_fragments.cleanup_constraint_ref(self, self._dss, self._cr_id)
194194

195+
def _verify_clean_secondaries_step(self):
196+
self.begin_test_step("Verify secondary DSS instances are clean")
197+
for dss in self._secondary_dss_instances:
198+
test_step_fragments.verify_constraint_does_not_exist(self, dss, self._cr_id)
199+
200+
self.end_test_step()
201+
195202
def _create_cr_with_params(self, creation_params: PutConstraintReferenceParameters):
196203
with self.check(
197204
"Create constraint reference query succeeds", [self._primary_pid]
@@ -583,5 +590,5 @@ def _confirm_secondary_has_no_oir(self, secondary_dss: DSSInstance):
583590

584591
def cleanup(self):
585592
self.begin_cleanup()
586-
self._ensure_clean_workspace_step()
593+
self._ensure_clean_primary_workspace_step()
587594
self.end_cleanup()

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

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,19 @@ def verify_op_intent_does_not_exist(
273273

274274

275275
def cleanup_constraint_ref(
276-
scenario: TestScenarioType, dss: DSSInstance, cr_id: EntityID
277-
) -> None:
276+
scenario: TestScenarioType,
277+
dss: DSSInstance,
278+
cr_id: EntityID,
279+
delete_if_exists: bool = False,
280+
) -> bool:
278281
"""
279282
Remove the specified constraint reference from the DSS, if it exists.
280283
281284
This function implements some of the test step fragment described in clean_workspace.md:
282285
- Constraint references can be queried by ID
283286
- Constraint reference removed
287+
288+
:return: True if the constraint reference was found to exist, False if no constraint reference was found.
284289
"""
285290

286291
with scenario.check(
@@ -289,6 +294,13 @@ def cleanup_constraint_ref(
289294
try:
290295
cr, q = dss.get_constraint_ref(cr_id)
291296
scenario.record_query(q)
297+
if cr.ovn is None:
298+
check.record_failed(
299+
summary=f"CR {cr_id} is missing OVN",
300+
details="The CR retrieved from the DSS did not include an OVN, despite the CR being owned by uss_qualifier. The scenario cannot proceed.",
301+
query_timestamps=[q.request.timestamp],
302+
)
303+
return False
292304
except fetch.QueryError as e:
293305
scenario.record_queries(e.queries)
294306
if e.cause_status_code != 404:
@@ -297,7 +309,24 @@ def cleanup_constraint_ref(
297309
details=e.msg,
298310
query_timestamps=e.query_timestamps,
299311
)
300-
else:
301-
return
312+
return False
313+
314+
if delete_if_exists:
315+
remove_constraint_ref(scenario, dss, cr_id, cr.ovn)
302316

303-
remove_constraint_ref(scenario, dss, cr_id, cr.ovn)
317+
return True
318+
319+
320+
def verify_constraint_does_not_exist(
321+
scenario: TestScenarioType, dss: DSSInstance, cr_id: EntityID
322+
):
323+
cr_found = cleanup_constraint_ref(scenario, dss, cr_id, delete_if_exists=False)
324+
with scenario.check(
325+
"constraint reference with test ID does not exist",
326+
dss.participant_id,
327+
) as check:
328+
if cr_found:
329+
check.record_failed(
330+
summary=f"Constraint intent reference {cr_id} was still found on DSS {dss.participant_id}",
331+
details=f"Expected constraint reference {cr_id} to not be found on secondary DSS because it was not present on, or has been removed, from the primary DSS, but it was returned.",
332+
)

0 commit comments

Comments
 (0)