Skip to content

Commit

Permalink
test(robot): add block disk back to previously deleted node for v2 te…
Browse files Browse the repository at this point in the history
…st cases

Signed-off-by: Yang Chiu <[email protected]>
  • Loading branch information
yangchiu committed Dec 13, 2024
1 parent f360ab1 commit 0dbec1c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions e2e/keywords/k8s.resource
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Delete volume of ${workload_kind} ${workload_id} replica node

Add deleted node back
reboot_node_by_name ${deleted_node}
${host_provider}= Get Environment Variable HOST_PROVIDER
${disk_path}= Set Variable If "${host_provider}" == "harvester" /dev/vdc /dev/xvdh
add_disk block-disk ${deleted_node} block ${disk_path}

Force drain volume of ${workload_kind} ${workload_id} volume node
${workload_name} = generate_name_with_suffix ${workload_kind} ${workload_id}
Expand Down
17 changes: 13 additions & 4 deletions e2e/libs/node/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,19 @@ def wait_for_disk_update(self, node_name, disk_num):
assert len(node.disks) == disk_num, f"Waiting for node {node_name} disk updated to {disk_num} failed: {disks}"

def add_disk(self, node_name, disk):
node = get_longhorn_client().by_id_node(node_name)
disks = node.disks
disks.update(disk)
self.update_disks(node_name, disks)
added = False
for i in range(self.retry_count):
try:
node = get_longhorn_client().by_id_node(node_name)
disks = node.disks
disks.update(disk)
self.update_disks(node_name, disks)
added = True
break
except Exception as e:
logging(f"Adding disk {disk} to node {node_name} error: {e}")
time.sleep(self.retry_interval)
assert added, f"Adding disk {disk} to node {node_name} failed"

def reset_disks(self, node_name):
node = get_longhorn_client().by_id_node(node_name)
Expand Down

0 comments on commit 0dbec1c

Please sign in to comment.