-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GSS BZ-2214838 Automation, Test Rook Reclaim Namespace (#9154)
Signed-off-by: oviner <[email protected]>
- Loading branch information
Showing
4 changed files
with
153 additions
and
15 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
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
127 changes: 127 additions & 0 deletions
127
tests/functional/pv/space_reclaim/test_rook_reclaim_namespace.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,127 @@ | ||
import logging | ||
import time | ||
|
||
import pytest | ||
|
||
|
||
from ocs_ci.ocs import constants | ||
from ocs_ci.utility.utils import TimeoutSampler | ||
from ocs_ci.ocs.resources.pod import get_csi_provisioner_pod | ||
from ocs_ci.framework.pytest_customization.marks import green_squad | ||
from ocs_ci.helpers.helpers import ( | ||
create_reclaim_space_job, | ||
verify_log_exist_in_pods_logs, | ||
) | ||
from ocs_ci.framework.testlib import ( | ||
ManageTest, | ||
tier2, | ||
bugzilla, | ||
skipif_ocs_version, | ||
) | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@green_squad | ||
@tier2 | ||
@bugzilla("2214838") | ||
@skipif_ocs_version("<4.13") | ||
@pytest.mark.polarion_id("OCS-5424") | ||
class TestRookReclaimNamespace(ManageTest): | ||
""" | ||
Test Rook Reclaim Namespace | ||
""" | ||
|
||
@pytest.fixture(autouse=True) | ||
def teardown(self, request): | ||
def finalizer(): | ||
try: | ||
self.reclaim_job_after_pod_delete.delete() | ||
self.reclaim_job_before_pod_delete.delete() | ||
except Exception as e: | ||
log.info(f"Exception: {e}") | ||
|
||
request.addfinalizer(finalizer) | ||
|
||
def test_rook_reclaim_namespace(self, pvc_factory, pod_factory, teardown_factory): | ||
""" | ||
Test Process: | ||
1.Create RBD PVC with filesystem mode | ||
2.Create Pod using that PVC | ||
3.Create reclaimspacejob CR to run on that PVC | ||
4.Verify reclaimspacejob successful completion | ||
5.Check logs of csi-rbdplugin-provisioner-xxx/csi-rbdplugin pods. | ||
6.Verify sparsify is skipped. | ||
7.Delete pod | ||
8.Delete reclaimspacejob CR | ||
9.Recreate reclaimspacejob CR | ||
10.Sleep 120 seconds so the logs in csi-rbdplugin-provisioner-xxx/csi-rbdplugin will be updated | ||
11.Verify logs does not show 'skipping sparsify operation' message. | ||
""" | ||
log.info("Create RBD PVC with filesystem mode") | ||
pvc_obj = pvc_factory( | ||
interface=constants.CEPHBLOCKPOOL, | ||
status=constants.STATUS_BOUND, | ||
size=2, | ||
) | ||
pod_dict_path = constants.NGINX_POD_YAML | ||
raw_block_pv = False | ||
|
||
log.info( | ||
f"Created new pod sc_name={constants.CEPHFILESYSTEM} size=10Gi, " | ||
f"access_mode={constants.ACCESS_MODE_RWX}, volume_mode={constants.VOLUME_MODE_FILESYSTEM}" | ||
) | ||
pod_obj = pod_factory( | ||
interface=constants.CEPHFILESYSTEM, | ||
pvc=pvc_obj, | ||
status=constants.STATUS_RUNNING, | ||
pod_dict_path=pod_dict_path, | ||
raw_block_pv=raw_block_pv, | ||
) | ||
|
||
log.info(f"Create reclaimspacejob CR to run on pvc {pvc_obj.name}") | ||
self.reclaim_job_before_pod_delete = create_reclaim_space_job( | ||
pvc_name=pvc_obj.name | ||
) | ||
expected_log = "skipping sparsify operation" | ||
pod_names = get_csi_provisioner_pod(interface=constants.CEPHBLOCKPOOL) | ||
|
||
log.info( | ||
f"Check logs of csi-rbdplugin-provisioner-xxx/csi-rbdplugin pods {pod_names}" | ||
) | ||
sample = TimeoutSampler( | ||
timeout=100, | ||
sleep=5, | ||
func=verify_log_exist_in_pods_logs, | ||
pod_names=pod_names, | ||
expected_log=expected_log, | ||
) | ||
if not sample.wait_for_func_status(result=True): | ||
raise ValueError( | ||
f"The expected log '{expected_log}' does not exist in {pod_names} pods" | ||
) | ||
|
||
log.info(f"Delete pod {pod_obj.name}") | ||
pod_obj.delete() | ||
|
||
log.info(f"Delete reclaimspacejob CR {self.reclaim_job_before_pod_delete.name}") | ||
self.reclaim_job_before_pod_delete.delete() | ||
|
||
log.info("Recreate reclaimspacejob CR") | ||
self.reclaim_job_after_pod_delete = create_reclaim_space_job( | ||
pvc_name=pvc_obj.name | ||
) | ||
|
||
log.info(f"Sleep 120 seconds so the logs in {pod_names} will be updated") | ||
time.sleep(120) | ||
|
||
log.info("Verify logs does not show 'skipping sparsify operation' message.") | ||
log_exist = verify_log_exist_in_pods_logs( | ||
pod_names=pod_names, expected_log=expected_log, since="120s" | ||
) | ||
if log_exist: | ||
raise ValueError( | ||
f"The expected log '{expected_log}' exist in {pod_names} pods after reclaimspacejob deletion" | ||
) |
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