Skip to content

Commit

Permalink
mock: Support for quay.io/k8scsi/mock-driver
Browse files Browse the repository at this point in the history
  • Loading branch information
lpabon committed May 3, 2018
1 parent 57aeb5f commit a96cd62
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
bin/mock
cmd/csi-sanity/csi-sanity
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ script:
- go vet $(go list ./... | grep -v vendor)
- go test $(go list ./... | grep -v vendor | grep -v "cmd/csi-sanity")
- ./hack/e2e.sh
after_success:
- if [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" quay.io;
make push;
fi
6 changes: 6 additions & 0 deletions Dockerfile.mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine
LABEL maintainers="Kubernetes Authors"
LABEL description="CSI Mock Driver"

COPY ./bin/mock mock
ENTRYPOINT ["/mock"]
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2016 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.

IMAGE_NAME = quay.io/k8scsi/mock-driver
IMAGE_VERSION = canary

ifdef V
TESTARGS = -v -args -alsologtostderr -v 5
else
TESTARGS =
endif

all: mock

mock:
mkdir -p bin
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./bin/mock ./mock/main.go

clean:
rm -rf bin

container: mock
docker build -f Dockerfile.mock -t $(IMAGE_NAME):$(IMAGE_VERSION) .

push: container
docker push $(IMAGE_NAME):$(IMAGE_VERSION)
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[![Build Status](https://travis-ci.org/kubernetes-csi/csi-test.svg?branch=master)](https://travis-ci.org/kubernetes-csi/csi-test)
[![Docker Repository on Quay](https://quay.io/repository/k8scsi/mock-driver/status "Docker Repository on
Quay")](https://quay.io/repository/k8scsi/mock-driver)

# csi-test
csi-test houses packages and libraries to help test CSI client and plugins.

Expand All @@ -7,6 +10,13 @@ CO developers can use this framework to create drivers based on the
[Golang mock](https://github.com/golang/mock) framework. Please see
[co_test.go](test/co_test.go) for an example.

### Mock driver for testing
We also provide a container called `quay.io/k8scsi/mock-driver:canary` which can be used as an in-memory mock driver.
It follows the same release cycle as other containers, so the latest release is `quay.io/k8scsi/mock-driver:v0.2.0`.

You will need to setup the environment variable `CSI_ENDPOINT` for the mock driver to know where to create the unix
domain socket.

## For CSI Driver Tests
To test drivers please take a look at [pkg/sanity](https://github.com/kubernetes-csi/csi-test/tree/master/pkg/sanity).
This package and [csi-sanity](https://github.com/kubernetes-csi/csi-test/tree/master/cmd/csi-sanity) are meant to test
Expand Down

0 comments on commit a96cd62

Please sign in to comment.