Module tests.test_provisioner

Functions

def create_storage(api, sc_manifest, pvc_manifest)

Create a StorageClass and PersistentVolumeClaim for testing.

def test_provisioner_fs_format(client, core_api, storage_class, pvc, pod, inode_size, block_size)

Context: https://github.com/longhorn/longhorn/issues/4642 This is to test the FS format options are configured as mentioned in the storage class.

  1. Deploy a new storage class 'longhorn-provisioner' with mkfsParams param.
  2. Deploy a PVC and POD with the above storage class.
  3. A Longhorn volume should get created, verify the Inode size and block size. They should be same as the mkfsParams parameter.
def test_provisioner_generic_ephemeral()

Test that a Longhorn generic ephemeral volume can be created, mounted, unmounted, and deleted properly on the Kubernetes cluster.

  1. Create a StorageClass and Pod with a generic ephemeral volume spec: https://kubernetes.io/docs/concepts/storage/ephemeral-volumes
  2. Verify:
  3. The Pod is running.
  4. The volume parameters match the StorageClass parameters.
  5. The volume.status.kubernetesStatus.workloadStatus reflects the running Pod.
  6. Write data to the volume using the Pod, read it back, and verify it.
def test_provisioner_io(client, core_api, storage_class, pvc, pod)

Test that input and output on a StorageClass provisioned PersistentVolumeClaim works as expected.

Fixtures are torn down here in reverse order that they are specified as a parameter. Take caution when reordering test fixtures.

  1. Create a StorageClass, PVC and Pod.
  2. Wait for pod to be up.
  3. Write data to the pod
  4. Delete the original pod and create a new one using the same PVC
  5. Read the data from the new pod, verify the data.
def test_provisioner_mount(client, core_api, storage_class, pvc, pod)

Test that a StorageClass provisioned volume can be created, mounted, unmounted, and deleted properly on the Kubernetes cluster.

Fixtures are torn down here in reverse order that they are specified as a parameter. Take caution when reordering test fixtures.

  1. Create a StorageClass, PVC and Pod
  2. Verify the pod is up and volume parameters.
def test_provisioner_params(client, core_api, storage_class, pvc, pod)

Test that substituting different StorageClass parameters is reflected in the resulting PersistentVolumeClaim.

Fixtures are torn down here in reverse order that they are specified as a parameter. Take caution when reordering test fixtures.

  1. Create a StorageClass with replica 2 (instead of 3) etc.
  2. Create PVC and Pod using it.
  3. Verify the volume's parameter matches the Storage Class.
def test_provisioner_tags(client, core_api, node_default_tags, storage_class, pvc, pod)

Test that a StorageClass can properly provision a volume with requested Tags.

Test prerequisite: - set Replica Node Level Soft Anti-Affinity enabled

  1. Use node_default_tags to add default tags to nodes.
  2. Create a StorageClass with disk and node tag set.
  3. Create PVC and Pod.
  4. Verify the volume has the correct parameters and tags.