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

test: add more test cases for e2e test #92

Merged
merged 1 commit into from
Nov 17, 2020
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
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ push:

.PHONY: install-nfs-server
install-nfs-server:
kubectl apply -f ./examples/kubernetes/nfs-server/nfs-server.yaml
kubectl apply -f ./examples/nfs-server.yaml

.PHONY: install-helm
install-helm:
Expand All @@ -111,4 +111,10 @@ e2e-teardown:

.PHONY: e2e-test
e2e-test:
go test -v -timeout=0 ./test/e2e ${GINKGO_FLAGS}
go test -v -timeout=0 ./test/e2e ${GINKGO_FLAGS}

.PHONY: create-example-deployment
create-example-deployment:
kubectl apply -f ./examples/storageclass-nfs.yaml
kubectl apply -f ./examples/deployment.yaml
kubectl apply -f ./examples/statefulset.yaml
4 changes: 2 additions & 2 deletions deploy/install-driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ if [[ "$#" -gt 0 ]]; then
ver="$1"
fi

repo="https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/$ver/deploy/kubernetes"
repo="https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/$ver/deploy"
if [[ "$#" -gt 1 ]]; then
if [[ "$2" == *"local"* ]]; then
echo "use local deploy"
repo="./deploy/kubernetes"
repo="./deploy"
fi
fi

Expand Down
4 changes: 2 additions & 2 deletions deploy/uninstall-driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ if [[ "$#" -gt 0 ]]; then
ver="$1"
fi

repo="https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/$ver/deploy/kubernetes"
repo="https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/$ver/deploy"
if [[ "$#" -gt 1 ]]; then
if [[ "$2" == *"local"* ]]; then
echo "use local deploy"
repo="./deploy/kubernetes"
repo="./deploy"
fi
fi

Expand Down
File renamed without changes.
43 changes: 43 additions & 0 deletions examples/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-deployment-nfs
spec:
accessModes:
- ReadWriteMany # In this example, multiple Pods consume the same PVC.
resources:
requests:
storage: 10Gi
storageClassName: nfs-csi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-nfs-rwm
spec:
replicas: 3
selector:
matchLabels:
name: deployment-nfs-rwm
template:
metadata:
name: deployment-nfs-rwm
labels:
name: deployment-nfs-rwm
spec:
containers:
containers:
- name: deployment-nfs-rwm
image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine
command:
- "/bin/sh"
- "-c"
- while true; do echo $(hostname) $(date) >> /mnt/nfs/outfile; sleep 1; done
volumeMounts:
- name: nfs
mountPath: "/mnt/nfs"
volumes:
- name: nfs
persistentVolumeClaim:
claimName: pvc-deployment-nfs
65 changes: 0 additions & 65 deletions examples/kubernetes/nfs-server/deployment.yaml

This file was deleted.

52 changes: 0 additions & 52 deletions examples/kubernetes/nginx.yaml

This file was deleted.

File renamed without changes.
31 changes: 31 additions & 0 deletions examples/nginx-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-nginx
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi
storageClassName: nfs-csi
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- image: nginx
name: nginx
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- mountPath: /var/www
name: pvc-nginx
volumes:
- name: pvc-nginx
persistentVolumeClaim:
claimName: pvc-nginx
21 changes: 21 additions & 0 deletions examples/pv-nfs-csi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-nfs
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
mountOptions:
- hard
- nfsvers=4.1
csi:
driver: nfs.csi.k8s.io
readOnly: false
volumeHandle: unique-volumeid # make sure it's a unique id in the cluster
volumeAttributes:
server: nfs-server.default.svc.cluster.local
share: /
12 changes: 12 additions & 0 deletions examples/pvc-nfs-csi-dynamic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-nfs-dynamic
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
storageClassName: nfs-csi
13 changes: 13 additions & 0 deletions examples/pvc-nfs-csi-static.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-nfs-static
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
volumeName: pv-nfs
storageClassName: ""
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
app: nginx
spec:
serviceName: statefulset-nfs
replicas: 1
replicas: 3
template:
metadata:
labels:
Expand Down
37 changes: 35 additions & 2 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"strings"
"testing"

"time"

"github.com/kubernetes-csi/csi-driver-nfs/pkg/nfs"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
Expand Down Expand Up @@ -76,14 +78,45 @@ var _ = ginkgo.BeforeSuite(func() {
})

var _ = ginkgo.AfterSuite(func() {
createExampleDeployment := testCmd{
command: "make",
args: []string{"create-example-deployment"},
startLog: "create example deployments",
endLog: "example deployments created",
}
execTestCmd([]testCmd{createExampleDeployment})
// sleep 120s waiting for deployment running complete
time.Sleep(120 * time.Second)

nfsLog := testCmd{
command: "bash",
args: []string{"test/utils/nfs_log.sh"},
startLog: "===================nfs log===================",
endLog: "==================================================",
}

e2eTeardown := testCmd{
command: "make",
args: []string{"e2e-teardown"},
startLog: "Uninstalling NFS CSI Driver...",
endLog: "NFS Driver uninstalled",
}
execTestCmd([]testCmd{e2eTeardown})

execTestCmd([]testCmd{nfsLog, e2eTeardown})

// install/uninstall CSI Driver deployment scripts test
installDriver := testCmd{
command: "bash",
args: []string{"deploy/install-driver.sh", "master", "local"},
startLog: "===================install CSI Driver deployment scripts test===================",
endLog: "===================================================",
}
uninstallDriver := testCmd{
command: "bash",
args: []string{"deploy/uninstall-driver.sh", "master", "local"},
startLog: "===================uninstall CSI Driver deployment scripts test===================",
endLog: "===================================================",
}
execTestCmd([]testCmd{installDriver, uninstallDriver})
})

// handleFlags sets up all flags and parses the command line.
Expand Down
Loading