Skip to content
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

Adding Markers for FUSION HCI Provider Client Platform #8824

Merged
merged 9 commits into from
Nov 15, 2023
22 changes: 22 additions & 0 deletions ocs_ci/framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,28 @@ def is_consumer_exist(self):
cluster_types = [cluster.ENV_DATA["cluster_type"] for cluster in self.clusters]
return "consumer" in cluster_types

def hci_client_exist(self):
"""
Check if the hci_client cluster exists in the clusters

Returns:
bool: True, if the hci_client cluster exists in the clusters. False, otherwise.

"""
cluster_types = [cluster.ENV_DATA["cluster_type"] for cluster in self.clusters]
return "hci_client" in cluster_types

def hci_provider_exist(self):
"""
Check if the provider cluster exists in the clusters

Returns:
bool: True, if the provider cluster exists in the clusters. False, otherwise.

"""
cluster_types = [cluster.ENV_DATA["cluster_type"] for cluster in self.clusters]
return "provider" in cluster_types

def is_cluster_type_exist(self, cluster_type):
"""
Check if the given cluster type exists in the clusters
Expand Down
49 changes: 49 additions & 0 deletions ocs_ci/framework/pytest_customization/marks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
OPENSHIFT_DEDICATED_PLATFORM,
MANAGED_SERVICE_PLATFORMS,
HPCS_KMS_PROVIDER,
HCI_PROVIDER_CLIENT_PLATFORMS,
HCI_CLIENT,
HCI_PROVIDER,
)
from ocs_ci.utility import version
from ocs_ci.utility.aws import update_config_from_s3
Expand Down Expand Up @@ -274,6 +277,31 @@
reason="Test runs ONLY on Managed service with provider and consumer clusters",
)

hci_client_required = pytest.mark.skipif(
not (
config.default_cluster_ctx.ENV_DATA["platform"].lower()
in HCI_PROVIDER_CLIENT_PLATFORMS
and config.default_cluster_ctx.ENV_DATA["cluster_type"].lower() == HCI_CLIENT
),
reason="Test runs ONLY on Fusion HCI Client cluster",
)

hci_provider_required = pytest.mark.skipif(
not (
config.default_cluster_ctx.ENV_DATA["platform"].lower()
in HCI_PROVIDER_CLIENT_PLATFORMS
and config.default_cluster_ctx.ENV_DATA["cluster_type"].lower() == HCI_PROVIDER
),
reason="Test runs ONLY on Fusion HCI Provider cluster",
)
hci_provider_and_client_required = pytest.mark.skipif(
not (
config.ENV_DATA["platform"].lower() in HCI_PROVIDER_CLIENT_PLATFORMS
and config.hci_provider_exist()
and config.hci_client_exist()
),
reason="Test runs ONLY on Fusion HCI provider and client clusters",
)
kms_config_required = pytest.mark.skipif(
(
config.ENV_DATA["KMS_PROVIDER"].lower() != HPCS_KMS_PROVIDER
Expand Down Expand Up @@ -342,6 +370,27 @@
reason="Test will not run on Managed service with provider and consumer clusters",
)

skipif_hci_provider = pytest.mark.skipif(
config.default_cluster_ctx.ENV_DATA["platform"].lower()
in HCI_PROVIDER_CLIENT_PLATFORMS
and config.default_cluster_ctx.ENV_DATA["cluster_type"].lower() == HCI_PROVIDER,
reason="Test will not run on Fusion HCI provider cluster",
)

skipif_hci_client = pytest.mark.skipif(
config.default_cluster_ctx.ENV_DATA["platform"].lower()
in HCI_PROVIDER_CLIENT_PLATFORMS
and config.default_cluster_ctx.ENV_DATA["cluster_type"].lower() == HCI_CLIENT,
reason="Test will not run on Fusion HCI client cluster",
)

skipif_hci_provider_and_client = pytest.mark.skipif(
config.ENV_DATA["platform"].lower() in HCI_PROVIDER_CLIENT_PLATFORMS
and config.hci_provider_exist()
and config.hci_client_exist(),
reason="Test will not run on Fusion HCI provider and Client clusters",
)

skipif_rosa = pytest.mark.skipif(
config.ENV_DATA["platform"].lower() == ROSA_PLATFORM,
reason="Test will not run on ROSA cluster",
Expand Down
28 changes: 28 additions & 0 deletions ocs_ci/ocs/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,20 @@ def is_ms_consumer_cluster():
)


def is_hci_client_cluster():
"""
Check if the cluster is a Fusion HCI Client cluster

