Skip to content

Commit

Permalink
refactor(robot): add storage_size for pvc creation
Browse files Browse the repository at this point in the history
longhorn/longhorn-6633

Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang committed Dec 6, 2024
1 parent 9ae25ba commit 696232f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion e2e/keywords/persistentvolumeclaim.resource
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Library ../libs/keywords/volume_keywords.py

*** Keywords ***
Create persistentvolumeclaim ${claim_id} using ${volume_type} volume
[Arguments] &{config}
${claim_name} = generate_name_with_suffix claim ${claim_id}
create_persistentvolumeclaim ${claim_name} ${volume_type}
create_persistentvolumeclaim ${claim_name} ${volume_type} &{config}

Create persistentvolumeclaim ${claim_id} using ${volume_type} volume with ${sc_name} storageclass
${claim_name} = generate_name_with_suffix claim ${claim_id}
Expand Down
4 changes: 2 additions & 2 deletions e2e/libs/keywords/persistentvolumeclaim_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def cleanup_persistentvolumeclaims(self):
for claim in claims.items:
self.delete_persistentvolumeclaim(claim.metadata.name)

def create_persistentvolumeclaim(self, name, volume_type="RWO", sc_name="longhorn"):
def create_persistentvolumeclaim(self, name, volume_type="RWO", sc_name="longhorn", storage_size="3Gi"):
logging(f'Creating {volume_type} persistentvolumeclaim {name} with {sc_name} storageclass')
return self.claim.create(name, volume_type, sc_name)
return self.claim.create(name, volume_type, sc_name, storage_size)

def delete_persistentvolumeclaim(self, name):
logging(f'Deleting persistentvolumeclaim {name}')
Expand Down
8 changes: 7 additions & 1 deletion e2e/libs/persistentvolumeclaim/persistentvolumeclaim.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from utility.constant import ANNOT_EXPANDED_SIZE
from utility.constant import LABEL_TEST
from utility.constant import LABEL_TEST_VALUE
from utility.utility import convert_size_to_bytes
from utility.utility import get_retry_count_and_interval
from utility.utility import logging

Expand All @@ -23,7 +24,9 @@ def __init__(self):
if self._strategy == LonghornOperationStrategy.CRD:
self.claim = CRD()

def create(self, name, volume_type, sc_name):
def create(self, name, volume_type, sc_name, storage_size="3GiB"):
storage_size_bytes = convert_size_to_bytes(storage_size)

filepath = "./templates/workload/pvc.yaml"
with open(filepath, 'r') as f:
namespace = 'default'
Expand All @@ -38,6 +41,9 @@ def create(self, name, volume_type, sc_name):
# correct storageclass name
manifest_dict['spec']['storageClassName'] = sc_name

# correct storage request
manifest_dict['spec']['resources']['requests']['storage'] = storage_size_bytes

# correct access mode`
if volume_type == 'RWX':
manifest_dict['spec']['accessModes'][0] = 'ReadWriteMany'
Expand Down

0 comments on commit 696232f

Please sign in to comment.