Skip to content

Commit f972977

Browse files
committed
Set up CI for e2e test
1 parent 7e65a2b commit f972977

14 files changed

+281
-160
lines changed

Gopkg.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
PKG=sigs.k8s.io/blobfuse-csi-driver
16-
REGISTRY_NAME?=andyzhangx
17-
IMAGE_NAME=blobfuse-csi
18-
IMAGE_VERSION=v0.4.0
19-
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(IMAGE_VERSION)
20-
IMAGE_TAG_LATEST=$(REGISTRY_NAME)/$(IMAGE_NAME):latest
21-
GIT_COMMIT?=$(shell git rev-parse HEAD)
22-
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
23-
LDFLAGS?="-X ${PKG}/pkg/blobfuse.driverVersion=${IMAGE_VERSION} -X ${PKG}/pkg/blobfuse.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/blobfuse.buildDate=${BUILD_DATE} -s -w -extldflags '-static'"
15+
PKG = sigs.k8s.io/blobfuse-csi-driver
16+
REGISTRY ?= andyzhangx
17+
IMAGE_NAME = blobfuse-csi
18+
IMAGE_VERSION ?= v0.4.0
19+
# Use a custom version for E2E tests if we are in Prow
20+
ifdef AZURE_CREDENTIALS
21+
override IMAGE_VERSION := e2e-$(GIT_COMMIT)
22+
endif
23+
IMAGE_TAG = $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_VERSION)
24+
IMAGE_TAG_LATEST = $(REGISTRY_NAME)/$(IMAGE_NAME):latest
25+
GIT_COMMIT ?= $(shell git rev-parse HEAD)
26+
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
27+
LDFLAGS ?= "-X ${PKG}/pkg/blobfuse.driverVersion=${IMAGE_VERSION} -X ${PKG}/pkg/blobfuse.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/blobfuse.buildDate=${BUILD_DATE} -s -w -extldflags '-static'"
28+
GINKGO_FLAGS = -ginkgo.noColor -ginkgo.v
2429
GO111MODULE = off
2530
export GO111MODULE
2631

@@ -44,7 +49,28 @@ integration-test: blobfuse
4449

4550
.PHONY: e2e-test
4651
e2e-test:
47-
test/e2e/run-test.sh
52+
go test -v -timeout=0 ./test/e2e ${GINKGO_FLAGS}
53+
54+
.PHONY: e2e-bootstrap
55+
e2e-bootstrap: install-helm
56+
# Only build and push the image if it does not exist in the registry
57+
docker pull $(IMAGE_TAG) || make blobfuse-container push
58+
helm install charts/latest/blobfuse-csi-driver -n blobfuse-csi-driver --namespace kube-system --wait \
59+
--set image.blobfuse.pullPolicy=IfNotPresent \
60+
--set image.blobfuse.repository=$(REGISTRY)/$(IMAGE_NAME) \
61+
--set image.blobfuse.tag=$(IMAGE_VERSION)
62+
63+
.PHONY: install-helm
64+
install-helm:
65+
# Use v2.11.0 helm to match tiller's version in clusters made by aks-engine
66+
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | DESIRED_VERSION=v2.11.0 bash
67+
# Make sure tiller is ready
68+
kubectl wait pod -l name=tiller --namespace kube-system --for condition=ready --timeout 5m
69+
helm version
70+
71+
.PHONY: e2e-teardown
72+
e2e-teardown:
73+
helm delete --purge blobfuse-csi-driver
4874

4975
.PHONY: blobfuse
5076
blobfuse:

test/e2e/dynamic_provisioning.go renamed to test/e2e/dynamic_provisioning_test.go

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,17 @@ package e2e
1818

1919
import (
2020
"fmt"
21-
"os"
2221

23-
"sigs.k8s.io/blobfuse-csi-driver/pkg/blobfuse"
2422
"sigs.k8s.io/blobfuse-csi-driver/test/e2e/driver"
2523
"sigs.k8s.io/blobfuse-csi-driver/test/e2e/testsuites"
2624

27-
. "github.com/onsi/ginkgo"
28-
"github.com/pborman/uuid"
25+
"github.com/onsi/ginkgo"
2926
v1 "k8s.io/api/core/v1"
3027
clientset "k8s.io/client-go/kubernetes"
3128
"k8s.io/kubernetes/test/e2e/framework"
3229
)
3330