Returns:
bool: True, if the cluster is a Fusion HCI client cluster. False, otherwise

"""
return (
config.ENV_DATA["platform"].lower() in constants.HCI_PROVIDER_CLIENT_PLATFORMS
and config.ENV_DATA["cluster_type"].lower() == constants.HCI_CLIENT
)


def is_ms_provider_cluster():
"""
Check if the cluster is a managed service provider cluster
Expand All @@ -2216,6 +2230,20 @@ def is_ms_provider_cluster():
)


def is_hci_provider_cluster():
"""
Check if the cluster is a Fusion HCI provider cluster

Returns:
bool: True, if the cluster is a Fusion HCI provider cluster. False, otherwise

"""
return (
config.ENV_DATA["platform"].lower() in constants.HCI_PROVIDER_CLIENT_PLATFORMS
and config.ENV_DATA["cluster_type"].lower() == constants.HCI_PROVIDER
)


def get_osd_dump(pool_name):
"""
Get the osd dump part of a given pool
Expand Down
11 changes: 11 additions & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@
MS_PROVIDER_TYPE = "provider"
NON_MS_CLUSTER_TYPE = "non_ms"

# HCI cluster types
HCI_CLIENT = "hci_client"
HCI_PROVIDER = "provider"

OCP_QE_MISC_REPO = "https://gitlab.cee.redhat.com/aosqe/flexy-templates.git"
CRITICAL_ERRORS = ["core dumped", "oom_reaper"]
must_gather_pod_label = "app=must-gather"
Expand Down Expand Up @@ -987,6 +991,8 @@
RHV_PLATFORM = "rhv"
ROSA_PLATFORM = "rosa"
FUSIONAAS_PLATFORM = "fusion_aas"
HCI_BAREMETAL = "hci_baremetal"
HCI_VSPHERE = "hci_vsphere"
suchita-g marked this conversation as resolved.
Show resolved Hide resolved
ACM_OCP_DEPLOYMENT = "acm_ocp_deployment"
ON_PREM_PLATFORMS = [
VSPHERE_PLATFORM,
Expand All @@ -1011,6 +1017,11 @@
]
BAREMETAL_PLATFORMS = [BAREMETAL_PLATFORM, BAREMETALPSI_PLATFORM]

HCI_PROVIDER_CLIENT_PLATFORMS = [
HCI_BAREMETAL,
HCI_VSPHERE,
]

# AWS i3 worker instance for LSO
AWS_LSO_WORKER_INSTANCE = "i3en.2xlarge"

Expand Down
1 change: 1 addition & 0 deletions ocs_ci/ocs/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

OCS_OPERATOR_NAME = "ocs-operator"
ODF_OPERATOR_NAME = "odf-operator"
HCI_CLIENT_ODF_OPERATOR_NAME = "ocs-client-operator"
NOOBAA_OPERATOR = "noobaa-operator"
MCG_OPERATOR = "mcg-operator"
ODF_CSI_ADDONS_OPERATOR = "odf-csi-addons-operator"
Expand Down
5 changes: 5 additions & 0 deletions ocs_ci/utility/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,11 @@ def get_ocs_build_number():
>= version_module.VERSION_4_9
):
operator_name = defaults.ODF_OPERATOR_NAME
if (
config.ENV_DATA.get("platform") in constants.HCI_PROVIDER_CLIENT_PLATFORMS
and config.ENV_DATA.get("cluster_type") == constants.HCI_CLIENT
):
operator_name = defaults.HCI_CLIENT_ODF_OPERATOR_NAME
else:
operator_name = defaults.OCS_OPERATOR_NAME
ocs_csvs = get_csvs_start_with_prefix(
Expand Down
16 changes: 12 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ def pytest_collection_modifyitems(session, config, items):
log.debug(f"Test: {item} will be skipped due to {skip_condition}")
items.remove(item)
continue
if skipif_upgraded_from_marker:
if (
skipif_upgraded_from_marker
and ocsci_config.ENV_DATA.get("platform", "").lower()
not in constants.HCI_PROVIDER_CLIENT_PLATFORMS
):
skip_args = skipif_upgraded_from_marker.args
if skipif_upgraded_from(skip_args[0]):
log.debug(
Expand Down Expand Up @@ -5938,7 +5942,7 @@ def toolbox_on_faas_consumer():
@pytest.fixture(scope="function", autouse=True)
def switch_to_provider_for_test(request):
"""
Switch to provider cluster as required by the test. Applicable for Managed Services only if
Switch to provider cluster as required by the test. Applicable for Managed Services and HCI Provider-client only if
the marker 'runs_on_provider' is added in the test.

