-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a new test case for reclaim space job and cronjob on rwop pvc #10096
Conversation
Signed-off-by: Yulia Persky <[email protected]>
Signed-off-by: Yulia Persky <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR validation
Cluster Name:
Cluster Configuration:
PR Test Suite: tier1
PR Test Path: tests/functional/pv/pv_services/test_rwop_pvc.py
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master
Job UNSTABLE (some or all tests failed).
def wait_for_reclaim_space_cronjob(reclaim_space_cron_job, schedule): | ||
""" | ||
Wait for reclaim space cronjbo | ||
|
||
Args: | ||
reclaim_space_cron_job (obj): The reclaim space cron job | ||
schedule (str): Reclaim space cron job schedule | ||
|
||
Raises: | ||
UnexpectedBehaviour: In case reclaim space cron job doesn't reach the desired state | ||
""" | ||
|
||
try: | ||
for reclaim_space_cron_job_yaml in TimeoutSampler( | ||
timeout=120, sleep=5, func=reclaim_space_cron_job.get | ||
): | ||
result = reclaim_space_cron_job_yaml["spec"]["schedule"] | ||
if result == f"@{schedule}": | ||
logger.info( | ||
f"ReclaimSpaceCronJob {reclaim_space_cron_job.name} succeeded" | ||
) | ||
break | ||
else: | ||
logger.info( | ||
f"Waiting for the @{schedule} result of the ReclaimSpaceCronJob {reclaim_space_cron_job.name}. " | ||
f"Present value of result is {result}" | ||
) | ||
except TimeoutExpiredError: | ||
raise UnexpectedBehaviour( | ||
f"ReclaimSpaceJob {reclaim_space_cron_job.name} is not successful. " | ||
f"Yaml output: {reclaim_space_cron_job.get()}" | ||
) | ||
|
||
|
||
def wait_for_reclaim_space_job(reclaim_space_job): | ||
""" | ||
Wait for reclaim space cronjbo | ||
|
||
Args: | ||
reclaim_space_job (obj): The reclaim space job | ||
|
||
Raises: | ||
UnexpectedBehaviour: In case reclaim space job doesn't reach the Succeeded state | ||
""" | ||
|
||
try: | ||
for reclaim_space_job_yaml in TimeoutSampler( | ||
timeout=120, sleep=5, func=reclaim_space_job.get | ||
): | ||
result = reclaim_space_job_yaml.get("status", {}).get("result") | ||
if result == "Succeeded": | ||
logger.info(f"ReclaimSpaceJob {reclaim_space_job.name} succeeded") | ||
break | ||
else: | ||
logger.info( | ||
f"Waiting for the Succeeded result of the ReclaimSpaceJob {reclaim_space_job.name}. " | ||
f"Present value of result is {result}" | ||
) | ||
except TimeoutExpiredError: | ||
raise UnexpectedBehaviour( | ||
f"ReclaimSpaceJob {reclaim_space_job.name} is not successful. Yaml output: {reclaim_space_job.get()}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the 2 functions are almost identical. Can you club them to 1 function and call them with a parameter to distinguish between reclaim_space_cron_job_yaml and reclaim_space_job_yaml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#10111 - a Github issue was opened for addressing your comment later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these 2 methods look visually identical but the content is somewhat different, the same as a subject of "reclaim space" action, since it does not look good, and does not help in readability, I would not suggest merging them.
For reference, the one that is merged can look like:
def wait_for_reclaim_space_job(reclaim_space_job, job_type="cronjob", schedule=None):
"""
Wait for reclaim space job to reach the desired state
Args:
reclaim_space_job (obj): The reclaim space job object
job_type (str): Type of the job, either "cronjob" or "job"
schedule (str, optional): Reclaim space cron job schedule if job_type is "cronjob"
Raises:
UnexpectedBehaviour: In case reclaim space job doesn't reach the desired state
"""
try:
for reclaim_space_job_yaml in TimeoutSampler(
timeout=120, sleep=5, func=reclaim_space_job.get
):
if job_type == "cronjob":
if schedule is None:
raise ValueError("Schedule must be provided for cronjob type")
result = reclaim_space_job_yaml["spec"]["schedule"]
desired_state = f"@{schedule}"
success_message = f"ReclaimSpaceCronJob {reclaim_space_job.name} succeeded"
else:
result = reclaim_space_job_yaml.get("status", {}).get("result")
desired_state = "Succeeded"
success_message = f"ReclaimSpaceJob {reclaim_space_job.name} succeeded"
if result == desired_state:
logger.info(success_message)
break
else:
logger.info(
f"Waiting for the {desired_state} result of the {job_type} {reclaim_space_job.name}. "
f"Present value of result is {result}"
)
except TimeoutExpiredError:
raise UnexpectedBehaviour(
f"{job_type} {reclaim_space_job.name} is not successful. "
f"Yaml output: {reclaim_space_job.get()}"
)
Signed-off-by: Yulia Persky <[email protected]>
Signed-off-by: Yulia Persky <[email protected]>
#10112 - Github issue for adding Polarion ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR validation
Cluster Name:
Cluster Configuration:
PR Test Suite: tier2
PR Test Path: tests/functional/pv/pv_services/test_rwop_pvc_reclaim_space.py
Additional Test Params:
OCP VERSION: 4.16
OCS VERSION: 4.16
tested against branch: master
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: DanielOsypenko, ebenahar, jilju, ramkiperiy, ypersky1980 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…ed-hat-storage#10096) * adding new test case for reclaim space job and cronjob on rwop pvc * adding rwop reclaim space as a separate file and only for rbd Signed-off-by: Yulia Persky <[email protected]>
This PR contains the following: