Skip to content

Commit

Permalink
Merge pull request #55 from phillc/lka16-4
Browse files Browse the repository at this point in the history
Volume expansion
  • Loading branch information
phillc authored Sep 2, 2020
2 parents e3eaa07 + 13b22e1 commit 88073c3
Show file tree
Hide file tree
Showing 26 changed files with 425 additions and 236 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
- GO111MODULE=on

go:
- 1.11.5
- 1.13.x
- tip

cache:
Expand All @@ -31,7 +31,5 @@ install:

script:
- make test
- make linode-container
- make docker-build
- golangci-lint run
- travis_wait 20 roveralls -ignore e2e
- goveralls -coverprofile=roveralls.coverprofile -service=travis-ci -ignore=csi_driver_test.go,e2e_suite_test.go
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ vet: fmt
test: vet
go test -v ./... -cover

.PHONY: linode
linode: test
.PHONY: build-linux
build-linux: test
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.vendorVersion=$(REV) -extldflags "-static"' -o _output/linode ./app/linode

.PHONY: linode-container
linode-container: linode
.PHONY: docker-build
docker-build: build-linux
docker build -t $(IMAGE_TAG) -f ./app/linode/Dockerfile .

.PHONY: push
push: linode-container
.PHONY: docker-push
docker-push:
echo "[reminder] Did you run `make docker-build`?"
docker push $(IMAGE_TAG)

.PHONY: verify
Expand Down
16 changes: 10 additions & 6 deletions e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
export GO111MODULE=on
IMG ?= linode/linode-blockstorage-csi-driver:latest

imports: $(GOPATH)/bin/goimports
goimports -w test
REGISTRY_NAME=index.docker.io/linode
IMAGE_NAME=linode-blockstorage-csi-driver
IMAGE_VERSION=canary
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(IMAGE_VERSION)

.PHONY: test reuse-and-test clean
.PHONY: test reuse-and-test clean check-token install-terraform test-manifest

test-manifest:
../hack/generate-yaml.sh $(IMAGE_VERSION) > test/manifest/linode-blockstorage-csi-driver.yaml

reuse-and-test: SUITE_ARGS='--reuse'

test reuse-and-test: $(GOPATH)/bin/ginkgo check-token
test reuse-and-test: $(GOPATH)/bin/ginkgo check-token test-manifest
go list -m; \
ginkgo -r --v --progress --trace --cover $(TEST_ARGS) -- --v=3 --image=${IMG} $(SUITE_ARGS); \
ginkgo -r --v --progress --trace --cover $(TEST_ARGS) -- --v=3 --image=${IMAGE_TAG} $(SUITE_ARGS)

clean: check-token
cd test; \
Expand Down
8 changes: 6 additions & 2 deletions e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ go 1.12