"""
Expand All @@ -5947,8 +5951,12 @@ def switch_to_provider_for_test(request):
if (
request.node.get_closest_marker("runs_on_provider")
and ocsci_config.multicluster
and current_cluster.ENV_DATA.get("platform", "").lower()
in constants.MANAGED_SERVICE_PLATFORMS
and (
current_cluster.ENV_DATA.get("platform", "").lower()
in constants.MANAGED_SERVICE_PLATFORMS
or current_cluster.ENV_DATA.get("platform", "").lower()
in constants.HCI_PROVIDER_CLIENT_PLATFORMS
)
):
for cluster in ocsci_config.clusters:
if cluster.ENV_DATA.get("cluster_type") == "provider":
Expand Down
96 changes: 96 additions & 0 deletions tests/libtest/test_hci_pc_markers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import logging
import pytest

from ocs_ci.framework.pytest_customization.marks import yellow_squad
from ocs_ci.framework.testlib import (
libtest,
ManageTest,
ignore_leftovers,
hci_provider_and_client_required,
skipif_hci_client,
skipif_hci_provider,
runs_on_provider,
)
from ocs_ci.ocs.cluster import (
is_hci_client_cluster,
is_hci_provider_cluster,
)
from ocs_ci.ocs.managedservice import check_and_change_current_index_to_default_index

logger = logging.getLogger(__name__)


@yellow_squad
@libtest
@hci_provider_and_client_required
@ignore_leftovers
class TestHCIProviderClientMarkers(ManageTest):
"""
Test that the HCI Provider Client markers work as expected
"""

@pytest.mark.first
def test_default_cluster_context_index_equal_to_current_index(self):
"""
Test that the default cluster index is equal to the current cluster index. This test should run first
"""
assert (
check_and_change_current_index_to_default_index()
), "The default cluster index is different from the current cluster index"
logger.info(
"The default cluster index is equal to the current cluster index as expected"
)

@skipif_hci_client
def test_marker_skipif_hci_client(self):
"""
Test that the 'skipif_hci_client' marker work as expected
"""
assert (
not is_hci_client_cluster()
), "The cluster is a HCI Client cluster, even though we have the marker 'skipif_hci_client'"
logger.info("The cluster is not a HCI Client cluster as expected")

assert check_and_change_current_index_to_default_index()
logger.info(
"The default cluster index is equal to the current cluster index as expected"
)

@skipif_hci_provider
def test_marker_skipif_hci_provider(self):
"""
Test that the 'skipif_hci_provider' marker work as expected
"""
assert (
not is_hci_provider_cluster()
), "The cluster is a HCI provider cluster, even though we have the marker 'skipif_hci_provider'"
logger.info("The cluster is not a HCI provider cluster as expected")

assert check_and_change_current_index_to_default_index()
logger.info(
"The default cluster index is equal to the current cluster index as expected"
)

@runs_on_provider
@pytest.mark.second_to_last
def test_runs_on_provider_marker(self):
"""
Test that the 'runs_on_provider' marker work as expected
"""
assert (
is_hci_provider_cluster()
), "The cluster is not a HCI provider cluster, even though we have the marker 'runs_on_provider'"
logger.info("The cluster is a provider cluster as expected")

@pytest.mark.last
def test_current_index_not_change_after_using_runs_on_provider(self):
"""
Test that the current cluster index didn't change after using the 'runs_on_provider'
marker in the previous test.
"""
assert (
check_and_change_current_index_to_default_index()
), "The current cluster index has changed after using the 'runs_on_provider' marker"
logger.info(
"The current cluster index didn't change after using the 'runs_on_provider' marker"
)
Loading