From cc7ba6fc23d405bd6384f0dd66a2e61fe1805347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Pab=C3=B3n?= Date: Thu, 3 May 2018 08:39:41 -0400 Subject: [PATCH] mock: Support for quay.io/k8scsi/mock-driver --- .gitignore | 1 + .travis.yml | 5 +++++ Dockerfile.mock | 6 ++++++ Makefile | 37 +++++++++++++++++++++++++++++++++++++ README.md | 10 ++++++++++ 5 files changed, 59 insertions(+) create mode 100644 Dockerfile.mock create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 5e8f082f..984ec0fb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +bin/mock cmd/csi-sanity/csi-sanity diff --git a/.travis.yml b/.travis.yml index 414fa97b..9d636c7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Dockerfile.mock b/Dockerfile.mock new file mode 100644 index 00000000..72697712 --- /dev/null +++ b/Dockerfile.mock @@ -0,0 +1,6 @@ +FROM alpine +LABEL maintainers="Kubernetes Authors" +LABEL description="CSI Mock Driver" + +COPY ./bin/mock mock +ENTRYPOINT ["/mock"] diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..99d8481c --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +# Copyright 2018 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) diff --git a/README.md b/README.md index 932dba72..f6891ae7 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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