Skip to content

Commit d93e480

Browse files
authored
tests, net, bridge-marker: Use 'wait_for_condition' resource method (RedHatQE#2535)
##### What this PR does / why we need it: Use the existing 'wait_for_condition' to query for a specific condition. Drop local implementation of condition parsing. * Depends on enhanced 'wait_for_condition' method from the wrapper, in which the 'reason' and 'message' arguments are available. ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: Depends on: RedHatQE/openshift-python-wrapper#2544 ##### jira-ticket: <!-- full-ticket-url needs to be provided. This would add a link to the pull request to the jira and close it when the pull request is merged If the task is not tracked by a Jira ticket, just write "NONE". --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Updated bridge marker tests to replace a dedicated helper with direct condition checks and an explicit short timeout, improving reliability and clarity when asserting scheduling failures due to insufficient bridge resources. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Edward Haas <edwardh@redhat.com>
1 parent de90553 commit d93e480

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

tests/network/general/test_bridge_marker.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,6 @@ def non_homogenous_bridges(worker_node1, worker_node2):
127127
yield bridgemarker2_ncp, bridgemarker3_ncp
128128

129129

130-
def _assert_failure_reason_is_bridge_missing(vmi, bridge):
131-
requested_condition = "PodScheduled"
132-
133-
# Store the list of conditions, to make sure that if an exception is encountered, it is aligned with the conditions
134-
# we check.
135-
conditions = vmi.instance.status.conditions
136-
for cond in conditions:
137-
if cond.type == requested_condition:
138-
assert cond.status == "False"
139-
assert cond.reason == "Unschedulable"
140-
assert f"Insufficient {bridge.resource_name}" in cond.message
141-
return
142-
pytest.fail(f"VMI {vmi.name} doesn't report {requested_condition}. Reported conditions:{conditions}")
143-
144-
145130
@pytest.mark.sno
146131
@pytest.mark.polarion("CNV-2234")
147132
@pytest.mark.s390x
@@ -151,9 +136,12 @@ def test_bridge_marker_no_device(bridge_marker_bridge_network, bridge_attached_v
151136
bridge_attached_vmi_for_bridge_marker_no_device.wait_until_running(timeout=_VM_NOT_RUNNING_TIMEOUT, logs=False)
152137

153138
# validate the exact reason for VMI startup failure is missing bridge
154-
_assert_failure_reason_is_bridge_missing(
155-
vmi=bridge_attached_vmi_for_bridge_marker_no_device,
156-
bridge=bridge_marker_bridge_network,
139+
bridge_attached_vmi_for_bridge_marker_no_device.wait_for_condition(
140+
condition="PodScheduled",
141+
status="False",
142+
reason="Unschedulable",
143+
message=f"Insufficient {bridge_marker_bridge_network.resource_name}",
144+
timeout=2,
157145
)
158146

159147

@@ -180,4 +168,10 @@ def test_bridge_marker_devices_exist_on_different_nodes(
180168

181169
# validate the exact reason for VMI startup failure is missing bridge
182170
for bridge in bridge_networks:
183-
_assert_failure_reason_is_bridge_missing(vmi=multi_bridge_attached_vmi, bridge=bridge)
171+
multi_bridge_attached_vmi.wait_for_condition(
172+
condition="PodScheduled",
173+
status="False",
174+
reason="Unschedulable",
175+
message=f"Insufficient {bridge.resource_name}",
176+
timeout=2,
177+
)

0 commit comments

Comments
 (0)