34-
var _ = Describe("Dynamic Provisioning", func() {
31+
var _ = ginkgo.Describe("[blobfuse-csi-e2e] Dynamic Provisioning", func() {
3532
f := framework.NewDefaultFramework("blobfuse")
3633

3734
var (
@@ -40,21 +37,13 @@ var _ = Describe("Dynamic Provisioning", func() {
4037
testDriver driver.PVTestDriver
4138
)
4239

43-
nodeid := os.Getenv("nodeid")
44-
blobfuseDriver := blobfuse.NewDriver(nodeid)
45-
endpoint := fmt.Sprintf("unix:///tmp/csi-%s.sock", uuid.NewUUID().String())
46-
47-
go func() {
48-
blobfuseDriver.Run(endpoint)
49-
}()
50-
51-
BeforeEach(func() {
40+
ginkgo.BeforeEach(func() {
5241
cs = f.ClientSet
5342
ns = f.Namespace
5443
})
5544

5645
testDriver = driver.InitBlobFuseCSIDriver()
57-
It(fmt.Sprintf("should create a volume on demand"), func() {
46+
ginkgo.It(fmt.Sprintf("should create a volume on demand"), func() {
5847
pods := []testsuites.PodDetails{
5948
{
6049
Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data",
@@ -76,7 +65,7 @@ var _ = Describe("Dynamic Provisioning", func() {
7665
test.Run(cs, ns)
7766
})
7867

79-
It("should create a deployment object, write and read to it, delete the pod and write and read to it again", func() {
68+
ginkgo.It("should create a deployment object, write and read to it, delete the pod and write and read to it again", func() {
8069
pod := testsuites.PodDetails{
8170
Cmd: "echo 'hello world' >> /mnt/test-1/data && while true; do sleep 1; done",
8271
Volumes: []testsuites.VolumeDetails{
@@ -102,7 +91,7 @@ var _ = Describe("Dynamic Provisioning", func() {
10291
})
10392

10493
// Track issue https://github.com/kubernetes/kubernetes/issues/70505
105-
It("should create a volume on demand and mount it as readOnly in a pod", func() {
94+
ginkgo.It("should create a volume on demand and mount it as readOnly in a pod", func() {
10695
pods := []testsuites.PodDetails{
10796
{
10897
Cmd: "touch /mnt/test-1/data",
@@ -126,7 +115,7 @@ var _ = Describe("Dynamic Provisioning", func() {
126115
test.Run(cs, ns)
127116
})
128117

129-
It("should create multiple PV objects, bind to PVCs and attach all to different pods on the same node", func() {
118+
ginkgo.It("should create multiple PV objects, bind to PVCs and attach all to different pods on the same node", func() {
130119
pods := []testsuites.PodDetails{
131120
{
132121
Cmd: "while true; do echo $(date -u) >> /mnt/test-1/data; sleep 1; done",
@@ -163,7 +152,7 @@ var _ = Describe("Dynamic Provisioning", func() {
163152
test.Run(cs, ns)
164153
})
165154

166-
It(fmt.Sprintf("should delete PV with reclaimPolicy %q", v1.PersistentVolumeReclaimDelete), func() {
155+
ginkgo.It(fmt.Sprintf("should delete PV with reclaimPolicy %q", v1.PersistentVolumeReclaimDelete), func() {
167156
reclaimPolicy := v1.PersistentVolumeReclaimDelete
168157
volumes := []testsuites.VolumeDetails{
169158
{
@@ -179,7 +168,7 @@ var _ = Describe("Dynamic Provisioning", func() {
179168
test.Run(cs, ns)
180169
})
181170

182-
It(fmt.Sprintf("[env] should retain PV with reclaimPolicy %q", v1.PersistentVolumeReclaimRetain), func() {
171+
ginkgo.It(fmt.Sprintf("[env] should retain PV with reclaimPolicy %q", v1.PersistentVolumeReclaimRetain), func() {
183172
reclaimPolicy := v1.PersistentVolumeReclaimRetain
184173
volumes := []testsuites.VolumeDetails{
185174
{

test/e2e/pre_provisioning.go renamed to test/e2e/pre_provisioning_test.go

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@ package e2e
1919
import (
2020
"context"
2121
"fmt"
22-
"os"
2322

24-
"sigs.k8s.io/blobfuse-csi-driver/pkg/blobfuse"
2523
"sigs.k8s.io/blobfuse-csi-driver/test/e2e/driver"
2624
"sigs.k8s.io/blobfuse-csi-driver/test/e2e/testsuites"
2725

2826
"github.com/container-storage-interface/spec/lib/go/csi"
29-
. "github.com/onsi/ginkgo"
30-
"github.com/pborman/uuid"
27+
"github.com/onsi/ginkgo"
3128
v1 "k8s.io/api/core/v1"
3229
clientset "k8s.io/client-go/kubernetes"
3330
"k8s.io/kubernetes/test/e2e/framework"
@@ -41,7 +38,7 @@ var (
4138
defaultVolumeSizeBytes int64 = defaultVolumeSize * 1024 * 1024 * 1024
4239
)
4340

44-
var _ = Describe("[blobfuse-csi-e2e] [single-az] Pre-Provisioned", func() {
41+
var _ = ginkgo.Describe("[blobfuse-csi-e2e] Pre-Provisioned", func() {
4542
f := framework.NewDefaultFramework("blobfuse")
4643

4744
var (
@@ -52,40 +49,33 @@ var _ = Describe("[blobfuse-csi-e2e] [single-az] Pre-Provisioned", func() {
5249
// Set to true if the volume should be deleted automatically after test
5350
skipManuallyDeletingVolume bool
5451
)
55-
nodeid := os.Getenv("nodeid")
56-
blobfuseDriver := blobfuse.NewDriver(nodeid)
57-
endpoint := fmt.Sprintf("unix:///tmp/csi-%s.sock", uuid.NewUUID().String())
5852

59-
go func() {
60-
blobfuseDriver.Run(endpoint)
61-
}()
62-
63-
BeforeEach(func() {
53+
ginkgo.BeforeEach(func() {
6454
cs = f.ClientSet
6555
ns = f.Namespace
6656
testDriver = driver.InitBlobFuseCSIDriver()
6757
})
6858

69-
AfterEach(func() {
59+
ginkgo.AfterEach(func() {
7060
if !skipManuallyDeletingVolume {
7161
req := &csi.DeleteVolumeRequest{
7262
VolumeId: volumeID,
7363
}
7464
_, err := blobfuseDriver.DeleteVolume(context.Background(), req)
7565
if err != nil {
76-
Fail(fmt.Sprintf("create volume %q error: %v", volumeID, err))
66+
ginkgo.Fail(fmt.Sprintf("create volume %q error: %v", volumeID, err))
7767
}
7868
}
7969
})
8070

81-
It("[env] should use a pre-provisioned volume and mount it as readOnly in a pod", func() {
71+
ginkgo.It("[env] should use a pre-provisioned volume and mount it as readOnly in a pod", func() {
8272
req := makeCreateVolumeReq("pre-provisioned-readOnly")
8373
resp, err := blobfuseDriver.CreateVolume(context.Background(), req)
8474
if err != nil {
85-
Fail(fmt.Sprintf("create volume error: %v", err))
75+
ginkgo.Fail(fmt.Sprintf("create volume error: %v", err))
8676
}
8777
volumeID = resp.Volume.VolumeId
88-
By(fmt.Sprintf("Successfully provisioned BloBFuse volume: %q\n", volumeID))
78+
ginkgo.By(fmt.Sprintf("Successfully provisioned BloBFuse volume: %q\n", volumeID))
8979

9080
volumeSize := fmt.Sprintf("%dGi", defaultVolumeSize)
9181
pods := []testsuites.PodDetails{
@@ -112,14 +102,14 @@ var _ = Describe("[blobfuse-csi-e2e] [single-az] Pre-Provisioned", func() {
112102
test.Run(cs, ns)
113103
})
114104

115-
It(fmt.Sprintf("[env] should use a pre-provisioned volume and retain PV with reclaimPolicy %q", v1.PersistentVolumeReclaimRetain), func() {
105+
ginkgo.It(fmt.Sprintf("[env] should use a pre-provisioned volume and retain PV with reclaimPolicy %q", v1.PersistentVolumeReclaimRetain), func() {
116106
req := makeCreateVolumeReq("pre-provisioned-retain-reclaimPolicy")
117107
resp, err := blobfuseDriver.CreateVolume(context.Background(), req)
118108
if err != nil {
119-
Fail(fmt.Sprintf("create volume error: %v", err))
109+
ginkgo.Fail(fmt.Sprintf("create volume error: %v", err))
120110
}
121111
volumeID = resp.Volume.VolumeId
122-
By(fmt.Sprintf("Successfully provisioned BlobFuse volume: %q\n", volumeID))
112+
ginkgo.By(fmt.Sprintf("Successfully provisioned BlobFuse volume: %q\n", volumeID))
123113

124114
volumeSize := fmt.Sprintf("%dGi", defaultVolumeSize)
125115
reclaimPolicy := v1.PersistentVolumeReclaimRetain

test/e2e/run-test.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)