diff --git a/e2e/keywords/statefulset.resource b/e2e/keywords/statefulset.resource index 5b679c230..bba98e643 100644 --- a/e2e/keywords/statefulset.resource +++ b/e2e/keywords/statefulset.resource @@ -35,10 +35,6 @@ Scale up statefulset ${statefulset_id} to attach volume ${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id} scale_statefulset_up ${statefulset_name} -Expand statefulset ${statefulset_id} volume by ${size} MiB - ${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id} - expand_workload_claim_size_by_mib ${statefulset_name} ${size} - Write ${size} MB data to file ${file_name} in statefulset ${statefulset_id} ${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id} write_workload_pod_random_data ${statefulset_name} ${size} ${file_name} diff --git a/e2e/keywords/workload.resource b/e2e/keywords/workload.resource index fcf9ca755..13e0926df 100644 --- a/e2e/keywords/workload.resource +++ b/e2e/keywords/workload.resource @@ -232,3 +232,9 @@ Check volume of ${workload_kind} ${workload_id} replica on node ${node_id} disk ${disk_uuid} = get_disk_uuid ${node_name} ${disk_name} ${replicas} = get_replicas volume_name=${volume_name} node_name=${node_name} disk_uuid=${disk_uuid} Should Be True len(${replicas}) > 0 + +Expand ${workload_kind} ${workload_id} volume by ${size} + ${workload_name} = generate_name_with_suffix ${workload_kind} ${workload_id} + ${new_size} = convert_size_to_bytes ${size} + + expand_workload_claim_size ${workload_name} ${new_size} diff --git a/e2e/libs/keywords/workload_keywords.py b/e2e/libs/keywords/workload_keywords.py index d34fb1567..41f2e0e5c 100644 --- a/e2e/libs/keywords/workload_keywords.py +++ b/e2e/libs/keywords/workload_keywords.py @@ -28,10 +28,10 @@ from utility.constant import ANNOT_CHECKSUM from utility.constant import ANNOT_EXPANDED_SIZE from utility.constant import LABEL_LONGHORN_COMPONENT +from utility.utility import convert_size_to_bytes from utility.utility import logging from volume import Volume -from volume.constant import MEBIBYTE class workload_keywords: @@ -158,11 +158,12 @@ def wait_for_workload_volume_detached(self, workload_name): logging(f'Waiting for {workload_name} volume {volume_name} to be detached') self.volume.wait_for_volume_detached(volume_name) - def expand_workload_claim_size_by_mib(self, workload_name, size_in_mib, claim_index=0): + def expand_workload_claim_size(self, workload_name, size_in_byte, claim_index=0): claim_name = get_workload_persistent_volume_claim_name(workload_name, index=claim_index) - size_in_byte = int(size_in_mib) * MEBIBYTE + current_size = self.persistentvolumeclaim.get(claim_name).spec.resources.requests['storage'] + current_size_byte = convert_size_to_bytes(current_size) - logging(f'Expanding {workload_name} persistentvolumeclaim {claim_name} by {size_in_mib} MiB') + logging(f'Expanding {workload_name} persistentvolumeclaim {claim_name} from {current_size_byte} to {size_in_byte}') self.persistentvolumeclaim.expand(claim_name, size_in_byte) def wait_for_workload_claim_size_expanded(self, workload_name, claim_index=0): diff --git a/e2e/libs/utility/utility.py b/e2e/libs/utility/utility.py index bfe8073d7..c690895aa 100644 --- a/e2e/libs/utility/utility.py +++ b/e2e/libs/utility/utility.py @@ -338,3 +338,18 @@ def get_name_suffix(*args): if arg: suffix += f"-{arg}" return suffix + + +def convert_size_to_bytes(size): + size = size.replace(" ", "") + + if size.endswith("GiB"): + return int(size[:-3]) * 1024 * 1024 * 1024 + + if size.endswith("MiB"): + return int(size[:-3]) * 1024 * 1024 + + if size.isdigit(): + return int(size) + + raise ValueError(f"Invalid size format: {size}")