Skip to content

Commit

Permalink
get_dr_operator_versions function
Browse files Browse the repository at this point in the history
Signed-off-by: oviner <[email protected]>
  • Loading branch information
OdedViner committed Jul 23, 2024
1 parent 3106ab2 commit 2e67781
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 102 deletions.
52 changes: 6 additions & 46 deletions ocs_ci/ocs/resources/ocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@
from ocs_ci.ocs.exceptions import CSVNotFound
from ocs_ci.utility import templating, utils
from ocs_ci.utility.version import get_semantic_ocs_version_from_config, VERSION_4_9
from ocs_ci.utility.version import (
get_dr_hub_operator_version,
get_ocp_dr_cluster_operator_version,
get_odf_multicluster_orchestrator_version,
get_ocp_gitops_operator_version,
get_submariner_operator_version,
get_volsync_operator_version,
)
from ocs_ci.utility.utils import get_oadp_version, get_acm_version


log = logging.getLogger(__name__)

Expand Down Expand Up @@ -213,43 +205,11 @@ def get_version_info(namespace=None):
csv_name = package_manifest.get_current_csv(channel)
csv_pre = CSV(resource_name=csv_name, namespace=namespace)
info = get_images(csv_pre.get())
from ocs_ci.ocs.utils import is_dr_scenario

if is_dr_scenario():
with config.RunWithAcmConfigContext():
acm_operator_version = get_acm_version()
if acm_operator_version:
info["acm_version"] = acm_operator_version
ocp_dr_hub_operator_version = get_dr_hub_operator_version()
if ocp_dr_hub_operator_version:
info["dr_hub_version"] = ocp_dr_hub_operator_version
odf_multicluster_orchestrator_version = (
get_odf_multicluster_orchestrator_version()
)
if odf_multicluster_orchestrator_version:
info[
"odf_multicluster_orchestrator_version"
] = odf_multicluster_orchestrator_version
gitops_operator_version = get_ocp_gitops_operator_version()
if gitops_operator_version:
info["gitops_version"] = gitops_operator_version
with config.RunWithPrimaryConfigContext():
oadp_operator_version = get_oadp_version()
if oadp_operator_version:
info["oadp_version"] = oadp_operator_version
ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version()
if ocp_dr_cluster_operator_version:
info["ocp_dr_cluster_version"] = ocp_dr_cluster_operator_version
gitops_operator_version = get_ocp_gitops_operator_version()
if gitops_operator_version:
info["gitops_version"] = gitops_operator_version
volsync_operator_version = get_volsync_operator_version()
if volsync_operator_version:
info["volsync_version"] = volsync_operator_version
submariner_operator_version = get_submariner_operator_version()
if submariner_operator_version:
info["submariner_version"] = submariner_operator_version
return info
from ocs_ci.ocs.utils import get_dr_operator_versions

dr_operator_versions = get_dr_operator_versions()
versions = {**info, **dr_operator_versions}
return versions


