Skip to content

Commit

Permalink
Changed metadata tests to use custom storageclass feature
Browse files Browse the repository at this point in the history
Signed-off-by: Parag Kamble <[email protected]>
  • Loading branch information
paraggit committed Oct 26, 2023
1 parent 3b88096 commit 5d9ff1e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 44 deletions.
30 changes: 0 additions & 30 deletions ocs_ci/utility/metadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,33 +335,3 @@ def validate_metadata(
assert (
namespace == metadata["csi.storage.k8s.io/volumesnapshot/namespace"]
), "Error: namespace is not as expected"


def update_testdata_for_external_modes(
sc_name,
fs,
external_mode=False,
):
"""
Update the file sytem and storage class names for external mode clusters
Args:
sc_name (str): storage class
fs (str): file system
external_mode(bool): External mode or not
Returns:
sc_name (str): storage class
fs (str): file system
"""
if external_mode:
if sc_name == constants.DEFAULT_STORAGECLASS_CEPHFS:
fs = "fsvol001"
sc_name = constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_CEPHFS
elif sc_name == constants.DEFAULT_STORAGECLASS_RBD:
fs = ""
sc_name = constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD
else:
log.exception("Metadata feature is not supported for this storage class")
return fs, sc_name
43 changes: 29 additions & 14 deletions tests/manage/add_metadata_feature/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ def test_metadata_feature_unavailable_for_previous_versions(
for csi-cephfsplugin-provisioner and csi-rbdplugin-provisioner pods
"""
sc_name = storageclass_name(sc_interface)
external_mode = config.DEPLOYMENT["external_mode"]
fs, sc_name = metadata_utils.update_testdata_for_external_modes(
sc_name, fs, external_mode=external_mode
fs = (
""
if sc_interface == constants.OCS_COMPONENTS_MAP["blockpools"]
else "fsvol001"
)
config_map_obj = ocp.OCP(kind="Configmap", namespace="openshift-storage")
pod_obj = ocp.OCP(kind="Pod", namespace="openshift-storage")
Expand Down Expand Up @@ -176,9 +177,10 @@ def test_metadata_not_enabled_by_default(
"""
sc_name = storageclass_name(sc_interface)
external_mode = config.DEPLOYMENT["external_mode"]
fs, sc_name = metadata_utils.update_testdata_for_external_modes(
sc_name, fs, external_mode=external_mode
fs = (
""
if sc_interface == constants.OCS_COMPONENTS_MAP["blockpools"]
else "fsvol001"
)
config_map_obj = ocp.OCP(kind="Configmap", namespace="openshift-storage")
pod_obj = ocp.OCP(kind="Pod", namespace="openshift-storage")
Expand Down Expand Up @@ -317,6 +319,11 @@ def test_verify_metadata_details(
"""
sc_name = storageclass_name(sc_interface)
fs = (
""
if sc_interface == constants.OCS_COMPONENTS_MAP["blockpools"]
else "fsvol001"
)
available_subvolumes = metadata_utils.available_subvolumes(
sc_name, self.toolbox, fs
)
Expand Down Expand Up @@ -447,8 +454,10 @@ def test_verify_metadata_details_for_new_pvc_same_named(self, fs, sc_interface):
is different than previous metadata
"""
sc_name = storageclass_name(sc_interface)
fs, sc_name = metadata_utils.update_testdata_for_external_modes(
sc_name, fs, external_mode=self.external_mode
fs = (
""
if sc_interface == constants.OCS_COMPONENTS_MAP["blockpools"]
else "fsvol001"
)
available_subvolumes = metadata_utils.available_subvolumes(
sc_name, self.toolbox, fs
Expand Down Expand Up @@ -561,8 +570,10 @@ def test_metadata_details_available_only_when_metadata_flag_enabled(
"""
sc_name = storageclass_name(sc_interface)
fs, sc_name = metadata_utils.update_testdata_for_external_modes(
sc_name, fs, external_mode=self.external_mode
fs = (
""
if sc_interface == constants.OCS_COMPONENTS_MAP["blockpools"]
else "fsvol001"
)
available_subvolumes = metadata_utils.available_subvolumes(
sc_name, self.toolbox, fs
Expand Down Expand Up @@ -709,8 +720,10 @@ def test_disable_metadata_flag_after_enabling(self, fs, sc_interface):
"""
sc_name = storageclass_name(sc_interface)
fs, sc_name = metadata_utils.update_testdata_for_external_modes(
sc_name, fs, external_mode=self.external_mode
fs = (
""
if sc_interface == constants.OCS_COMPONENTS_MAP["blockpools"]
else "fsvol001"
)
available_subvolumes = metadata_utils.available_subvolumes(
sc_name, self.toolbox, fs
Expand Down Expand Up @@ -833,8 +846,10 @@ def test_metadata_update_for_PV_Retain(
"""
sc_name = storageclass_name(sc_interface)
fs, sc_name = metadata_utils.update_testdata_for_external_modes(
sc_name, fs, external_mode=self.external_mode
fs = (
""
if sc_interface == constants.OCS_COMPONENTS_MAP["blockpools"]
else "fsvol001"
)
# Enable CSI_ENABLE_OMAP_GENERATOR flag
enable_omap_generator = '{"data":{"CSI_ENABLE_OMAP_GENERATOR": "true"}}'
Expand Down

0 comments on commit 5d9ff1e

Please sign in to comment.