Skip to content

Commit

Permalink
Adds nfsv4 PVC scenario to the integration test
Browse files Browse the repository at this point in the history
The longhorn-share-manager rock is currently untested because it's not
needed for ReadWriteOnce PVCs (ext4 volumes).

The integration test now also creates a Pod with a ReadWriteMany PVC,
which will result in a nfsv4 mount, which will require the
longhorn-share-manager rock to work properly.
  • Loading branch information
claudiubelu committed Sep 16, 2024
1 parent 3c7d372 commit 0b75195
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 27 deletions.
60 changes: 33 additions & 27 deletions tests/integration/test_longhorn_in_helm_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,33 +210,39 @@ def test_longhorn_helm_chart_deployment(
function_instance, CSI_VOLUME_ANNOTATION, LONGHORN_CSI_ANNOTATION_VALUE
)

# Deploy an nginx Pod with a PVC, which should be satisfied by Longhorn.
function_instance.exec(
["k8s", "kubectl", "apply", "-f", "-"],
input=pathlib.Path(TEMPLATES_DIR / "nginx-pod.yaml").read_bytes(),
)
# Deploy nginx Pods with PVCs, which should be satisfied by Longhorn.
for yaml_file in ["nginx-pod.yaml", "nginx-nfs-pod.yaml"]:
function_instance.exec(
["k8s", "kubectl", "apply", "-f", "-"],
input=pathlib.Path(TEMPLATES_DIR / yaml_file).read_bytes(),
)

# Expect the Pod to become ready, and that it has the volume attached.
k8s_util.wait_for_resource(
function_instance,
"pod",
"nginx-longhorn-example",
condition=constants.K8S_CONDITION_READY,
)
# Expect the Pods to become ready, and that they have the volume attached.
expected_outputs = {
"nginx-longhorn-example": "ext4 /var/www /dev/longhorn/pvc-",
"nginx-longhorn-nfs-example": "nfs4 /var/www ",
}
for pod_name, expected_output in expected_outputs.items():
k8s_util.wait_for_resource(
function_instance,
"pod",
pod_name,
condition=constants.K8S_CONDITION_READY,
)

process = function_instance.exec(
[
"k8s",
"kubectl",
"exec",
"nginx-longhorn-example",
"--",
"bash",
"-c",
"findmnt /var/www -o FSTYPE,TARGET,SOURCE",
],
capture_output=True,
text=True,
)
process = function_instance.exec(
[
"k8s",
"kubectl",
"exec",
pod_name,
"--",
"bash",
"-c",
"findmnt /var/www -o FSTYPE,TARGET,SOURCE",
],
capture_output=True,
text=True,
)

assert "ext4 /var/www /dev/longhorn/pvc-" in process.stdout
assert expected_output in process.stdout
28 changes: 28 additions & 0 deletions tests/templates/nginx-nfs-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: longhorn-nfs-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: longhorn
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-longhorn-nfs-example
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: longhorn-pvc
mountPath: /var/www
readOnly: false
volumes:
- name: longhorn-pvc
persistentVolumeClaim:
claimName: longhorn-nfs-pvc

0 comments on commit 0b75195

Please sign in to comment.