From 3ae2be56f7381faee9d6da39005cd14e03c81e91 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Fri, 14 Aug 2020 13:54:26 +0000 Subject: [PATCH] test: add sanity test test: add sanity test revert go mod change run all sanity tests move to Makefile fix comments --- Makefile | 5 +++++ test/sanity/README.md | 8 +++++++ test/sanity/run-test.sh | 47 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 test/sanity/README.md create mode 100755 test/sanity/run-test.sh diff --git a/Makefile b/Makefile index 765f97e8c..96499d771 100644 --- a/Makefile +++ b/Makefile @@ -16,3 +16,8 @@ CMDS=nfsplugin all: build include release-tools/build.make + +.PHONY: sanity-test +sanity-test: build + ./test/sanity/run-test.sh + diff --git a/test/sanity/README.md b/test/sanity/README.md new file mode 100644 index 000000000..27a1f7b16 --- /dev/null +++ b/test/sanity/README.md @@ -0,0 +1,8 @@ +## Sanity Tests +Testing the NFS CSI driver using the [`sanity`](https://github.com/kubernetes-csi/csi-test/tree/master/pkg/sanity) package test suite. + +### Run sanity tests +``` +make sanity-test +``` + diff --git a/test/sanity/run-test.sh b/test/sanity/run-test.sh new file mode 100755 index 000000000..66d717117 --- /dev/null +++ b/test/sanity/run-test.sh @@ -0,0 +1,47 @@ +#!/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 -eo pipefail + +function cleanup { + echo 'pkill -f nfsplugin' + pkill -f nfsplugin + echo 'Deleting CSI sanity test binary' + rm -rf csi-test +} +trap cleanup EXIT + +function install_csi_sanity_bin { + echo 'Installing CSI sanity test binary...' + git clone https://github.com/kubernetes-csi/csi-test.git -b v2.2.0 + pushd csi-test/cmd/csi-sanity + make + popd +} + +install_csi_sanity_bin + +readonly endpoint='unix:///tmp/csi.sock' +nodeid='CSINode' +if [[ "$#" -gt 0 ]] && [[ -n "$1" ]]; then + nodeid="$1" +fi + +bin/nfsplugin --endpoint "$endpoint" --nodeid "$nodeid" -v=5 & + +echo 'Begin to run sanity test...' +readonly CSI_SANITY_BIN='csi-test/cmd/csi-sanity/csi-sanity' +"$CSI_SANITY_BIN" --ginkgo.v --ginkgo.noColor --csi.endpoint="$endpoint"