Module tests.test_rwx
Functions
def test_encrypted_rwx_volume(core_api, statefulset, storage_class, crypto_secret, pvc, make_deployment_with_pvc)
-
Test creating encrypted rwx volume and use the secret in non longhorn-system namespace.
- Create crypto secret in non longhorn-system namespace.
- Create a storage class.
- Create a deployment with a PVC and the pods should be able to running.
def test_restore_rwo_volume_to_rwx(set_random_backupstore, client, core_api, volume_name, pvc, csi_pv, pod_make, make_deployment_with_pvc)
-
Test restoring a rwo to a rwx volume.
- Create a volume with 'accessMode' rwo.
- Create a PV and a PVC with access mode 'readwriteonce' and attach to the volume.
- Create a pod and attach to the PVC.
- Write some data into the pod and compute md5sum.
- Take a backup of the volume.
- Restore the backup with 'accessMode' rwx.
- Create PV and PVC and attach to 2 pods.
- Verify the data.
-
Test moving of Share manager pod from one node to another.
- Create a StatefulSet of 1 pod with VolumeClaimTemplate where accessMode is 'RWX'.
- Wait for StatefulSet to come up healthy.
- Write data and compute md5sum.
- Delete the share manager pod.
- The workload pod should still be functioning and the volume should remain attached.
- Check the data md5sum in statefulSet.
- Write more data to it and compute md5sum.
- Check the data md5sum in share manager volume.
def test_rwx_deployment_with_multi_pods(core_api, pvc, make_deployment_with_pvc)
-
Test deployment of 2 pods with same PVC.
- Create a volume with 'accessMode' rwx.
- Create a PV and a PVC with access mode 'readwritemany' and attach to the volume.
- Create a deployment of 2 pods with PVC created
- Wait for 2 pods to come up healthy.
- Write data in both pods and compute md5sum.
- Check the data md5sum in the share manager pod.
def test_rwx_multi_statefulset_with_same_pvc(core_api, pvc, statefulset, pod)
-
Test writing of data into a volume from multiple pods using same PVC
- Create a volume with 'accessMode' rwx.
- Create a PV and a PVC with access mode 'readwritemany' and attach to the volume.
- Deploy a StatefulSet of 2 pods with the existing PVC above created.
- Wait for both pods to come up.
- Create a pod with the existing PVC above created.
- Wait for StatefulSet to come up healthy.
- Write data all three pods and compute md5sum.
- Check the data md5sum in the share manager pod.
def test_rwx_offline_expansion(client, core_api, pvc, make_deployment_with_pvc)
-
Related issue : https://github.com/longhorn/longhorn/issues/2181 https://github.com/longhorn/longhorn/issues/2484
This test case does not cover the UI test mentioned in the related issue's test steps."
Given - Create a rwx pvc using longhorn storage class of size 1 Gi.
And - Attach it to a workload (deployment) and write some data. - Scale down the workload, wait volume detached - Share manager pod will terminate automatically - Expand the volume to 4 Gi, wait exoansion complete
When - Scale up workload
Then - Share manager pod created - Volume healthy
And - 1.5 Gi of data is successfully written to the expanded volume
def test_rwx_online_expansion()
-
Related issue : https://github.com/longhorn/longhorn/issues/2181 https://github.com/longhorn/longhorn/issues/2484
This test case does not cover the UI test mentioned in the related issue's test steps."
Given - Create a rwx pvc using longhorn storage class of size 1 Gi.
And - Attach it to a workload (deployment) and write some data.
When - Expand the volume to 5 Gi
Then - Expansion of volume is completed. - Share manager pod not restart
And - 1.5 Gi of data is successfully written to the expanded volume.
def test_rwx_parallel_writing(core_api, statefulset, pod)
-
Test parallel writing of data
- Create a StatefulSet of 1 pod with VolumeClaimTemplate where accessMode is 'RWX'.
- Wait for StatefulSet to come up healthy.
- Create another statefulSet with same pvc which got created with first statefulSet.
- Wait for statefulSet to come up healthy.
- Start writing 800 MB data in first statefulSet
file 1
and start writing 500 MB data in second statefulSetfile 2
. - Compute md5sum.
- Check the data md5sum in share manager pod volume
def test_rwx_statefulset_scale_down_up(core_api, statefulset)
-
Test Scaling up and down of pods attached to rwx volume.
- Create a StatefulSet of 2 pods with VolumeClaimTemplate where accessMode is 'RWX'.
- Wait for StatefulSet pods to come up healthy.
- Write data and compute md5sum in the both pods.
- Delete the pods.
- Wait for the pods to be terminated.
- Verify the share manager pods are no longer available and the volume is detached.
- Recreate the pods
- Wait for new pods to come up.
- Check the data md5sum in new pods.
def test_rwx_volume_mount_options(core_api, storage_class, pvc, make_deployment_with_pvc)
-
Test creating rwx volume with custom mount options non longhorn-system namespace.
- Create a storage class with nfsOptions parameter.
- Create a deployment with a PVC and the pods should be able to run.
- Check the mounts on the deployment pods.
def test_rwx_with_statefulset_multi_pods(core_api, statefulset)
-
Test creation of share manager pod and rwx volumes from 2 pods.
- Create a StatefulSet of 2 pods with VolumeClaimTemplate where accessMode is 'RWX'.
- Wait for both pods to come up running.
- Verify there are two share manager pods created in the longhorn
namespace and they have the directory with the PV name in the
path
/export
- Write data in both pods and compute md5sum.
- Compare md5sum of the data with the data written the share manager.
def write_data_into_pod(pod_name_and_data_path)