Module tests.test_cloning

Functions

def clone_pod(request)
def clone_pvc(request)
def test_cloning_basic(client, core_api, pvc, pod, clone_pvc, clone_pod, storage_class_name='longhorn')
  1. Create a PVC: yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: source-pvc spec: storageClassName: longhorn accessModes: - ReadWriteOnce resources: requests: storage: 3Gi
  2. Specify the source-pvc in a pod yaml and start the pod
  3. Wait for the pod to be running, write some data to the mount path of the volume
  4. Clone a volume by creating the PVC: yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: cloned-pvc spec: storageClassName: longhorn dataSource: name: source-pvc kind: PersistentVolumeClaim accessModes: - ReadWriteOnce resources: requests: storage: 3Gi
  5. Wait for the CloneStatus.State in cloned-pvc to be completed
  6. Clone volume should get detached after cloning completion, wait for it.
  7. Specify the cloned-pvc in a cloned pod yaml and deploy the cloned pod
  8. In 3-min retry loop, wait for the cloned pod to be running
  9. Verify the data in cloned-pvc is the same as in source-pvc
  10. In 2-min retry loop, verify the volume of the clone-pvc eventually becomes healthy
def test_cloning_interrupted(client, core_api, pvc, pod, clone_pvc, clone_pod)
  1. Create a PVC: yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: source-pvc spec: storageClassName: longhorn accessModes: - ReadWriteOnce resources: requests: storage: 3Gi
  2. Specify the source-pvc in a pod yaml and start the pod
  3. Wait for the pod to be running, write 500MB of data to the mount path of the volume
  4. Clone a volume by creating the PVC: yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: cloned-pvc spec: storageClassName: longhorn dataSource: name: source-pvc kind: PersistentVolumeClaim accessModes: - ReadWriteOnce resources: requests: storage: 3Gi
  5. Wait for the CloneStatus.State in cloned-pvc to be initiated
  6. Kill all replicas process of the source-pvc
  7. Wait for the CloneStatus.State in cloned-pvc to be failed
  8. Clean up clone-pvc
  9. Redeploy cloned-pvc and clone pod
  10. In 3-min retry loop, verify cloned pod become running
  11. cloned-pvc has the same data as source-pvc
  12. In 2-min retry loop, verify the volume of the clone-pvc eventually becomes healthy.
def test_cloning_with_backing_image(client, core_api, pvc, pod, clone_pvc, clone_pod, storage_class)
  1. Deploy a storage class that has backing image parameter yaml kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: longhorn-bi-parrot provisioner: driver.longhorn.io allowVolumeExpansion: true parameters: numberOfReplicas: "3" staleReplicaTimeout: "2880" # 48 hours in minutes backingImage: "bi-parrot" backingImageDataSourceType: "download" backing_image_data_source_parameters = ( '{"url": "https://backing-image-example.s3-region.amazonaws.com/' 'test-backing-image"}' )
  2. Repeat the test_cloning_without_backing_image() test with source-pvc and cloned-pvc use longhorn-bi-parrot instead of longhorn storageclass
  3. Clean up the test
def test_cloning_with_detached_source_volume(client, core_api, pvc, clone_pvc)
  1. Create a PVC: yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: source-pvc spec: storageClassName: longhorn accessModes: - ReadWriteOnce resources: requests: storage: 3Gi
  2. Wait for volume to be created and attach it to a node.
  3. Write some data to the mount path of the volume
  4. Detach the volume and wait for the volume to be in detached state.
  5. Clone a volume by creating the PVC: yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: cloned-pvc spec: storageClassName: longhorn dataSource: name: source-pvc kind: PersistentVolumeClaim accessModes: - ReadWriteOnce resources: requests: storage: 3Gi
  6. Wait for the CloneStatus.State in cloned-pvc to be completed
  7. Wait for source-pvc to be detached
  8. Attach the cloned volume to a node
  9. Verify the data in cloned-pvc is the same as in source-pvc.
  10. In 2-min retry loop, verify the volume of the clone-pvc eventually becomes healthy.
  11. Verify snapshot created in source-pvc volume because of the clone