From 68130bf837e443dd8b0cb12c3488aac8e6e2ed43 Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Thu, 26 Oct 2023 12:26:22 +0100 Subject: [PATCH] Update roles markers Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/ocs/constants.py | 2 +- ocs_ci/utility/multicluster.py | 38 ++++++++++----------- tests/ecosystem/upgrade/test_upgrade.py | 2 +- tests/ecosystem/upgrade/test_upgrade_ocp.py | 3 +- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/ocs_ci/ocs/constants.py b/ocs_ci/ocs/constants.py index aea2de8385a0..67e14e425fd5 100644 --- a/ocs_ci/ocs/constants.py +++ b/ocs_ci/ocs/constants.py @@ -2320,4 +2320,4 @@ HTML_REPORT_TEMPLATE_DIR = "ocs_ci/templates/html_reports/" # MDR multicluster roles -mdr_roles = ["ActiveACM", "PassiveACM", "Primary_odf", "Secondary_odf"] +MDR_ROLES = ["ActiveACM", "PassiveACM", "Primary_odf", "Secondary_odf"] diff --git a/ocs_ci/utility/multicluster.py b/ocs_ci/utility/multicluster.py index 2cdc36680665..e2da836dbb69 100644 --- a/ocs_ci/utility/multicluster.py +++ b/ocs_ci/utility/multicluster.py @@ -9,6 +9,7 @@ get_active_acm_index, get_all_acm_indexes, ) +from ocs_ci.ocs.constants import MDR_ROLES class MutliClusterUpgradeParametrize(object): @@ -31,7 +32,7 @@ class MutliClusterUpgradeParametrize(object): def __init__(self): self.roles = [] # List of zones which are participating in this multicluster setup - self.zones = [] + self.zones = self.get_zone_info() self.zone_base_rank = 100 # Each zone will be assigned with a rank # This rank comes handy when we have to order the tests @@ -97,23 +98,20 @@ def __init__(self): self.roles_to_param_tuples = dict() self.roles_to_config_index_map = dict() self.zone_role_map = dict() + self.all_mdr_roles = MDR_ROLES - self.zones = self.get_zone_info() - self.mdr_roles = self.get_roles() self.generate_zone_ranks() self.generate_role_ranks() - self.generate_role_to_param_tuple_map() self.generate_config_index_map() + self.generate_role_to_param_tuple_map() self.generate_zone_role_map() - # In ocs-ci we need to build this based on the config provided - def get_config_index_map(self): - # TO BE built before pytest_generate_test - if not self.roles_to_config_index_map: - self.generate_config_index_map() - return self.roles_to_config_index_map - def generate_config_index_map(self): + """ + Generate config indexes for all the MDRs cluster roles + ex: {"ActiveACM": 0, "PassiceACM": 2, "PrimaryODF": 1, "SecondaryODF": 3} + + """ for cluster in ocsci_config: cluster_index = cluster.MULTICLUSTER["multicluster_index"] if cluster_index == get_active_acm_index(): @@ -143,7 +141,7 @@ def generate_role_ranks(self): def generate_zone_role_map(self): """ Generate a map of Cluster's role vs zone in which clusters are located - + ex: {"ActiveACM": 'a', "PassiveACM": 'b', "PrimaryODF": 'a'} """ for crole, cindex in self.roles_to_config_index_map.items(): czone = ocsci_config.clusters[cindex].ENV_DATA.get("zone") @@ -153,22 +151,24 @@ def generate_zone_role_map(self): def generate_role_to_param_tuple_map(self): """ For each of the MDRs applicable roles store a tuple (zone_rank, role_rank, config_index) + ex: {"ActiveACM": (1, 1, 0), "PassiceACM": (2, 1, 2), "PrimaryODF": (1, 2, 1), "SecondarODF": (2, 2, 3)} """ - for role in self.mdr_roles: + for role in self.all_mdr_roles: self.roles_to_param_tuples[role] = ( self.zone_ranks[self.zone_role_map[role]], self.role_ranks[role], - self.get_config_index_map()[role], + self.roles_to_config_index_map[role], ) def get_pytest_params_tuple(self, role): """ - Generate a tuple of parameters applicable to the given role - For ex: if role is 'ActiveACM', then generate a tuple which is applicable to - that role. If the role is 'all' then we will generate tuple of parameter - for each of the role applicable from MDRs perspective. - Parmeter tuples looks like (zone_rank, role_rank, config_index) + Get a tuple of parameters applicable to the given role + For ex: if role is 'ActiveACM', then get a tuple which is applicable to + that role. If the role is 'all' then we will get tuples of parameter + for all the roles applicable + Parmeter tuples looks like (zone_rank, role_rank, config_index) for a given role + """ param_list = list() if role == "all": diff --git a/tests/ecosystem/upgrade/test_upgrade.py b/tests/ecosystem/upgrade/test_upgrade.py index 7dd33e4ad1c7..0365614e3fd0 100644 --- a/tests/ecosystem/upgrade/test_upgrade.py +++ b/tests/ecosystem/upgrade/test_upgrade.py @@ -64,7 +64,7 @@ def test_osd_reboot(teardown): @purple_squad @ocs_upgrade @polarion_id(get_polarion_id(upgrade=True)) -@multicluster_roles(["odf"]) +@multicluster_roles(["mdr_all_ocs"]) def test_upgrade(): """ Tests upgrade procedure of OCS cluster diff --git a/tests/ecosystem/upgrade/test_upgrade_ocp.py b/tests/ecosystem/upgrade/test_upgrade_ocp.py index 3fae8f3777c6..2e17bef9e327 100644 --- a/tests/ecosystem/upgrade/test_upgrade_ocp.py +++ b/tests/ecosystem/upgrade/test_upgrade_ocp.py @@ -36,7 +36,7 @@ @ignore_leftovers @ocp_upgrade @purple_squad -@multicluster_roles(["ocp"]) +@multicluster_roles(["mdr_all_ocp"]) class TestUpgradeOCP(ManageTest): """ 1. check cluster health @@ -86,7 +86,6 @@ def test_upgrade_ocp(self, reduce_and_resume_cluster_load): logger.debug(f"Cluster versions before upgrade:\n{cluster_ver}") ceph_cluster = CephCluster() with CephHealthMonitor(ceph_cluster): - ocp_channel = config.UPGRADE.get( "ocp_channel", ocp.get_ocp_upgrade_channel() )