require (
github.com/appscode/go v0.0.0-20190112082056-52eaa8008e2e
github.com/codeskyblue/go-sh v0.0.0-20171228145154-cf804ac79dff
github.com/davecgh/go-spew v1.1.1
github.com/dnaeon/go-vcr v1.0.1 // indirect
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
github.com/elazarl/goproxy v0.0.0-20190410145444-c548f45dcf1d // indirect
github.com/elazarl/goproxy/ext v0.0.0-20190410145444-c548f45dcf1d // indirect
Expand All @@ -15,14 +18,15 @@ require (
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/linode/linodego v0.7.1
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.0
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.8.0
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e // indirect
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/resty.v1 v1.12.0 // indirect
k8s.io/api v0.0.0-20180904230853-4e7be11eab3f
k8s.io/apimachinery v0.0.0-20180621070125-103fd098999d
k8s.io/client-go v8.0.0+incompatible
Expand Down
15 changes: 15 additions & 0 deletions e2e/go.sum
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/appscode/go v0.0.0-20190112082056-52eaa8008e2e h1:QwszriolcyRBOTovn+OLx/f1yclQtatwoVqvAvPGQlI=
github.com/appscode/go v0.0.0-20190112082056-52eaa8008e2e/go.mod h1:a9V9cFfL4x+IolJkNLeM4ZaNPTY8GXCyQB6Ool2I4AI=
github.com/appscode/go-notify v0.0.0-20180516083708-17078f08a5ba/go.mod h1:ta+dFCq77Bh3GwYmYtKuzO0HhDxsalgPelI4nDOk5lA=
github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg=
github.com/cenkalti/backoff v2.0.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 h1:sDMmm+q/3+BukdIpxwO365v/Rbspp2Nt5XntgQRXq8Q=
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
github.com/codeskyblue/go-sh v0.0.0-20171228145154-cf804ac79dff h1:6dIlQE/9GSZhFYpqKUKnx9IJKQ7ANrzvwR7xdJhOsnk=
github.com/codeskyblue/go-sh v0.0.0-20171228145154-cf804ac79dff/go.mod h1:2hUMLQDY+46DXIf/i7n2rUCHUwF3gZrb4slZV8C4RYI=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dnaeon/go-vcr v1.0.1 h1:r8L/HqC0Hje5AXMu1ooW8oyQyOFv4GxqpL0nRP7SLLY=
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKGUhzj7BQlPSU4OvT6tfOKe3DVHzOA7s=
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/elazarl/goproxy v0.0.0-20190410145444-c548f45dcf1d h1:FEw1BeUVT/wxetVmacXPqQgRyYCG+0aCfQel+53Pa/E=
Expand Down Expand Up @@ -50,6 +55,8 @@ github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVE
github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/linode/linodego v0.7.1 h1:4WZmMpSA2NRwlPZcc0+4Gyn7rr99Evk9bnr0B3gXRKE=
github.com/linode/linodego v0.7.1/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
Expand Down Expand Up @@ -78,10 +85,14 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/crypto v0.0.0-20180830192347-182538f80094 h1:rVTAlhYa4+lCfNxmAIEOGQRoD23UqP72M3+rSWVGDTg=
golang.org/x/crypto v0.0.0-20180830192347-182538f80094/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA=
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
Expand All @@ -94,13 +105,17 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/resty.v1 v1.12.0 h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
Expand Down
2 changes: 2 additions & 0 deletions e2e/test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ cluster.tf
terraform*
.terraform

manifest/linode-blockstorage-csi-driver.yaml

120 changes: 41 additions & 79 deletions e2e/test/csi_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ package test

import (
"e2e_test/test/framework"
"strconv"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)

var _ = Describe("CSIDriver", func() {
var (
err error
pod *core.Pod
podName1 = "test-pod-1"
podName2 = "test-pod-2"
pvc *core.PersistentVolumeClaim
f *framework.Invocation
size string
file = "/data/heredoc"
waitTime = 1 * time.Minute
err error
pod *core.Pod
pvc *core.PersistentVolumeClaim
f *framework.Invocation
size string
file = "/data/heredoc"
)
BeforeEach(func() {
f = root.Invoke()
Expand All @@ -37,53 +36,53 @@ var _ = Describe("CSIDriver", func() {
Expect(err).NotTo(HaveOccurred())
}

var waitForOperation = func() {
time.Sleep(waitTime)
}

var deleteAndCreatePod = func(name string) {
By("Deleting the First pod")
err = f.DeletePod(pod.Name)
var expandVolume = func(size string) {
By("Expanding Size of the Persistent Volume")
currentPVC, err := f.GetPersistentVolumeClaim(pvc.ObjectMeta)
Expect(err).NotTo(HaveOccurred())

By("Waiting for the Volume to be Detached")
waitForOperation()

By("Creating Second Pod with the Same PVC")
pod = f.GetPodObject(name, pvc.Name)
err = f.CreatePod(pod)
currentPVC.Spec.Resources.Requests = core.ResourceList{
core.ResourceName(core.ResourceStorage): resource.MustParse(size),
}
err = f.UpdatePersistentVolumeClaim(currentPVC)
Expect(err).NotTo(HaveOccurred())

By("Checking if Volume Expansion Occurred")
Eventually(func() string {
s, _ := f.GetVolumeSize(currentPVC)
return strconv.Itoa(s) + "Gi"
}).Should(Equal(size))
}

Describe("Test", func() {
Context("Simple", func() {
Context("Block Storage", func() {
JustBeforeEach(func() {
By("Creating Persistent Volume Claim")
pvc = f.GetPersistentVolumeClaim(size)
pvc = f.GetPersistentVolumeClaimObject(size, f.StorageClass)
err = f.CreatePersistentVolumeClaim(pvc)
Expect(err).NotTo(HaveOccurred())

By("Creating Pod with PVC")
pod = f.GetPodObject(podName1, pvc.Name)
pod = f.GetPodObject(pvc.Name)
err = f.CreatePod(pod)
Expect(err).NotTo(HaveOccurred())
})

AfterEach(func() {
By("Deleting the Pod with PVC")
err = f.DeletePod(pod.Name)
err = f.DeletePod(pod.ObjectMeta)
Expect(err).NotTo(HaveOccurred())

By("Waiting for the Volume to be Detached")
waitForOperation()
time.Sleep(2 * time.Minute)

By("Deleting the PVC")
err = f.DeletePersistentVolumeClaim(pvc.ObjectMeta)
Expect(err).NotTo(HaveOccurred())

By("Waiting for the Volume to be Deleted")
waitForOperation()
time.Sleep(1 * time.Minute)
})

Context("1Gi Storage", func() {
Expand All @@ -95,93 +94,56 @@ var _ = Describe("CSIDriver", func() {
readFile(file)
})
})

Context("10Gi Storage", func() {
BeforeEach(func() {
size = "10Gi"
})
It("should write and read", func() {
writeFile(file)
readFile(file)
})
})

Context("20Gi Storage", func() {
BeforeEach(func() {
size = "20Gi"
})
It("should write and read", func() {
writeFile(file)
readFile(file)
})
})
})
})
})

Context("Pre-Provisioned", func() {
Context("Linode Block Storage", func() {
Describe("Test", func() {
Context("Block Storage", func() {
Context("Volume Expansion", func() {
JustBeforeEach(func() {
By("Applying Manifest")
err = framework.ApplyManifest("apply", "manifest/linode-blockstorage-csi-driver.yaml")
Expect(err).NotTo(HaveOccurred())

By("Creating Persistent Volume Claim")
pvc = f.GetPersistentVolumeClaim(size)
pvc = f.GetPersistentVolumeClaimObject(size, "linode-block-storage")
err = f.CreatePersistentVolumeClaim(pvc)
Expect(err).NotTo(HaveOccurred())

By("Creating Pod with PVC")
pod = f.GetPodObject(podName1, pvc.Name)
pod = f.GetPodObject(pvc.Name)
err = f.CreatePod(pod)
Expect(err).NotTo(HaveOccurred())
})

AfterEach(func() {
By("Deleting the Pod with PVC")
err = f.DeletePod(pod.Name)
err = f.DeletePod(pod.ObjectMeta)
Expect(err).NotTo(HaveOccurred())

By("Waiting for the Volume to be Detached")
waitForOperation()
time.Sleep(2 * time.Minute)

By("Deleting the PVC")
err = f.DeletePersistentVolumeClaim(pvc.ObjectMeta)
Expect(err).NotTo(HaveOccurred())

By("Waiting for the Volume to be Deleted")
waitForOperation()
time.Sleep(1 * time.Minute)
})

Context("10Gi Storage", func() {
Context("Expanding Storage from 10Gi to 15Gi", func() {
BeforeEach(func() {
size = "10Gi"
})
It("should write and read", func() {
writeFile(file)
deleteAndCreatePod(podName2)
readFile(file)
})
})

Context("15Gi Storage", func() {
BeforeEach(func() {
size = "15Gi"
})
It("should write and read", func() {
writeFile(file)
deleteAndCreatePod(podName2)
readFile(file)
})
})

Context("20Gi Storage", func() {
BeforeEach(func() {
size = "20Gi"
})
It("should write and read", func() {
writeFile(file)
deleteAndCreatePod(podName2)
expandVolume("15Gi")
readFile(file)
})
})
})
})
})

})
Loading

0 comments on commit 88073c3

Please sign in to comment.