Skip to content

Fixed metadata test case #12044

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 37 additions & 5 deletions ocs_ci/utility/metadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,39 @@
CommandFailed,
ResourceWrongStatusException,
)
from ocs_ci.utility import version

log = logging.getLogger(__name__)


def get_nodeplugin_labels(interface):
"""
Retrieve the nodeplugin label based on the storage interface type and OCS version.

Args:
interface (str): The storage interface type. Expected values are:
- constants.RBD_INTERFACE
- constants.CEPHFS_INTERFACE

Returns:
str: The appropriate nodeplugin label for the given interface and OCS version.
Returns an empty string if the interface is not recognized.
"""
ocs_version = version.get_semantic_ocs_version_from_config()

if interface not in (constants.RBD_INTERFACE, constants.CEPHFS_INTERFACE):
return ""

if ocs_version < version.VERSION_4_19:
return constants.CSI_RBDPLUGIN_PROVISIONER_LABEL

return (
constants.RBD_NODEPLUGIN_LABEL
if interface == constants.RBD_INTERFACE
else constants.CEPHFS_NODEPLUGIN_LABEL
)


def check_setmetadata_availability(pod_obj):
"""
Check setmetadata parameter is available or not for cephfs and rbd plugin pods
Expand All @@ -26,7 +55,10 @@ def check_setmetadata_availability(pod_obj):
"""
plugin_provisioner_pod_objs = pod.get_all_pods(
namespace=config.ENV_DATA["cluster_namespace"],
selector=["csi-cephfsplugin-provisioner", "csi-rbdplugin-provisioner"],
selector=[
get_nodeplugin_labels(constants.CEPHFS_INTERFACE).replace("app=", ""),
get_nodeplugin_labels(constants.RBD_INTERFACE).replace("app=", ""),
],
)
log.info(f"list of provisioner pods---- {plugin_provisioner_pod_objs}")
response = retry((CommandFailed, ResourceWrongStatusException), tries=3, delay=15)(
Expand Down Expand Up @@ -84,14 +116,14 @@ def enable_metadata(
# Check csi-cephfsplugin provisioner and csi-rbdplugin-provisioner pods are up and running
assert pod_obj.wait_for_resource(
condition=constants.STATUS_RUNNING,
selector=constants.CSI_CEPHFSPLUGIN_PROVISIONER_LABEL,
selector=get_nodeplugin_labels(constants.CEPHFS_INTERFACE),
dont_allow_other_resources=True,
timeout=60,
), "Pods are not in running status"

assert pod_obj.wait_for_resource(
condition=constants.STATUS_RUNNING,
selector=constants.CSI_RBDPLUGIN_PROVISIONER_LABEL,
selector=get_nodeplugin_labels(constants.RBD_INTERFACE),
dont_allow_other_resources=True,
timeout=60,
), "Pods are not in running status"
Expand Down Expand Up @@ -144,14 +176,14 @@ def disable_metadata(
# Check csi-cephfsplugin provisioner and csi-rbdplugin-provisioner pods are up and running
assert pod_obj.wait_for_resource(
condition=constants.STATUS_RUNNING,
selector=constants.CSI_CEPHFSPLUGIN_PROVISIONER_LABEL,
selector=get_nodeplugin_labels(constants.CEPHFS_INTERFACE),
dont_allow_other_resources=True,
timeout=60,
), "Pods are not in running status"

assert pod_obj.wait_for_resource(
condition=constants.STATUS_RUNNING,
selector=constants.CSI_RBDPLUGIN_PROVISIONER_LABEL,
selector=get_nodeplugin_labels(constants.RBD_INTERFACE),
dont_allow_other_resources=True,
timeout=60,
), "Pods are not in running status"
Expand Down