test: refactor verify example test

fix image
This commit is contained in:
andyzhangx 2021-01-18 13:51:32 +00:00
parent 7271a3cc0f
commit 67218855ab
4 changed files with 34 additions and 14 deletions

View File

@ -119,10 +119,4 @@ e2e-teardown:
.PHONY: e2e-test
e2e-test:
go test -v -timeout=0 ./test/e2e ${GINKGO_FLAGS}
.PHONY: create-example-deployment
create-example-deployment:
kubectl apply -f ./deploy/example/storageclass-nfs.yaml
kubectl apply -f ./deploy/example/deployment.yaml
kubectl apply -f ./deploy/example/statefulset.yaml
go test -v -timeout=0 ./test/e2e ${GINKGO_FLAGS}

View File

@ -30,7 +30,7 @@ spec:
"kubernetes.io/os": linux
containers:
- name: deployment-nfs
image: mcr.icrosoft.com/oss/nginx/nginx:1.19.5
image: mcr.microsoft.com/oss/nginx/nginx:1.19.5
command:
- "/bin/bash"
- "-c"

30
hack/verify-examples.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# Copyright 2020 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
echo "begin to create deployment examples ..."
kubectl apply -f ./deploy/example/storageclass-nfs.yaml
kubectl apply -f ./deploy/example/deployment.yaml
kubectl apply -f ./deploy/example/statefulset.yaml
echo "sleep 60s ..."
sleep 60
kubectl get pods --field-selector status.phase=Running | grep deployment-nfs
kubectl get pods --field-selector status.phase=Running | grep statefulset-nfs-0
echo "deployment examples running completed."

View File

@ -26,8 +26,6 @@ import (
"strings"
"testing"
"time"
"github.com/kubernetes-csi/csi-driver-nfs/pkg/nfs"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
@ -96,14 +94,12 @@ var _ = ginkgo.BeforeSuite(func() {
var _ = ginkgo.AfterSuite(func() {
createExampleDeployment := testCmd{
command: "make",
args: []string{"create-example-deployment"},
command: "bash",
args: []string{"hack/verify-examples.sh"},
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",