Skip to content

Commit 535a198

Browse files
committed
test: add sanity test
test: add sanity test revert go mod change run all sanity tests
1 parent d94b64b commit 535a198

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

release-tools/build.make

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,7 @@ test-shellcheck:
270270
.PHONY: check-go-version-%
271271
check-go-version-%:
272272
./release-tools/verify-go-version.sh "$*"
273+
274+
.PHONY: sanity-test
275+
sanity-test: build
276+
test/sanity/run-test.sh

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 2019 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)