Skip to content

Commit

Permalink
test(recurring-job/fstrim): test RWO and RWX volume
Browse files Browse the repository at this point in the history
longhorn-7768

Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang authored and yangchiu committed Jan 28, 2024
1 parent 385cadb commit c6bebbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 11 additions & 4 deletions manager/integration/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@
FS_TYPE_EXT4 = "ext4"
FS_TYPE_XFS = "xfs"

ACCESS_MODE_RWO = "rwo"
ACCESS_MODE_RWX = "rwx"

ATTACHER_TYPE_CSI_ATTACHER = "csi-attacher"
ATTACHER_TYPE_LONGHORN_API = "longhorn-api"
ATTACHER_TYPE_LONGHORN_UPGRADER = "longhorn-upgrader"
Expand Down Expand Up @@ -493,7 +496,8 @@ def delete_backup_volume(client, volume_name):
def create_and_check_volume(client, volume_name,
num_of_replicas=3, size=SIZE, backing_image="",
frontend=VOLUME_FRONTEND_BLOCKDEV,
snapshot_data_integrity=SNAPSHOT_DATA_INTEGRITY_IGNORED): # NOQA
snapshot_data_integrity=SNAPSHOT_DATA_INTEGRITY_IGNORED, # NOQA
access_mode=ACCESS_MODE_RWO):
"""
Create a new volume with the specified parameters. Assert that the new
volume is detached and that all of the requested parameters match.
Expand All @@ -512,7 +516,8 @@ def create_and_check_volume(client, volume_name,
client.create_volume(name=volume_name, size=size,
numberOfReplicas=num_of_replicas,
backingImage=backing_image, frontend=frontend,
snapshotDataIntegrity=snapshot_data_integrity)
snapshotDataIntegrity=snapshot_data_integrity,
accessMode=access_mode)
volume = wait_for_volume_detached(client, volume_name)
assert volume.name == volume_name
assert volume.size == size
Expand Down Expand Up @@ -4987,7 +4992,8 @@ def prepare_statefulset_with_data_in_mb(
def prepare_pod_with_data_in_mb(
client, core_api, csi_pv, pvc, pod_make, volume_name,
volume_size=str(1*Gi), num_of_replicas=3, data_path="/data/test",
data_size_in_mb=DATA_SIZE_IN_MB_1, add_liveness_probe=True):# NOQA:
data_size_in_mb=DATA_SIZE_IN_MB_1, add_liveness_probe=True,
access_mode=ACCESS_MODE_RWO):# NOQA:

pod_name = volume_name + "-pod"
pv_name = volume_name
Expand All @@ -5012,7 +5018,8 @@ def prepare_pod_with_data_in_mb(

create_and_check_volume(client, volume_name,
num_of_replicas=num_of_replicas,
size=volume_size)
size=volume_size,
access_mode=access_mode)
core_api.create_persistent_volume(csi_pv)
core_api.create_namespaced_persistent_volume_claim(
body=pvc, namespace='default')
Expand Down
8 changes: 6 additions & 2 deletions manager/integration/tests/test_recurring_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
from common import wait_for_cron_job_create
from common import wait_for_cron_job_delete

from common import ACCESS_MODE_RWO
from common import ACCESS_MODE_RWX
from common import JOB_LABEL
from common import KUBERNETES_STATUS_LABEL
from common import LONGHORN_NAMESPACE
Expand Down Expand Up @@ -2082,7 +2084,8 @@ def test_recurring_job_restored_from_backup_target(set_random_backupstore, clien


@pytest.mark.recurring_job # NOQA
def test_recurring_job_filesystem_trim(client, core_api, batch_v1_api, volume_name, csi_pv, pvc, pod_make): # NOQA
@pytest.mark.parametrize("access_mode", [ACCESS_MODE_RWO, ACCESS_MODE_RWX]) # NOQA
def test_recurring_job_filesystem_trim(client, core_api, batch_v1_api, volume_name, csi_pv, pvc, pod_make, access_mode): # NOQA
"""
Scenario: test recurring job filesystem-trim
Expand All @@ -2103,7 +2106,8 @@ def test_recurring_job_filesystem_trim(client, core_api, batch_v1_api, volume_na
"""
pod_name, _, _, _ = \
prepare_pod_with_data_in_mb(client, core_api, csi_pv, pvc, pod_make,
volume_name, data_size_in_mb=10)
volume_name, data_size_in_mb=10,
access_mode=access_mode)

volume = client.by_id_volume(volume_name)

Expand Down

0 comments on commit c6bebbe

Please sign in to comment.