From 3c32edb33acb6bae97ece735f4aebb778dc84a57 Mon Sep 17 00:00:00 2001 From: Yang Chiu Date: Tue, 5 Nov 2024 14:44:39 +0800 Subject: [PATCH] fix(node): cleanup node exec in test case teardown Signed-off-by: Yang Chiu --- e2e/keywords/common.resource | 1 + e2e/libs/keywords/common_keywords.py | 5 +++++ e2e/libs/node_exec/node_exec.py | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/e2e/keywords/common.resource b/e2e/keywords/common.resource index 33fd67f723..ee0c548159 100644 --- a/e2e/keywords/common.resource +++ b/e2e/keywords/common.resource @@ -42,6 +42,7 @@ Cleanup test resources uncordon_all_nodes cleanup_control_plane_network_latency reset_node_schedule + cleanup_node_exec cleanup_stress_helper cleanup_recurringjobs cleanup_deployments diff --git a/e2e/libs/keywords/common_keywords.py b/e2e/libs/keywords/common_keywords.py index 0275b1af46..48c524eec3 100644 --- a/e2e/libs/keywords/common_keywords.py +++ b/e2e/libs/keywords/common_keywords.py @@ -1,4 +1,5 @@ from node import Node +from node_exec import NodeExec from utility.utility import init_k8s_api_client from utility.utility import generate_name_with_suffix @@ -19,3 +20,7 @@ def get_worker_nodes(self): def get_node_by_index(self, node_id): return Node().get_node_by_index(node_id) + + def cleanup_node_exec(self): + for node_name in Node().list_node_names_by_role("all"): + NodeExec(node_name).cleanup() diff --git a/e2e/libs/node_exec/node_exec.py b/e2e/libs/node_exec/node_exec.py index 1f492b16f5..cdfab37d4a 100644 --- a/e2e/libs/node_exec/node_exec.py +++ b/e2e/libs/node_exec/node_exec.py @@ -17,8 +17,6 @@ class NodeExec: def __init__(self, node_name): self.node_name = node_name self.core_api = client.CoreV1Api() - self.cleanup() - self.pod = self.launch_pod() def cleanup(self): if get_pod(self.node_name): @@ -26,6 +24,10 @@ def cleanup(self): delete_pod(self.node_name) def issue_cmd(self, cmd): + + self.cleanup() + self.pod = self.launch_pod() + logging(f"Issuing command on {self.node_name}: {cmd}") if isinstance(cmd, list):