Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Sanity Testing #21

Merged
merged 8 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
106 changes: 106 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
name = "k8s.io/kubernetes"
version = "v1.13.0"

[[override]]
name = "gopkg.in/fsnotify.v1"
source = "https://github.com/fsnotify/fsnotify.git"

[[override]]
version = "kubernetes-1.13.0"
name = "k8s.io/api"
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ test:
go vet github.com/csi-driver/azuredisk-csi-driver/pkg/...
integration-test:
test/integration/run-tests-all-clouds.sh
test-sanity:
go test -v ./test/sanity/...
azuredisk:
if [ ! -d ./vendor ]; then dep ensure -vendor-only; fi
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X github.com/csi-driver/azuredisk-csi-driver/pkg/azuredisk.vendorVersion=$(IMAGE_VERSION) -extldflags "-static"' -o _output/azurediskplugin ./pkg/azurediskplugin
Expand Down
13 changes: 11 additions & 2 deletions pkg/azuredisk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,17 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
return nil, status.Error(codes.InvalidArgument, "Volume capabilities not supported")
}

volSizeBytes := int64(req.GetCapacityRange().GetRequiredBytes())
requestGiB := int(util.RoundUpSize(volSizeBytes, 1024*1024*1024))
volSizeBytes := int64(util.GIB)
if req.GetCapacityRange() != nil {
volSizeBytes = req.GetCapacityRange().GetRequiredBytes()
}

requestGiB := int(util.RoundUpSize(volSizeBytes, util.GIB))

maxVolSize := int(req.GetCapacityRange().GetLimitBytes())
if (maxVolSize > 0) && (maxVolSize < requestGiB) {
return nil, status.Error(codes.InvalidArgument, "After round-up, volume size exceeds the limit specified")
}

var (
location, account string
Expand Down
18 changes: 18 additions & 0 deletions test/sanity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Sanity Tests
Testing the Azure Disk CSI driver using the [`sanity`](https://github.com/kubernetes-csi/csi-test/tree/master/pkg/sanity) package test suite.

## Run Integration Tests Locally
### Prerequisite
- make sure `GOPATH` is set

- set the environment variable AZURE_CREDENTIAL_FILE with the path to cloud provider config file only if you have the file at a different location than `/etc/kubernetes/azure.json`
> By default Cloud provider config file is present at `/etc/kubernetes/azure.json` on a kubernetes cluster node
```
export set AZURE_CREDENTIAL_FILE=
```

### Run integration tests
```
make test-sanity
```

48 changes: 48 additions & 0 deletions test/sanity/sanity_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Copyright 2019 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.
*/

package sanity

import (
"testing"

sanity "github.com/kubernetes-csi/csi-test/pkg/sanity"

azuredisk "github.com/csi-driver/azuredisk-csi-driver/pkg/azuredisk"
)

const (
mountPath = "/tmp/csi/mount"
stagePath = "/tmp/csi/stage"
socket = "/tmp/csi.sock"
endpoint = "unix://" + socket
)

func TestSanity(t *testing.T) {
ddriver := azuredisk.NewDriver("someNodeID")

go func() {
ddriver.Run(endpoint)
}()

// Run test
config := &sanity.Config{
TargetPath: mountPath,
StagingPath: stagePath,
Address: endpoint,
}
sanity.Test(t, config)
}
3 changes: 3 additions & 0 deletions vendor/github.com/hpcloud/tail/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions vendor/github.com/hpcloud/tail/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions vendor/github.com/hpcloud/tail/CHANGES.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/hpcloud/tail/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/hpcloud/tail/Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading