Skip to content

Commit

Permalink
refactor(negative): stress node cpu/mem by volume list
Browse files Browse the repository at this point in the history
Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang committed Nov 3, 2023
1 parent ebdecf9 commit 54f41db
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
8 changes: 4 additions & 4 deletions e2e/keywords/node.resource
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ Restart cluster
wait_for_workload_pod_stable ${statefulset}
END

Stress volume node cpu
stress_node_cpu_by_volume ${volume_name}
Stress the CPU of all volume nodes
stress_node_cpu_by_volumes ${volume_list}

Stress volume node memory
stress_node_memory_by_volume ${volume_name}
Stress the memory of all volume nodes
stress_node_memory_by_volumes ${volume_list}
13 changes: 5 additions & 8 deletions e2e/libs/keywords/node_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from node import Node
from node import Stress
from node.utility import get_node_by_index
from node.utility import list_node_names_by_volumes

from utility.utility import wait_for_all_instance_manager_running

Expand Down Expand Up @@ -42,12 +43,8 @@ def wait_for_all_instance_manager_running(self):
def cleanup_stress_helper(self):
self.stress.cleanup()

def stress_node_cpu_by_volume(self, volume_name):
volume_keywords = BuiltIn().get_library_instance('volume_keywords')
volume_node = volume_keywords.get_volume_node(volume_name)
self.stress.cpu([volume_node])
def stress_node_cpu_by_volumes(self, volume_names):
self.stress.cpu(list_node_names_by_volumes(volume_names))

def stress_node_memory_by_volume(self, volume_name):
volume_keywords = BuiltIn().get_library_instance('volume_keywords')
volume_node = volume_keywords.get_volume_node(volume_name)
self.stress.memory([volume_node])
def stress_node_memory_by_volumes(self, volume_names):
self.stress.memory(list_node_names_by_volumes(volume_names))
12 changes: 12 additions & 0 deletions e2e/libs/node/utility.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from robot.libraries.BuiltIn import BuiltIn

from kubernetes import client


Expand Down Expand Up @@ -35,3 +37,13 @@ def filter_nodes(nodes, condition):
if role == "worker":
condition = lambda node: not any(label in node.metadata.labels for label in control_plane_labels)
return sorted(filter_nodes(nodes, condition))

def list_node_names_by_volumes(volume_names):
volume_nodes = {}
volume_keywords = BuiltIn().get_library_instance('volume_keywords')

for volume_name in volume_names:
volume_node = volume_keywords.get_volume_node(volume_name)
if volume_node not in volume_nodes:
volume_nodes[volume_node] = True
return list(volume_nodes.keys())
2 changes: 1 addition & 1 deletion e2e/tests/stress_cpu.robot
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Stress Volume Node CPU When Replica Is Rebuilding

FOR ${i} IN RANGE ${LOOP_COUNT}
When Delete replica on volume node to trigger replica rebuilding
And Stress volume node cpu
And Stress the CPU of all volume nodes

Then Wait until replica on volume node rebuilt
And Check data is intact
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/stress_memory.robot
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Stress Volume Node Memory When Replica Is Rebuilding

FOR ${i} IN RANGE ${LOOP_COUNT}
When Delete replica on volume node to trigger replica rebuilding
And Stress volume node memory
And Stress the memory of all volume nodes

Then Wait until replica on volume node rebuilt
And Check data is intact
Expand Down

0 comments on commit 54f41db

Please sign in to comment.