Skip to content

Commit 4dfe6a8

Browse files
fix: test failures
- fix issues with fake mounter in nodeserver tests - fix errors in sanity script Signed-off-by: Mayank Shah <[email protected]>
1 parent c2d9810 commit 4dfe6a8

File tree

9 files changed

+314
-23
lines changed

9 files changed

+314
-23
lines changed

.github/workflows/ubuntu.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ jobs:
3636
make container
3737
3838
- name: Get code coverage
39+
env:
40+
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3941
run: |
4042
GO111MODULE=off go get github.com/mattn/goveralls
41-
sudo -E env "PATH=$PATH" go test -covermode=count -coverprofile=profile.cov ./pkg/...
42-
$GOPATH/bin/goveralls -coverprofile=profile.cov -service=travis-ci
43+
$(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ before_install:
99
- GO111MODULE=off go get github.com/mattn/goveralls
1010

1111
script:
12-
- sudo -E env "PATH=$PATH" go test -covermode=count -coverprofile=profile.cov ./pkg/...
12+
- go test -covermode=count -coverprofile=profile.cov ./pkg/...
1313
- $GOPATH/bin/goveralls -coverprofile=profile.cov -service=travis-ci
1414
- make container

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
3030
LDFLAGS ?= "-X ${PKG}/pkg/blob.driverVersion=${IMAGE_VERSION} -X ${PKG}/pkg/blob.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/blob.buildDate=${BUILD_DATE} -s -w -extldflags '-static'"
3131
E2E_HELM_OPTIONS ?= --set image.blob.pullPolicy=IfNotPresent --set image.blob.repository=$(REGISTRY)/$(IMAGE_NAME) --set image.blob.tag=$(IMAGE_VERSION)
3232
GINKGO_FLAGS = -ginkgo.noColor -ginkgo.v
33-
GO111MODULE = off
33+
GO111MODULE = on
3434
GOPATH ?= $(shell go env GOPATH)
3535
GOBIN ?= $(GOPATH)/bin
3636
DOCKER_CLI_EXPERIMENTAL = enabled
@@ -132,4 +132,4 @@ clean:
132132

133133
.PHONY: create-metrics-svc
134134
create-metrics-svc:
135-
kubectl create -f deploy/example/metrics/csi-blob-controller-svc.yaml
135+
kubectl create -f deploy/example/metrics/csi-blob-controller-svc.yaml

pkg/blob/fake_mount.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ type fakeMounter struct {
2727
mount.FakeMounter
2828
}
2929

30+
// Mount overrides mount.FakeMounter.Mount.
31+
func (f *fakeMounter) Mount(source string, target string, fstype string, options []string) error {
32+
if strings.Contains(source, "error_mount") {
33+
return fmt.Errorf("fake Mount: source error")
34+
} else if strings.Contains(target, "error_mount") {
35+
return fmt.Errorf("fake Mount: target error")
36+
}
37+
38+
return nil
39+
}
40+
3041
// MountSensitive overrides mount.FakeMounter.MountSensitive.
3142
func (f *fakeMounter) MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
3243
if strings.Contains(source, "ut-container") {

pkg/blob/nodeserver_test.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/container-storage-interface/spec/lib/go/csi"
3232
"github.com/stretchr/testify/assert"
3333

34+
testingexec "k8s.io/utils/exec/testing"
3435
"k8s.io/utils/mount"
3536
)
3637

@@ -186,7 +187,12 @@ func TestNodePublishVolume(t *testing.T) {
186187
_ = makeDir(sourceTest)
187188
_ = makeDir(targetTest)
188189
d := NewFakeDriver()
189-
d.mounter, _ = NewSafeMounter()
190+
fakeMounter := &fakeMounter{}
191+
fakeExec := &testingexec.FakeExec{ExactOrder: true}
192+
d.mounter = &mount.SafeFormatAndMount{
193+
Interface: fakeMounter,
194+
Exec: fakeExec,
195+
}
190196

191197
for _, test := range tests {
192198
_, err := d.NodePublishVolume(context.Background(), &test.req)
@@ -233,9 +239,13 @@ func TestNodeUnpublishVolume(t *testing.T) {
233239
_ = makeDir(sourceTest)
234240
_ = makeDir(targetTest)
235241
d := NewFakeDriver()
236-
d.mounter, _ = NewSafeMounter()
237-
mountOptions := []string{"bind"}
238-
_ = d.mounter.Mount(sourceTest, targetTest, "", mountOptions)
242+
243+
fakeMounter := &fakeMounter{}
244+
fakeExec := &testingexec.FakeExec{ExactOrder: true}
245+
d.mounter = &mount.SafeFormatAndMount{
246+
Interface: fakeMounter,
247+
Exec: fakeExec,
248+
}
239249

240250
for _, test := range tests {
241251
_, err := d.NodeUnpublishVolume(context.Background(), &test.req)

test/sanity/run-test.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616

1717
set -eo pipefail
1818

19+
function cleanup {
20+
echo 'pkill -f blobplugin'
21+
pkill -f blobplugin
22+
echo 'Deleting CSI sanity test binary'
23+
rm -rf csi-test
24+
}
25+
26+
trap cleanup EXIT
27+
1928
readonly endpoint="unix:///tmp/csi.sock"
2029
nodeid="CSINode"
2130
if [[ "$#" -gt 0 ]] && [[ -n "$1" ]]; then
@@ -25,4 +34,6 @@ fi
2534
_output/blobplugin --endpoint "$endpoint" --nodeid "$nodeid" -v=5 &
2635

2736
echo "Begin to run sanity test..."
28-
csi-sanity --ginkgo.v --csi.endpoint=$endpoint -ginkgo.skip="should fail when requesting to create a volume with already existing name and different capacity"
37+
readonly CSI_SANITY_BIN='csi-test/cmd/csi-sanity/csi-sanity'
38+
"$CSI_SANITY_BIN" --ginkgo.v --csi.endpoint=$endpoint -ginkgo.skip="should fail when requesting to create a volume with already existing name and different capacity"
39+

test/sanity/run-tests-all-clouds.sh

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,13 @@
1717
set -eo pipefail
1818

1919
function install_csi_sanity_bin {
20-
mkdir -p $GOPATH/src/github.com/kubernetes-csi/csi-test
21-
git clone https://github.com/kubernetes-csi/csi-test.git -b v2.2.0 $GOPATH/src/github.com/kubernetes-csi/csi-test
22-
pushd $GOPATH/src/github.com/kubernetes-csi/csi-test/cmd/csi-sanity
23-
make && make install
20+
echo 'Installing CSI sanity test binary...'
21+
git clone https://github.com/kubernetes-csi/csi-test.git -b v2.2.0
22+
pushd csi-test/cmd/csi-sanity
23+
make
2424
popd
2525
}
2626

27-
function cleanup {
28-
echo 'pkill -f blobplugin'
29-
pkill -f blobplugin
30-
echo 'Deleting CSI sanity test binary'
31-
rm -rf $GOPATH/src/github.com/kubernetes-csi
32-
}
33-
34-
trap cleanup EXIT
35-
3627
# copy blobfuse binary
3728
mkdir -p /usr/blob
3829
cp test/artifacts/blobfuse /usr/bin/blobfuse

0 commit comments

Comments
 (0)