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.

  1. Create crypto secret in non longhorn-system namespace.
  2. Create a storage class.
  3. 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.

  1. Create a volume with 'accessMode' rwo.
  2. Create a PV and a PVC with access mode 'readwriteonce' and attach to the volume.
  3. Create a pod and attach to the PVC.
  4. Write some data into the pod and compute md5sum.
  5. Take a backup of the volume.
  6. Restore the backup with 'accessMode' rwx.
  7. Create PV and PVC and attach to 2 pods.
  8. Verify the data.
def test_rwx_delete_share_manager_pod(core_api, statefulset)

Test moving of Share manager pod from one node to another.

  1. Create a StatefulSet of 1 pod with VolumeClaimTemplate where accessMode is 'RWX'.
  2. Wait for StatefulSet to come up healthy.
  3. Write data and compute md5sum.
  4. Delete the share manager pod.
  5. The workload pod should still be functioning and the volume should remain attached.
  6. Check the data md5sum in statefulSet.
  7. Write more data to it and compute md5sum.
  8. 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.

  1. Create a volume with 'accessMode' rwx.
  2. Create a PV and a PVC with access mode 'readwritemany' and attach to the volume.
  3. Create a deployment of 2 pods with PVC created
  4. Wait for 2 pods to come up healthy.
  5. Write data in both pods and compute md5sum.
  6. 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

  1. Create a volume with 'accessMode' rwx.
  2. Create a PV and a PVC with access mode 'readwritemany' and attach to the volume.
  3. Deploy a StatefulSet of 2 pods with the existing PVC above created.
  4. Wait for both pods to come up.
  5. Create a pod with the existing PVC above created.
  6. Wait for StatefulSet to come up healthy.
  7. Write data all three pods and compute md5sum.
  8. 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

  1. Create a StatefulSet of 1 pod with VolumeClaimTemplate where accessMode is 'RWX'.
  2. Wait for StatefulSet to come up healthy.
  3. Create another statefulSet with same pvc which got created with first statefulSet.
  4. Wait for statefulSet to come up healthy.
  5. Start writing 800 MB data in first statefulSet file 1 and start writing 500 MB data in second statefulSet file 2.
  6. Compute md5sum.
  7. 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.

  1. Create a StatefulSet of 2 pods with VolumeClaimTemplate where accessMode is 'RWX'.
  2. Wait for StatefulSet pods to come up healthy.
  3. Write data and compute md5sum in the both pods.
  4. Delete the pods.
  5. Wait for the pods to be terminated.
  6. Verify the share manager pods are no longer available and the volume is detached.
  7. Recreate the pods
  8. Wait for new pods to come up.
  9. 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.

  1. Create a storage class with nfsOptions parameter.
  2. Create a deployment with a PVC and the pods should be able to run.
  3. 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.

  1. Create a StatefulSet of 2 pods with VolumeClaimTemplate where accessMode is 'RWX'.
  2. Wait for both pods to come up running.
  3. 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
  4. Write data in both pods and compute md5sum.
  5. Compare md5sum of the data with the data written the share manager.
def write_data_into_pod(pod_name_and_data_path)