Skip to content

Commit 8a8ea6f

Browse files
authored
Storage: added stop condition to storage checkups tests (#2741)
##### Short description: Added stop_condition (Failed) to positive storage checkups tests, to avoid waiting for the expected condition until the full timeout expired, in case the checkup job had already reached Failed state. ##### More details: This PR depends on RedHatQE/openshift-python-wrapper#2585 PR. ##### What this PR does / why we need it: ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### 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** * Improved test job-wait logic to better handle stop conditions for failed jobs. * Expanded exception handling to catch additional condition-related errors during waits. * Enhanced timeout/error messages to include the underlying error text for clearer diagnostics. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent f923b66 commit 8a8ea6f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/storage/checkups/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from ocp_resources.config_map import ConfigMap
55
from ocp_resources.data_import_cron import DataImportCron
66
from ocp_resources.data_source import DataSource
7+
from ocp_resources.exceptions import ConditionError
78
from ocp_resources.job import Job
89
from ocp_resources.resource import ResourceEditor
910
from ocp_resources.role import Role
@@ -146,13 +147,15 @@ def checkup_job(
146147
containers=containers,
147148
client=admin_client,
148149
) as job:
150+
stop_condition = job.Status.FAILED if request.param["expected_condition"] == job.Status.COMPLETE else None
149151
try:
150152
job.wait_for_condition(
151153
condition=request.param["expected_condition"],
152154
status=job.Condition.Status.TRUE,
153155
timeout=TIMEOUT_10MIN,
156+
stop_condition=stop_condition,
154157
)
155-
except TimeoutExpiredError:
158+
except (TimeoutExpiredError, ConditionError) as e:
156159
job_pods = get_pods(
157160
dyn_client=admin_client,
158161
namespace=checkups_namespace,
@@ -163,6 +166,7 @@ def checkup_job(
163166

164167
job_pod = job_pods[0]
165168
raise StorageCheckupConditionTimeoutExpiredError(
169+
f"Error while waiting for the job condition: {e}\n"
166170
f"{job.name} job failed. Log of {job_pod.name} pod:\n{job_pod.log()}"
167171
)
168172

0 commit comments

Comments
 (0)