Skip to content

Commit 16ed495

Browse files
authored
Merge pull request #43 from andyzhangx/sanity-test
test: add sanity test
2 parents 76c0893 + 3ae2be5 commit 16ed495

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ CMDS=nfsplugin
1616
all: build
1717

1818
include release-tools/build.make
19+
20+
.PHONY: sanity-test
21+
sanity-test: build
22+
./test/sanity/run-test.sh
23+

test/sanity/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Sanity Tests
2+
Testing the NFS CSI driver using the [`sanity`](https://github.com/kubernetes-csi/csi-test/tree/master/pkg/sanity) package test suite.
3+
4+
### Run sanity tests
5+
```
6+
make sanity-test
7+
```
8+

test/sanity/run-test.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Copyright 2020 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -eo pipefail
18+
19+
function cleanup {
20+
echo 'pkill -f nfsplugin'
21+
pkill -f nfsplugin
22+
echo 'Deleting CSI sanity test binary'
23+
rm -rf csi-test
24+
}
25+
trap cleanup EXIT
26+
27+
function install_csi_sanity_bin {
28+
echo 'Installing CSI sanity test binary...'
29+
git clone https://github.com/kubernetes-csi/csi-test.git -b v2.2.0
30+
pushd csi-test/cmd/csi-sanity
31+
make
32+
popd
33+
}
34+
35+
install_csi_sanity_bin
36+
37+
readonly endpoint='unix:///tmp/csi.sock'
38+
nodeid='CSINode'
39+
if [[ "$#" -gt 0 ]] && [[ -n "$1" ]]; then
40+
nodeid="$1"
41+
fi
42+
43+
bin/nfsplugin --endpoint "$endpoint" --nodeid "$nodeid" -v=5 &
44+
45+
echo 'Begin to run sanity test...'
46+
readonly CSI_SANITY_BIN='csi-test/cmd/csi-sanity/csi-sanity'
47+
"$CSI_SANITY_BIN" --ginkgo.v --ginkgo.noColor --csi.endpoint="$endpoint"

0 commit comments

Comments
 (0)