-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding test automation for reclaimspace disable operation
Signed-off-by: Parag Kamble <[email protected]>
- Loading branch information
Showing
2 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
tests/functional/pv/space_reclaim/test_disable_reclaimspace_operation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import logging | ||
|
||
from ocs_ci.framework.pytest_customization.marks import green_squad | ||
from ocs_ci.ocs import constants | ||
from ocs_ci.framework.testlib import tier1 | ||
from ocs_ci.helpers.helpers import ( | ||
change_reclaimspacecronjob_state_for_pvc, | ||
get_reclaimspacecronjob_for_pvc, | ||
) | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@green_squad | ||
@tier1 | ||
class TestDisableReclaimSpaceOperation: | ||
def test_disable_reclaimspace_operation(self, multi_pvc_factory, pod_factory): | ||
"""Test to verify reclaim space Disable operation for the PVC. | ||
Steps: | ||
1. Create a PVC from the CephBlockPool and attach it to a pod. | ||
2. To disable the reclaimspace operation for the PVC, set suspend = true and change the state annotation | ||
to unmanaged. | ||
3. Verify that the reclaimspace operation is disabled for the PVC by checking that suspend = true is set. | ||
4. Re-enable the reclaimspace cronjob by removing suspend = true and changing the state annotation back | ||
to managed for each PVC. | ||
5. Verify that all reclaimspace cronjobs are enabled. | ||
""" | ||
|
||
# Create a PVC's with volume block mode | ||
pvc_objs = multi_pvc_factory( | ||
size=5, | ||
num_of_pvc=3, | ||
access_modes=[f"{constants.ACCESS_MODE_RWO}-Block"], | ||
wait_each=True, | ||
) | ||
|
||
# Create POds | ||
self.pod_objs = [] | ||
|
||
# Create pods | ||
for pvc in pvc_objs: | ||
pod_obj = pod_factory( | ||
pvc=pvc, | ||
status=constants.STATUS_RUNNING, | ||
raw_block_pv=True, | ||
) | ||
self.pod_objs.append(pod_obj) | ||
|
||
# Disable Reclaimspace operation for the PVC | ||
log.info("Changing reclaimspace cronjob status to disable for all PVC object.") | ||
for pvc in pvc_objs: | ||
change_reclaimspacecronjob_state_for_pvc(pvc, enable=False) | ||
|
||
# Verify Reclaimnspace cronjob is set as disable. | ||
for pvc in pvc_objs: | ||
reclaimspace_cronjob = get_reclaimspacecronjob_for_pvc(pvc) | ||
suspend_state = reclaimspace_cronjob.data["spec"].get("suspend", False) | ||
|
||
assert ( | ||
suspend_state | ||
), "reclaimspacecronjob state is not in suspened state for the PVC: {pvc.name}" | ||
|
||
# ReEnable the reclaimspace Operation for PVC | ||
log.info("Changing reclaimspace cronjob status to Enable for all PVC object.") | ||
for pvc in pvc_objs: | ||
change_reclaimspacecronjob_state_for_pvc(pvc, enable=True) | ||
|
||
# Verify Reclaimnspace cronjob is enable for the PVC | ||
for pvc in pvc_objs: | ||
reclaimspace_cronjob = get_reclaimspacecronjob_for_pvc(pvc) | ||
suspend_state = reclaimspace_cronjob.data["spec"].get("suspend", False) | ||
|
||
assert ( | ||
not suspend_state | ||
), "reclaimspace cronjob state is still in suspened state for the PVC: {pvc.name}" |