Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds nfsv4 PVC scenario to the integration test #30

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading