add csi-test to vendor

This commit is contained in:
wackxu
2018-08-21 23:03:36 +08:00
parent 62551068b1
commit a2987675cf
110 changed files with 11973 additions and 24 deletions

View File

@@ -0,0 +1,61 @@
APP_NAME := csi-sanity
VER :=$(shell git describe)
RELEASEVER := $(shell git describe --abbrev=0)
BRANCH := $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
SHA := $(shell git rev-parse --short HEAD)
ARCH := $(shell go env GOARCH)
GOOS := $(shell go env GOOS)
DIR=.
ifdef APP_SUFFIX
VERSION = $(VER)-$(subst /,-,$(APP_SUFFIX))
else
ifeq (master,$(BRANCH))
VERSION = $(VER)
else
VERSION = $(VER)-$(BRANCH)
endif
endif
LDFLAGS :=-ldflags "-w -X github.com/kubernetes-csi/csi-test/cmd/csi-sanity.VERSION=$(VERSION) -extldflags '-z relro -z now'"
PACKAGE :=$(DIR)/dist/$(APP_NAME)-$(RELEASEVER).$(GOOS).$(ARCH).tar.gz
all: $(APP_NAME)
$(APP_NAME): Makefile sanity_test.go
go test $(LDFLAGS) -c -o $(APP_NAME)
install: $(APP_NAME)
cp $(APP_NAME) $(GOPATH)/bin
clean:
rm -f csi-sanity
dist-clean:
rm -rf $(DIR)/dist
dist: clean $(PACKAGE)
$(PACKAGE): $(APP_NAME)
@echo Packaging Binaries...
@mkdir -p tmp/$(APP_NAME)
@cp $(APP_NAME) tmp/$(APP_NAME)/
@mkdir -p $(DIR)/dist/
tar -czf $@ -C tmp $(APP_NAME);
@rm -rf tmp
@echo
@echo Package $@ saved in dist directory
linux_amd64_dist:
GOOS=linux GOARCH=amd64 $(MAKE) dist
linux_arm64_dist:
GOOS=linux GOARCH=arm64 $(MAKE) dist
darwin_amd64_dist:
GOOS=darwin GOARCH=amd64 $(MAKE) dist
release: dist-clean darwin_amd64_dist linux_amd64_dist linux_arm64_dist
.PHONY: release darwin_amd64_dist linux_arm64_dist linux_amd64_dist \
linux_arm_dist linux_amd64_dist clean dist-clean

View File

@@ -0,0 +1,58 @@
# Sanity Test Command Line Program
This is the command line program that tests a CSI driver using the [`sanity`](https://github.com/kubernetes-csi/csi-test/tree/master/pkg/sanity) package test suite.
Example:
```
$ csi-sanity --csi.endpoint=<your csi driver endpoint>
```
If you want to specify a mount point:
```
$ csi-sanity --csi.endpoint=<your csi driver endpoint> --csi.mountpoint=/mnt
```
For verbose type:
```
$ csi-sanity --ginkgo.v --csi.endpoint=<your csi driver endpoint>
```
For csi-credentials, create a secrets file with all the secrets in it:
```yaml
CreateVolumeSecret:
secretKey: secretval1
DeleteVolumeSecret:
secretKey: secretval2
ControllerPublishVolumeSecret:
secretKey: secretval3
ControllerUnpublishVolumeSecret:
secretKey: secretval4
NodeStageVolumeSecret:
secretKey: secretval5
NodePublishVolumeSecret:
secretKey: secretval6
```
Pass the file path to csi-sanity as:
```
$ csi-sanity --csi.endpoint=<your csi driver endpoint> --csi.secrets=<path to secrets file>
```
Replace the keys and values of the credentials appropriately. Since the whole
secret is passed in the request, multiple key-val pairs can be used.
### Help
The full Ginkgo and golang unit test parameters are available. Type
```
$ csi-sanity -h
```
to get more information
### Download
Please see the [Releases](https://github.com/kubernetes-csi/csi-test/releases) page
to download the latest version of `csi-sanity`

View File

@@ -0,0 +1,56 @@
/*
Copyright 2017 Luis Pabón luis@portworx.com
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.
*/
package sanity
import (
"flag"
"fmt"
"os"
"testing"
"github.com/kubernetes-csi/csi-test/pkg/sanity"
)
const (
prefix string = "csi."
)
var (
VERSION = "(dev)"
version bool
config sanity.Config
)
func init() {
flag.StringVar(&config.Address, prefix+"endpoint", "", "CSI endpoint")
flag.BoolVar(&version, prefix+"version", false, "Version of this program")
flag.StringVar(&config.TargetPath, prefix+"mountdir", os.TempDir()+"/csi", "Mount point for NodePublish")
flag.StringVar(&config.StagingPath, prefix+"stagingdir", os.TempDir()+"/csi", "Mount point for NodeStage if staging is supported")
flag.StringVar(&config.SecretsFile, prefix+"secrets", "", "CSI secrets file")
flag.Int64Var(&config.TestVolumeSize, prefix+"testvolumesize", sanity.DefTestVolumeSize, "Base volume size used for provisioned volumes")
flag.Parse()
}
func TestSanity(t *testing.T) {
if version {
fmt.Printf("Version = %s\n", VERSION)
return
}
if len(config.Address) == 0 {
t.Fatalf("--%sendpoint must be provided with an CSI endpoint", prefix)
}
sanity.Test(t, &config)
}