Skip to content

Commit fc2311d

Browse files
roger-ryaoyangchiu
authored andcommitted
test(robot): refactor block device size assertion to use retry-based helper
- Add `wait_for_block_device_size_in_pod` method in workload_keywords.py that polls until block device size matches expected value, with retry logic - Replace inline `blockdev --getsize64` one-time check in deployment.resource with the new `wait_for_block_device_size_in_pod` helper call - Remove `BLOCK_DEVICE_NAME/DIR/PATH` variables from variables.resource in favor of `BLOCK_PVC_VOLUME_DEVICE_PATH` constant Signed-off-by: Roger Yao <roger.yao@suse.com>
1 parent eb6d8c5 commit fc2311d

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

e2e/keywords/deployment.resource

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Library ../libs/keywords/deployment_keywords.py
77
Library ../libs/keywords/node_keywords.py
88
Library ../libs/keywords/workload_keywords.py
99
Library ../libs/keywords/volume_keywords.py
10-
Resource variables.resource
1110

1211
*** Keywords ***
1312
Create deployment ${deployment_id} with persistentvolumeclaim ${claim_id}
@@ -137,7 +136,4 @@ Assert block device size in deployment pod for deployment ${deployment_id} is ${
137136
${expected_bytes} = convert_size_to_bytes ${size} to_str=True
138137
${deployment_name} = generate_name_with_suffix deployment ${deployment_id}
139138
${pod_name} = get_workload_pod_name ${deployment_name}
140-
${cmd} = Set Variable blockdev --getsize64 ${BLOCK_DEVICE_PATH}
141-
${result} = pod_exec ${pod_name} default ${cmd}
142-
Should Be Equal As Integers ${result.strip()} ${expected_bytes}
143-
... msg=Block device size in pod ${pod_name}: expected ${expected_bytes} B, got ${result.strip()} B
139+
wait_for_block_device_size_in_pod ${pod_name} ${expected_bytes}

e2e/keywords/sharemanager.resource

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ Wait for sharemanager pod of ${workload_kind} ${workload_id} deleted
4949

5050
Assert disk size in sharemanager pod for ${workload_kind} ${workload_id} is ${size}
5151
${expected_size_byte} = convert_size_to_bytes ${size} to_str=True
52-
5352
${workload_name}= generate_name_with_suffix ${workload_kind} ${workload_id}
5453
${volume_name}= get_workload_volume_name ${workload_name}
5554
${share_manager_pod}= Set Variable share-manager-${volume_name}

e2e/keywords/variables.resource

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ ${VOLUME_STATE_CHECK_TIMEOUT} 120
1212
${LONGHORN_NAMESPACE} longhorn-system
1313
${DEFAULT_BLOCK_DISK_NAME} block-disk
1414

15-
# Block volume device path (volumeMode=Block)
16-
${BLOCK_DEVICE_NAME} longhorn-testblk
17-
${BLOCK_DEVICE_DIR} /dev/longhorn
18-
${BLOCK_DEVICE_PATH} ${BLOCK_DEVICE_DIR}/${BLOCK_DEVICE_NAME}
19-
2015
@{powered_off_nodes}=
2116

2217
&{volume_checksums}=

e2e/libs/keywords/workload_keywords.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from utility.constant import ANNOT_CHECKSUM
4848
from utility.constant import ANNOT_EXPANDED_SIZE
4949
from utility.constant import LABEL_LONGHORN_COMPONENT
50+
from utility.constant import BLOCK_PVC_VOLUME_DEVICE_PATH
5051
import utility.constant as constant
5152
from utility.utility import convert_size_to_bytes
5253
from utility.utility import logging
@@ -485,3 +486,20 @@ def verify_fio_data_integrity_in_workload(self, workload_name, namespace="defaul
485486
raise AssertionError(f"FIO verification failed with errors: {resp}")
486487

487488
logging(f"FIO data integrity verification passed")
489+
490+
def wait_for_block_device_size_in_pod(self, pod_name, expected_size, namespace="default"):
491+
for i in range(self.retry_count):
492+
logging(f"Waiting for block device size in pod {pod_name} to be {expected_size} ... ({i})")
493+
time.sleep(self.retry_interval)
494+
cmd = f"blockdev --getsize64 {BLOCK_PVC_VOLUME_DEVICE_PATH}"
495+
try:
496+
result = pod_exec(pod_name, namespace, cmd)
497+
actual_size = result.strip()
498+
logging(f"Current block device size in pod {pod_name}: {actual_size}, expected: {expected_size}")
499+
if actual_size == expected_size:
500+
return
501+
except Exception as e:
502+
logging(f"Error checking block device size in pod {pod_name}: {e}")
503+
continue
504+
505+
assert False, f"Block device size in pod {pod_name} is not {expected_size}"

0 commit comments

Comments
 (0)