From 50cf8f002f022f2393947b204cc9c60d201256fd Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Mon, 22 Apr 2019 15:53:35 -0400 Subject: [PATCH 1/2] Fix races in snapshot integration test (#146) This test failed more often than not in my local testing. Previously we only waited for the pod to be running which didn't guarantee the file had been created, nor that it had been sync'ed to the block device. --- CHANGELOG.md | 2 ++ test/kubernetes/integration_test.go | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 021530c65..336f3766d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ [[GH-142]](https://github.com/digitalocean/csi-digitalocean/pull/142) * Update `godo` (DigitalOcean API package) version to v1.13.0 [[GH-143]](https://github.com/digitalocean/csi-digitalocean/pull/143) +* Fix race in snapshot integration test. + [[GH-146]](https://github.com/digitalocean/csi-digitalocean/pull/146) ## v1.0.0 - 2018.12.19 diff --git a/test/kubernetes/integration_test.go b/test/kubernetes/integration_test.go index 941814b17..d0d645356 100644 --- a/test/kubernetes/integration_test.go +++ b/test/kubernetes/integration_test.go @@ -358,6 +358,24 @@ func TestSnapshot_Create(t *testing.T) { Name: "my-csi-app-2", }, Spec: v1.PodSpec{ + // Write the data in an InitContainer so that we can guarantee + // it's been written before we reach running in the main container. + InitContainers: []v1.Container{ + { + Name: "my-csi", + Image: "busybox", + VolumeMounts: []v1.VolumeMount{ + { + MountPath: "/data", + Name: volumeName, + }, + }, + Command: []string{ + "sh", "-c", + "echo testcanary > /data/canary && sync", + }, + }, + }, Containers: []v1.Container{ { Name: "my-csi-app", @@ -370,7 +388,7 @@ func TestSnapshot_Create(t *testing.T) { }, Command: []string{ "sh", "-c", - "echo testcanary > /data/canary && sleep 1000000", + "sleep 1000000", }, }, }, From fb1c08db7fb541b3807479f456306ecc811dd7e7 Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Mon, 22 Apr 2019 17:42:24 -0400 Subject: [PATCH 2/2] bump-version: remove sembump - sembump (github.com/jessfraz/junk/sembump) is unsupported by the author and won't build on mac/windows. Make NEW_VERSION explicit. - make ... bump-version manged the low-version on the compatibility table. --- Makefile | 6 ++---- README.md | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 5ea8ae376..2fbcee2ad 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,6 @@ BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) LDFLAGS ?= -X github.com/digitalocean/csi-digitalocean/driver.version=${VERSION} -X github.com/digitalocean/csi-digitalocean/driver.commit=${COMMIT} -X github.com/digitalocean/csi-digitalocean/driver.gitTreeState=${GIT_TREE_STATE} PKG ?= github.com/digitalocean/csi-digitalocean/cmd/do-csi-plugin -## Bump the version in the version file. Set BUMP to [ major | minor | patch ] -BUMP := patch VERSION ?= $(shell cat VERSION) all: test @@ -20,8 +18,8 @@ publish: compile build push clean .PHONY: bump-version bump-version: - @go get -u github.com/jessfraz/junk/sembump # update sembump tool - $(eval NEW_VERSION = $(shell sembump --kind $(BUMP) $(VERSION))) + @[ "${NEW_VERSION}" ] || ( echo "NEW_VERSION must be set (ex. make NEW_VERSION=v1.x.x bump-version)"; exit 1 ) + @(echo ${NEW_VERSION} | grep -E "^v") || ( echo "NEW_VERSION must be a semver ('v' prefix is required)"; exit 1 ) @echo "Bumping VERSION from $(VERSION) to $(NEW_VERSION)" @echo $(NEW_VERSION) > VERSION @cp deploy/kubernetes/releases/csi-digitalocean-${VERSION}.yaml deploy/kubernetes/releases/csi-digitalocean-${NEW_VERSION}.yaml diff --git a/README.md b/README.md index 27c3018f3..abd031170 100644 --- a/README.md +++ b/README.md @@ -36,19 +36,19 @@ bumped following the rules below: - v0.1.0 - v0.2.x + v0.1.x - v0.2.x yes no no - v0.3.0 - v0.4.x + v0.3.x - v0.4.x no yes no - v1.0.0 - v1.0.x + v1.0.x - v1.0.x no no yes @@ -226,7 +226,7 @@ Dependencies are managed via [Go modules](https://github.com/golang/go/wiki/Modu To release a new version bump first the version: ``` -$ make bump-version +$ make NEW_VERSION=v1.0.0 bump-version ``` Make sure everything looks good. Create a new branch with all changes: