From 937140ccd2e629d0b440af460cda20896f8426c6 Mon Sep 17 00:00:00 2001 From: prsurve Date: Mon, 7 Oct 2024 16:19:30 +0530 Subject: [PATCH] Check for Kube Object Sync time before running failover for Discovered Apps Signed-off-by: prsurve --- ocs_ci/helpers/dr_helpers.py | 2 +- ocs_ci/ocs/dr/dr_workload.py | 3 ++- .../test_failover_and_relocate_discovered_apps.py | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ocs_ci/helpers/dr_helpers.py b/ocs_ci/helpers/dr_helpers.py index 5f0cbdaa29b..9aa0f5d597f 100644 --- a/ocs_ci/helpers/dr_helpers.py +++ b/ocs_ci/helpers/dr_helpers.py @@ -1700,7 +1700,7 @@ def verify_last_kubeobject_protection_time(drpc_obj, kubeoject_sync_interval): ).total_seconds() / 60 logger.info(f"Time in minutes since the last sync {time_since_last_sync}") assert ( - time_since_last_sync < 3 * kubeoject_sync_interval + time_since_last_sync < 2 * kubeoject_sync_interval ), "The syncing of Kube Resources is exceeding three times the Kube object sync interval" logger.info("Verified lastKubeObjectProtectionTime value within expected range") config.switch_ctx(restore_index) diff --git a/ocs_ci/ocs/dr/dr_workload.py b/ocs_ci/ocs/dr/dr_workload.py index dd1383a9421..bdb8ffaf845 100644 --- a/ocs_ci/ocs/dr/dr_workload.py +++ b/ocs_ci/ocs/dr/dr_workload.py @@ -1076,7 +1076,8 @@ def __init__(self, **kwargs): self.discovered_apps_placement_name = kwargs.get("workload_placement_name") self.drpc_yaml_file = os.path.join(constants.DRPC_PATH) self.placement_yaml_file = os.path.join(constants.PLACEMENT_PATH) - self.kubeobject_capture_interval = f"{generate_kubeobject_capture_interval()}m" + self.kubeobject_capture_interval_int = generate_kubeobject_capture_interval() + self.kubeobject_capture_interval = f"{self.kubeobject_capture_interval_int}m" self.protection_type = kwargs.get("protection_type") self.target_clone_dir = config.ENV_DATA.get( "target_clone_dir", constants.DR_WORKLOAD_REPO_BASE_DIR diff --git a/tests/functional/disaster-recovery/regional-dr/test_failover_and_relocate_discovered_apps.py b/tests/functional/disaster-recovery/regional-dr/test_failover_and_relocate_discovered_apps.py index 1413e5497a2..2e0b1eba710 100644 --- a/tests/functional/disaster-recovery/regional-dr/test_failover_and_relocate_discovered_apps.py +++ b/tests/functional/disaster-recovery/regional-dr/test_failover_and_relocate_discovered_apps.py @@ -6,6 +6,7 @@ from ocs_ci.framework.testlib import acceptance, tier1 from ocs_ci.framework.pytest_customization.marks import turquoise_squad from ocs_ci.helpers import dr_helpers +from ocs_ci.ocs import constants from ocs_ci.ocs.resources.drpc import DRPC logger = logging.getLogger(__name__) @@ -44,14 +45,14 @@ def test_failover_and_relocate_discovered_apps(self, discovered_apps_dr_workload scheduling_interval = dr_helpers.get_scheduling_interval( rdr_workload.workload_namespace, discovered_apps=True ) - drpc_obj = DRPC(namespace=rdr_workload.workload_namespace) + drpc_obj = DRPC(namespace=constants.DR_OPS_NAMESAPCE) wait_time = 2 * scheduling_interval # Time in minutes logger.info(f"Waiting for {wait_time} minutes to run IOs") sleep(wait_time * 60) logger.info("Checking for lastKubeObjectProtectionTime") dr_helpers.verify_last_kubeobject_protection_time( - drpc_obj, rdr_workload.kubeobject_capture_interval + drpc_obj, rdr_workload.kubeobject_capture_interval_int ) dr_helpers.failover(