-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test automation for Default RBD storageclass for cluster (#9469)
Signed-off-by: Parag Kamble <pakamble@redhat.com>
- Loading branch information
Showing
5 changed files
with
138 additions
and
1 deletion.
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
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
72 changes: 72 additions & 0 deletions
72
tests/functional/storageclass/test_rbd_default_storageclass.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,72 @@ | ||
import logging | ||
import pytest | ||
from ocs_ci.helpers.helpers import is_rbd_default_storage_class | ||
from ocs_ci.ocs import constants | ||
from ocs_ci.utility import templating | ||
from ocs_ci.helpers.helpers import create_unique_resource_name | ||
from ocs_ci.helpers.helpers import default_storage_class | ||
from ocs_ci.framework.pytest_customization.marks import ( | ||
tier1, | ||
green_squad, | ||
polarion_id, | ||
baremetal_deployment_required, | ||
ui_deployment_required, | ||
) | ||
from ocs_ci.ocs.ui.helpers_ui import is_ui_deployment | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@green_squad | ||
@baremetal_deployment_required | ||
@ui_deployment_required | ||
class TestRBDStorageClassAsDefaultStorageClass: | ||
@tier1 | ||
@polarion_id("OCS-5459") | ||
def test_pvc_creation_without_storageclass_name(self, pvc_factory, pod_factory): | ||
""" | ||
Test PVC creation without mentioning storageclass name in the spec. | ||
Steps: | ||
1. Verify RBD storageclass is set as default. | ||
2. Create a PVC and don't provide any storage class name in the YAML file. | ||
3. Verify PVC has created and it has attached to the Default RBD SC. | ||
4. Create a POD and attached the above PVC to the Pod. | ||
5. Start IO on verify that IO is successful on the PV. | ||
""" | ||
if not is_ui_deployment(): | ||
pytest.skip("cluster is not deployed from UI. Skipping test.") | ||
|
||
assert ( | ||
is_rbd_default_storage_class() | ||
), "RBD is not default storageclass for Cluster." | ||
|
||
pvc_data = templating.load_yaml(constants.CSI_PVC_YAML) | ||
pvc_data["metadata"]["name"] = create_unique_resource_name("test", "pvc") | ||
log.info("Removing 'storageClassName' Parameter from the PVC yaml file.") | ||
del pvc_data["spec"]["storageClassName"] | ||
|
||
pvc_obj = pvc_factory(custom_data=pvc_data, status=constants.STATUS_BOUND) | ||
log.info("Created PVC without providing storage class name") | ||
assert pvc_obj, "PVC creation failed." | ||
|
||
sc_attached_to_pvc = pvc_obj.get().get("spec").get("storageClassName") | ||
sc_default_in_cluster = default_storage_class(constants.CEPHBLOCKPOOL) | ||
log.info("Verifying the storageclass attached to PVC is correct.") | ||
|
||
assert ( | ||
sc_attached_to_pvc == sc_default_in_cluster.name | ||
), "Storageclass attached to PVC is different from StorageClass set as default for BlockPool." | ||
|
||
log.info("Attaching PVC to pod to start IO workload.") | ||
pod_obj = pod_factory(pvc=pvc_obj, status=constants.STATUS_RUNNING) | ||
pod_obj.run_io(direct=1, runtime=60, storage_type="fs", size="1G") | ||
|
||
# Wait for IO completion | ||
fio_result = pod_obj.get_fio_results() | ||
log.info("IO completed on all pods") | ||
err_count = fio_result.get("jobs")[0].get("error") | ||
assert err_count == 0, ( | ||
f"IO error on pod {pod_obj.name}. " f"FIO result: {fio_result}" | ||
) |