def get_ocs_csv():
Expand Down
67 changes: 65 additions & 2 deletions ocs_ci/ocs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,21 @@
from ocs_ci.utility import templating, version
from ocs_ci.utility.prometheus import PrometheusAPI
from ocs_ci.utility.retry import retry
from ocs_ci.utility.utils import create_directory_path, mirror_image, run_cmd
from ocs_ci.utility.utils import (
create_directory_path,
mirror_image,
run_cmd,
get_oadp_version,
get_acm_version,
)
from ocs_ci.utility.version import (
get_dr_hub_operator_version,
get_ocp_dr_cluster_operator_version,
get_odf_multicluster_orchestrator_version,
get_ocp_gitops_operator_version,
get_submariner_operator_version,
get_volsync_operator_version,
)


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -1691,4 +1705,53 @@ def is_dr_scenario():
bool: return True if it is rdr or mdr setup otherwise False
"""
return ocsci_config.MULTICLUSTER["multicluster_mode"] in ("metro-dr", "regional-dr")
return ocsci_config.MULTICLUSTER.get("multicluster_mode") in (
"metro-dr",
"regional-dr",
)


def get_dr_operator_versions():
"""
Get all DR operator versions on hub and primary clusters
Returns:
dict: return operator name as key and version as value
"""
versions_dic = dict()
if is_dr_scenario():
with ocsci_config.RunWithAcmConfigContext():
acm_operator_version = get_acm_version()
if acm_operator_version:
versions_dic["acm_version"] = acm_operator_version
ocp_dr_hub_operator_version = get_dr_hub_operator_version()
if ocp_dr_hub_operator_version:
versions_dic["dr_hub_version"] = ocp_dr_hub_operator_version
odf_multicluster_orchestrator_version = (
get_odf_multicluster_orchestrator_version()
)
if odf_multicluster_orchestrator_version:
versions_dic[
"odf_multicluster_orchestrator_version"
] = odf_multicluster_orchestrator_version
gitops_operator_version = get_ocp_gitops_operator_version()
if gitops_operator_version:
versions_dic["gitops_version"] = gitops_operator_version
with ocsci_config.RunWithPrimaryConfigContext():
oadp_operator_version = get_oadp_version()
if oadp_operator_version:
versions_dic["oadp_version"] = oadp_operator_version
ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version()
if ocp_dr_cluster_operator_version:
versions_dic["ocp_dr_cluster_version"] = ocp_dr_cluster_operator_version
gitops_operator_version = get_ocp_gitops_operator_version()
if gitops_operator_version:
versions_dic["gitops_version"] = gitops_operator_version
volsync_operator_version = get_volsync_operator_version()
if volsync_operator_version:
versions_dic["volsync_version"] = volsync_operator_version
submariner_operator_version = get_submariner_operator_version()
if submariner_operator_version:
versions_dic["submariner_version"] = submariner_operator_version
return versions_dic
59 changes: 5 additions & 54 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
setup_ceph_toolbox,
collect_ocs_logs,
collect_pod_container_rpm_package,
is_dr_scenario,
get_dr_operator_versions,
)
from ocs_ci.ocs.resources.deployment import Deployment
from ocs_ci.ocs.resources.job import get_job_obj
Expand Down Expand Up @@ -147,8 +147,6 @@
skipif_ui_not_support,
run_cmd,
ceph_health_check_multi_storagecluster_external,
get_oadp_version,
get_acm_version,
)
from ocs_ci.helpers import helpers, dr_helpers
from ocs_ci.helpers.helpers import (
Expand All @@ -174,14 +172,7 @@
)
from ocs_ci.ocs.longevity import start_app_workload
from ocs_ci.utility.decorators import switch_to_default_cluster_index_at_last
from ocs_ci.utility.version import (
get_dr_hub_operator_version,
get_ocp_dr_cluster_operator_version,
get_odf_multicluster_orchestrator_version,
get_ocp_gitops_operator_version,
get_submariner_operator_version,
get_volsync_operator_version,
)


log = logging.getLogger(__name__)

Expand Down Expand Up @@ -1603,49 +1594,9 @@ def additional_testsuite_properties(record_testsuite_property, pytestconfig):
# add markers as separated property
markers = ocsci_config.RUN["cli_params"].get("-m", "").replace(" ", "-")
record_testsuite_property("rp_markers", markers)
if is_dr_scenario():
with ocsci_config.RunWithAcmConfigContext():
acm_operator_version = get_acm_version()
if acm_operator_version:
record_testsuite_property("rp_acm_version", acm_operator_version)
ocp_dr_hub_operator_version = get_dr_hub_operator_version()
if ocp_dr_hub_operator_version:
record_testsuite_property(
"rp_dr_hub_version", ocp_dr_hub_operator_version
)
odf_multicluster_orchestrator_version = (
get_odf_multicluster_orchestrator_version()
)
if odf_multicluster_orchestrator_version:
record_testsuite_property(
"rp_odf_multicluster_orchestrator_version",
odf_multicluster_orchestrator_version,
)
gitops_operator_version = get_ocp_gitops_operator_version()
if gitops_operator_version:
record_testsuite_property("rp_gitops_version", gitops_operator_version)
with ocsci_config.RunWithPrimaryConfigContext():
oadp_operator_version = get_oadp_version()
if oadp_operator_version:
record_testsuite_property("rp_oadp_version", oadp_operator_version)
ocp_dr_cluster_operator_version = get_ocp_dr_cluster_operator_version()
if ocp_dr_cluster_operator_version:
record_testsuite_property(
"rp_ocp_dr_cluster_version", ocp_dr_cluster_operator_version
)
gitops_operator_version = get_ocp_gitops_operator_version()
if gitops_operator_version:
record_testsuite_property("rp_gitops_version", gitops_operator_version)
volsync_operator_version = get_volsync_operator_version()
if volsync_operator_version:
record_testsuite_property(
"rp_volsync_version", volsync_operator_version
)
submariner_operator_version = get_submariner_operator_version()
if submariner_operator_version:
record_testsuite_property(
"rp_submariner_version", submariner_operator_version
)
dr_operator_versions = get_dr_operator_versions()
for dr_operator_name, dr_operator_version in dr_operator_versions.items():
record_testsuite_property(f"rp_{dr_operator_name}", dr_operator_version)


@pytest.fixture(scope="session")
Expand Down

0 comments on commit 2e67781

Please sign in to comment.