Skip to content

Commit

Permalink
Adding Markers for FUSION HCI Provider Client Platform
Browse files Browse the repository at this point in the history
Signed-off-by: suchita-g <[email protected]>
  • Loading branch information
suchita-g committed Nov 9, 2023
1 parent 9f45e2a commit b63cd66
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 1 deletion.
24 changes: 23 additions & 1 deletion ocs_ci/framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def current_cluster_name(self):

def is_provider_exist(self):
"""
Check if the provider cluster exists in the clusters
Check ifq the provider cluster exists in the clusters
Returns:
bool: True, if the provider cluster exists in the clusters. False, otherwise.
Expand All @@ -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 is_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 is_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
47 changes: 47 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,7 @@
OPENSHIFT_DEDICATED_PLATFORM,
MANAGED_SERVICE_PLATFORMS,
HPCS_KMS_PROVIDER,
HCI_PROVIDER_CLIENT_PLATFORMS,
)
from ocs_ci.utility import version
from ocs_ci.utility.aws import update_config_from_s3
Expand Down Expand Up @@ -274,6 +275,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() == "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.is_hci_provider_exist()
and config.is_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 +368,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() == "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.is_hci_provider_exist()
and config.is_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() == "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() == "provider"
)


def get_osd_dump(pool_name):
"""
Get the osd dump part of a given pool
Expand Down
5 changes: 5 additions & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,11 @@
FUSIONAAS_PLATFORM,
]
BAREMETAL_PLATFORMS = [BAREMETAL_PLATFORM, BAREMETALPSI_PLATFORM]
HCI_PROVIDER_CLIENT_PLATFORMS = [
BAREMETAL_PLATFORM,
VSPHERE_PLATFORM,
IBMCLOUD_PLATFORM,
]

# AWS i3 worker instance for LSO
AWS_LSO_WORKER_INSTANCE = "i3en.2xlarge"
Expand Down
96 changes: 96 additions & 0 deletions tests/hci_provider_client/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"
)

0 comments on commit b63cd66

Please sign in to comment.