From a2d12bcc600788a9cee7cdf3a13e2082b1c2005d Mon Sep 17 00:00:00 2001 From: Yang Chiu Date: Wed, 24 Jan 2024 09:49:12 +0800 Subject: [PATCH] test(negative): decouple stress operations from physical node operations Signed-off-by: Yang Chiu --- e2e/keywords/common.resource | 2 +- e2e/keywords/node.resource | 12 ------------ e2e/keywords/stress.resource | 17 +++++++++++++++++ e2e/libs/keywords/node_keywords.py | 19 ------------------- e2e/libs/keywords/stress_keywords.py | 26 ++++++++++++++++++++++++++ e2e/tests/stress_cpu.robot | 2 +- e2e/tests/stress_memory.robot | 2 +- 7 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 e2e/keywords/stress.resource create mode 100644 e2e/libs/keywords/stress_keywords.py diff --git a/e2e/keywords/common.resource b/e2e/keywords/common.resource index a0830e1a16..7000590780 100644 --- a/e2e/keywords/common.resource +++ b/e2e/keywords/common.resource @@ -2,7 +2,7 @@ Documentation Common keywords Library ../libs/keywords/common_keywords.py -Library ../libs/keywords/node_keywords.py +Library ../libs/keywords/stress_keywords.py Library ../libs/keywords/volume_keywords.py Library ../libs/keywords/recurring_job_keywords.py Library ../libs/keywords/workload_keywords.py diff --git a/e2e/keywords/node.resource b/e2e/keywords/node.resource index b68b0e2845..0dc25d63b8 100644 --- a/e2e/keywords/node.resource +++ b/e2e/keywords/node.resource @@ -66,15 +66,3 @@ Restart cluster FOR ${statefulset} IN @{statefulset_list} wait_for_workload_pod_stable ${statefulset} END - -Stress the CPU of all ${role} nodes - stress_node_cpu_by_role ${role} - -Stress the CPU of all volume nodes - stress_node_cpu_by_volumes ${volume_list} - -Stress the memory of all ${role} nodes - stress_node_memory_by_role ${role} - -Stress the memory of all volume nodes - stress_node_memory_by_volumes ${volume_list} diff --git a/e2e/keywords/stress.resource b/e2e/keywords/stress.resource new file mode 100644 index 0000000000..d4a99230fc --- /dev/null +++ b/e2e/keywords/stress.resource @@ -0,0 +1,17 @@ +*** Settings *** +Documentation Stress Node Keywords + +Library ../libs/keywords/stress_keywords.py + +*** Keywords *** +Stress the CPU of all ${role} nodes + stress_node_cpu_by_role ${role} + +Stress the CPU of all volume nodes + stress_node_cpu_by_volumes ${volume_list} + +Stress the memory of all ${role} nodes + stress_node_memory_by_role ${role} + +Stress the memory of all volume nodes + stress_node_memory_by_volumes ${volume_list} diff --git a/e2e/libs/keywords/node_keywords.py b/e2e/libs/keywords/node_keywords.py index 87ab3afd9b..fc23bb45c5 100644 --- a/e2e/libs/keywords/node_keywords.py +++ b/e2e/libs/keywords/node_keywords.py @@ -1,10 +1,7 @@ from robot.libraries.BuiltIn import BuiltIn from node import Node -from node import Stress from node.utility import get_node_by_index -from node.utility import list_node_names_by_role -from node.utility import list_node_names_by_volumes from utility.utility import wait_for_all_instance_manager_running @@ -13,7 +10,6 @@ class node_keywords: def __init__(self): self.node = Node() - self.stress = Stress() def reboot_volume_node(self, volume_name): volume_keywords = BuiltIn().get_library_instance('volume_keywords') @@ -40,18 +36,3 @@ def reboot_node_by_name(self, node_name, power_off_time_in_min=1): def wait_for_all_instance_manager_running(self): wait_for_all_instance_manager_running() - - def cleanup_stress_helper(self): - self.stress.cleanup() - - def stress_node_cpu_by_role(self, role): - self.stress.cpu(list_node_names_by_role(role)) - - def stress_node_cpu_by_volumes(self, volume_names): - self.stress.cpu(list_node_names_by_volumes(volume_names)) - - def stress_node_memory_by_role(self, role): - self.stress.memory(list_node_names_by_role(role)) - - def stress_node_memory_by_volumes(self, volume_names): - self.stress.memory(list_node_names_by_volumes(volume_names)) diff --git a/e2e/libs/keywords/stress_keywords.py b/e2e/libs/keywords/stress_keywords.py new file mode 100644 index 0000000000..f9b9928d44 --- /dev/null +++ b/e2e/libs/keywords/stress_keywords.py @@ -0,0 +1,26 @@ +from robot.libraries.BuiltIn import BuiltIn + +from node import Stress +from node.utility import list_node_names_by_role +from node.utility import list_node_names_by_volumes + + +class stress_keywords: + + def __init__(self): + self.stress = Stress() + + def cleanup_stress_helper(self): + self.stress.cleanup() + + def stress_node_cpu_by_role(self, role): + self.stress.cpu(list_node_names_by_role(role)) + + def stress_node_cpu_by_volumes(self, volume_names): + self.stress.cpu(list_node_names_by_volumes(volume_names)) + + def stress_node_memory_by_role(self, role): + self.stress.memory(list_node_names_by_role(role)) + + def stress_node_memory_by_volumes(self, volume_names): + self.stress.memory(list_node_names_by_volumes(volume_names)) diff --git a/e2e/tests/stress_cpu.robot b/e2e/tests/stress_cpu.robot index 7d36b1a7f7..b7f7998693 100644 --- a/e2e/tests/stress_cpu.robot +++ b/e2e/tests/stress_cpu.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Negative Test Cases -Resource ../keywords/node.resource +Resource ../keywords/stress.resource Resource ../keywords/volume.resource Resource ../keywords/workload.resource Resource ../keywords/common.resource diff --git a/e2e/tests/stress_memory.robot b/e2e/tests/stress_memory.robot index f2530a3592..8054b967a1 100644 --- a/e2e/tests/stress_memory.robot +++ b/e2e/tests/stress_memory.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Negative Test Cases -Resource ../keywords/node.resource +Resource ../keywords/stress.resource Resource ../keywords/volume.resource Resource ../keywords/workload.resource Resource ../keywords/common.resource