From cf524622a8ced96406678840016a2996ec19e1ad Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Tue, 17 Dec 2024 10:18:39 +0800 Subject: [PATCH] refactor(robot): get volume instance manager Signed-off-by: Chin-Ya Huang --- e2e/keywords/longhorn.resource | 10 ++++------ e2e/libs/keywords/volume_keywords.py | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/e2e/keywords/longhorn.resource b/e2e/keywords/longhorn.resource index 29198f4a6..a77fdf28b 100644 --- a/e2e/keywords/longhorn.resource +++ b/e2e/keywords/longhorn.resource @@ -69,16 +69,14 @@ Install Longhorn Delete instance-manager of volume ${volume_id} ${volume_name} = generate_name_with_suffix volume ${volume_id} - ${node_name} = get_volume_node ${volume_name} - ${pod_name} = get_instance_manager_on_node ${node_name} - delete_pod ${pod_name} longhorn-system + ${instance_manager} = get_volume_instance_manager ${volume_name} + delete_pod ${instance_manager} longhorn-system Delete instance-manager of deployment ${deployment_id} volume ${deployment_name} = generate_name_with_suffix deployment ${deployment_id} ${volume_name} = get_workload_volume_name ${deployment_name} - ${node_name} = get_volume_node ${volume_name} - ${pod_name} = get_instance_manager_on_node ${node_name} - delete_pod ${pod_name} longhorn-system + ${instance_manager} = get_volume_instance_manager ${volume_name} + delete_pod ${instance_manager} longhorn-system Wait for Longhorn components all running wait_for_namespace_pods_running longhorn-system diff --git a/e2e/libs/keywords/volume_keywords.py b/e2e/libs/keywords/volume_keywords.py index 9cf0bfc5f..f07aab760 100644 --- a/e2e/libs/keywords/volume_keywords.py +++ b/e2e/libs/keywords/volume_keywords.py @@ -14,6 +14,7 @@ from utility.utility import get_retry_count_and_interval from volume import Volume +from volume.rest import Rest as VolumeRest class volume_keywords: @@ -70,6 +71,11 @@ def get_replica_node(self, volume_name): def get_volume_node(self, volume_name): return self.get_node_id_by_replica_locality(volume_name, "volume node") + def get_volume_instance_manager(self, volume_name): + volume = VolumeRest().get(volume_name) + assert len(volume['controllers']) == 1, f"Expect only one controller for volume {volume_name}; Got controllers: {volume['controllers']}" + return volume['controllers'][0]['instanceManagerName'] + def get_node_id_by_replica_locality(self, volume_name, replica_locality): return self.get_node_ids_by_replica_locality(volume_name, replica_locality)[0]