Skip to content

Commit

Permalink
test(robot): detached volume should not reattach after node eviction
Browse files Browse the repository at this point in the history
longhorn/longhorn-9781

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
  • Loading branch information
c3y1huang committed Nov 15, 2024
1 parent 407bb20 commit 1e777ba
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e2e/keywords/node.resource
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Add ${disk_type} type disk ${disk_path} for all worker nodes
add_disk ${worker_node} ${disk_type} ${disk_path}
END

Set node ${node_id} with
[Arguments] &{config}
${node_name} = get_node_by_index ${node_id}
set_node ${node_name} &{config}

Disable node ${node_id} scheduling
${node_name} = get_node_by_index ${node_id}
disable_node_scheduling ${node_name}
Expand Down
7 changes: 7 additions & 0 deletions e2e/keywords/volume.resource
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ Wait for volume ${volume_id} detached
${volume_name} = generate_name_with_suffix volume ${volume_id}
wait_for_volume_detached ${volume_name}

Assert volume ${volume_id} remains detached for at least ${period} seconds
${volume_name} = generate_name_with_suffix volume ${volume_id}
FOR ${i} IN RANGE ${period}
wait_for_volume_detached ${volume_name}
Sleep 1
END

Wait for volume ${volume_id} faulted
${volume_name} = generate_name_with_suffix volume ${volume_id}
wait_for_volume_faulted ${volume_name}
Expand Down
4 changes: 4 additions & 0 deletions e2e/libs/keywords/node_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def disable_default_disk(self, node_name):
def enable_default_disk(self, node_name):
self.node.set_default_disk_scheduling(node_name, allowScheduling=True)

def set_node(self, node_name, allowScheduling=True, evictionRequested=False):
logging(f"Setting node {node_name}; scheduling={allowScheduling}; evictionRequested={evictionRequested}")
self.node.set_node(node_name, allowScheduling, evictionRequested)

def disable_node_scheduling(self, node_name):
self.node.set_node_scheduling(node_name, allowScheduling=False)

Expand Down
22 changes: 22 additions & 0 deletions e2e/libs/node/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,28 @@ def filter_nodes(nodes, condition):
elif role == "worker":
return worker_nodes

def set_node(self, node_name: str, allowScheduling: bool, evictionRequested: bool) -> object:
for _ in range(self.retry_count):
try:
node = get_longhorn_client().by_id_node(node_name)

get_longhorn_client().update(
node,
allowScheduling=allowScheduling,
evictionRequested=evictionRequested
)

node = get_longhorn_client().by_id_node(node_name)
assert node.allowScheduling == allowScheduling
assert node.evictionRequested == evictionRequested
return node
except Exception as e:
logging(f"Updating node {node_name} error: {e}")

time.sleep(self.retry_interval)

raise AssertionError(f"Updating node {node_name} failed")

def set_node_scheduling(self, node_name, allowScheduling=True, retry=False):
node = get_longhorn_client().by_id_node(node_name)

Expand Down
18 changes: 18 additions & 0 deletions e2e/tests/regression/test_volume.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Resource ../keywords/longhorn.resource
Resource ../keywords/persistentvolumeclaim.resource
Resource ../keywords/setting.resource
Resource ../keywords/workload.resource
Resource ../keywords/node.resource
Resource ../keywords/volume.resource

Test Setup Set test environment
Test Teardown Cleanup test resources
Expand Down Expand Up @@ -42,3 +44,19 @@ Test RWX volume data integrity after CSI plugin pod restart
... longhorn-csi-plugin

Then Check deployment 0 data in file data.txt is intact

Test detached volume should not reattach after node eviction
[Tags] volume node-eviction
[Documentation] Test detached volume should not reattach after node eviction.
...
... Issue: https://github.com/longhorn/longhorn/issues/9781
Given Create volume 0 with dataEngine=${DATA_ENGINE}
And Attach volume 0
And Wait for volume 0 healthy

When Detach volume 0
And Set node 1 with allowScheduling=false evictionRequested=true

Then Wait for volume 0 detached
And Assert volume 0 remains detached for at least 60 seconds

0 comments on commit 1e777ba

Please sign in to comment.