Skip to content

Commit a960673

Browse files
committed
Enable e2e testing using https://github.com/bitpoke/build
1 parent 1e9d91c commit a960673

File tree

20 files changed

+272
-186
lines changed

20 files changed

+272
-186
lines changed

.drone.yml

+145-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,83 @@
11
---
22
kind: pipeline
33
name: default
4+
#
5+
# clone:
6+
# disable: true
7+
#
8+
# workspace:
9+
# base: /workspace
10+
# path: src/github.com/bitpoke/mysql-operator
11+
#
12+
# steps:
13+
# - name: git
14+
# pull: default
15+
# image: plugins/git
16+
# settings:
17+
# depth: 0
18+
# tags: true
19+
#
20+
# - name: install dependencies
21+
# pull: always
22+
# image: docker.io/bitpoke/build:v0.4.1
23+
# commands:
24+
# - make -j4 build.tools
25+
#
26+
# - name: verify generated code
27+
# image: docker.io/bitpoke/build:v0.4.1
28+
# commands:
29+
# - make generate
30+
# - git diff --exit-code
31+
#
32+
# - name: lint
33+
# image: docker.io/bitpoke/build:v0.4.1
34+
# commands:
35+
# - make -j4 lint
36+
#
37+
# - name: test
38+
# image: docker.io/bitpoke/build:v0.4.1
39+
# commands:
40+
# - make test
41+
#
42+
# - name: build
43+
# image: docker.io/bitpoke/build:v0.4.1
44+
# commands:
45+
# - make -j4 build
46+
#
47+
# - name: publish
48+
# image: docker.io/bitpoke/build:v0.4.1
49+
# environment:
50+
# DOCKER_REGISTRY:
51+
# from_secret: DOCKER_REGISTRY
52+
# DOCKER_USERNAME:
53+
# from_secret: DOCKER_USERNAME
54+
# DOCKER_PASSWORD:
55+
# from_secret: DOCKER_PASSWORD
56+
# commands:
57+
# - /usr/local/bin/setup-credentials-helper.sh
58+
# - make publish
59+
# when:
60+
# ref:
61+
# - refs/tags/**
62+
#
63+
# services:
64+
# - name: docker
65+
# image: docker:20.10.8-dind
66+
# privileged: true
67+
# commands:
68+
# - /usr/local/bin/dockerd-entrypoint.sh dockerd --host "unix:///workspace/docker.sock" --storage-driver overlay2 --log-level error
69+
#
70+
# trigger:
71+
# ref:
72+
# - refs/pull/**
73+
# - refs/heads/master
74+
# - refs/heads/release-*
75+
# - refs/tags/**
76+
# # CI related changes SHOULD be prefixed with drone-
77+
# - refs/heads/drone-*
78+
# ---
79+
# kind: pipeline
80+
# name: e2e testing
481

582
clone:
683
disable: true
@@ -17,35 +94,38 @@ steps:
1794
depth: 0
1895
tags: true
1996

20-
- name: install dependencies
21-
pull: always
22-
image: docker.io/bitpoke/build:v0.3.0-3.g7069e76
97+
- name: create gke cluster
98+
image: docker.io/bitpoke/build:v0.4.1-2.gffe1bc4-amd64
99+
environment: &e2eEnvironment
100+
# set version in stone, as we need stable tags for e2e testing
101+
VERSION: ${DRONE_COMMIT}
102+
DOCKER_REGISTRY: eu.gcr.io/bitpoke-mysql-operator-testing
103+
GOOGLE_CREDENTIALS:
104+
from_secret: E2E_GOOGLE_CREDENTIALS
105+
GOOGLE_CLOUD_PROJECT: bitpoke-mysql-operator-testing
106+
GOOGLE_CLOUD_ZONE: europe-west4-b
107+
CLUSTER_NAME: mysql-operator-e2e-testing-${DRONE_COMMIT:0:8}
108+
BACKUP_BUCKET_NAME: bitpoke-mysql-operator-testing-backup
23109
commands:
24-
- make -j4 build.tools
25-
26-
- name: verify generated code
27-
image: docker.io/bitpoke/build:v0.3.0-3.g7069e76
28-
commands:
29-
- make generate
30-
- git diff --exit-code
31-
32-
- name: lint
33-
image: docker.io/bitpoke/build:v0.3.0-3.g7069e76
34-
commands:
35-
- make -j4 lint
36-
37-
- name: test
38-
image: docker.io/bitpoke/build:v0.3.0-3.g7069e76
39-
commands:
40-
- make test
110+
- /usr/local/bin/setup-credentials-helper.sh
111+
- gcloud container clusters create $CLUSTER_NAME
112+
--zone $GOOGLE_CLOUD_ZONE
113+
--preemptible
114+
--cluster-version 1.19
115+
--addons=GcePersistentDiskCsiDriver
116+
--monitoring=NONE
41117

42118
- name: build
43-
image: docker.io/bitpoke/build:v0.3.0-3.g7069e76
119+
image: docker.io/bitpoke/build:v0.4.1-2.gffe1bc4-amd64
120+
environment:
121+
<<: *e2eEnvironment
44122
commands:
45123
- make -j4 build
124+
depends_on:
125+
- git
46126

47127
- name: publish
48-
image: docker.io/bitpoke/build:v0.3.0-3.g7069e76
128+
image: docker.io/bitpoke/build:v0.4.1-2.gffe1bc4-amd64
49129
environment:
50130
DOCKER_REGISTRY:
51131
from_secret: DOCKER_REGISTRY
@@ -56,10 +136,51 @@ steps:
56136
commands:
57137
- /usr/local/bin/setup-credentials-helper.sh
58138
- make publish
139+
depends_on:
140+
- build
59141
when:
60142
ref:
61-
- refs/heads/master
62-
- refs/heads/release-*
143+
- refs/tags/**
144+
145+
- name: publish e2e images
146+
image: docker.io/bitpoke/build:v0.4.1-2.gffe1bc4-amd64
147+
environment:
148+
<<: *e2eEnvironment
149+
commands:
150+
- /usr/local/bin/setup-credentials-helper.sh
151+
- make publish
152+
depends_on:
153+
- build
154+
155+
- name: e2e test
156+
image: docker.io/bitpoke/build:v0.4.1-2.gffe1bc4-amd64
157+
environment:
158+
<<: *e2eEnvironment
159+
GOOGLE_CLOUD_CLUSTER: mysql-operator-e2e-testing-${DRONE_COMMIT:0:8}
160+
commands:
161+
- /usr/local/bin/setup-credentials-helper.sh
162+
- make e2e
163+
depends_on:
164+
- publish e2e images
165+
- create gke cluster
166+
167+
- name: delete gke cluster
168+
image: docker.io/bitpoke/build:v0.4.1-2.gffe1bc4-amd64
169+
environment:
170+
<<: *e2eEnvironment
171+
commands:
172+
- /usr/local/bin/setup-credentials-helper.sh
173+
- gcloud container clusters delete $CLUSTER_NAME
174+
--quiet
175+
--async
176+
--zone $GOOGLE_CLOUD_ZONE
177+
failure: ignore
178+
depends_on:
179+
- e2e test
180+
when:
181+
status:
182+
- success
183+
- failure
63184

64185
services:
65186
- name: docker
@@ -70,10 +191,8 @@ services:
70191

71192
trigger:
72193
ref:
73-
- refs/pull/**
74194
- refs/heads/master
75195
- refs/heads/release-*
76-
- refs/tags/**
77196
# CI related changes SHOULD be prefixed with drone-
78197
- refs/heads/drone-*
79198

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Changelog.md merge=union
1+
version.go export-subst

Dockerfile.sidecar

-77
This file was deleted.

Makefile

+44-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ PROJECT_REPO := github.com/bitpoke/mysql-operator
44

55
PLATFORMS := darwin_amd64 linux_amd64
66

7-
DOCKER_REGISTRY := docker.io/bitpoke
8-
IMAGES ?= mysql-operator mysql-operator-sidecar-5.7 mysql-operator-sidecar-8.0
7+
DOCKER_REGISTRY ?= docker.io/bitpoke
8+
IMAGES ?= mysql-operator mysql-operator-orchestrator mysql-operator-sidecar-5.7 mysql-operator-sidecar-8.0
99

1010
GOLANGCI_LINT_VERSION = 1.25.0
1111
GO111MODULE=on
@@ -16,8 +16,46 @@ include build/makelib/kubebuilder-v2.mk
1616
include build/makelib/image.mk
1717

1818
GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/mysql-operator $(GO_PROJECT)/cmd/mysql-operator-sidecar $(GO_PROJECT)/cmd/orc-helper
19+
GO_INTEGRATION_TESTS_SUBDIRS = test/e2e
20+
GO_LDFLAGS += \
21+
-X $(GO_PROJECT)/pkg/version.buildDate=$(BUILD_DATE) \
22+
-X $(GO_PROJECT)/pkg/version.gitVersion=$(VERSION) \
23+
-X $(GO_PROJECT)/pkg/version.gitCommit=$(GIT_COMMIT) \
24+
-X $(GO_PROJECT)/pkg/version.gitTreeState=$(GIT_TREE_STATE)
25+
26+
ifeq ($(CI),true)
27+
E2E_IMAGE_REGISTRY ?= $(DOCKER_REGISTRY)
28+
E2E_IMAGE_TAG ?= $(GIT_COMMIT)
29+
else
30+
E2E_IMAGE_REGISTRY ?= docker.io/$(BUILD_REGISTRY)
31+
E2E_IMAGE_TAG ?= latest
32+
E2E_IMAGE_SUFFIX ?= -$(ARCH)
33+
endif
34+
35+
GO_INTEGRATION_TESTS_PARAMS ?= -timeout 50m \
36+
-ginkgo.slowSpecThreshold 300 \
37+
-- \
38+
--pod-wait-timeout 200 \
39+
--kubernetes-config $(HOME)/.kube/config \
40+
--operator-image $(E2E_IMAGE_REGISTRY)/mysql-operator$(E2E_IMAGE_SUFFIX):$(E2E_IMAGE_TAG) \
41+
--sidecar-mysql57-image $(E2E_IMAGE_REGISTRY)/mysql-operator-sidecar-5.7$(E2E_IMAGE_SUFFIX):$(E2E_IMAGE_TAG) \
42+
--sidecar-mysql8-image $(E2E_IMAGE_REGISTRY)/mysql-operator-sidecar-8.0$(E2E_IMAGE_SUFFIX):$(E2E_IMAGE_TAG) \
43+
--orchestrator-image $(E2E_IMAGE_REGISTRY)/mysql-operator-orchestrator$(E2E_IMAGE_SUFFIX):$(E2E_IMAGE_TAG)
44+
45+
TEST_FILTER_PARAM += $(GO_INTEGRATION_TESTS_PARAMS)
46+
47+
48+
CLUSTER_NAME ?= mysql-operator
49+
delete-environment:
50+
-@kind delete cluster --name $(CLUSTER_NAME)
51+
52+
create-environment: delete-environment
53+
@kind create cluster --name $(CLUSTER_NAME)
54+
@$(MAKE) kind-load-images
55+
56+
kind-load-images:
57+
@set -e; \
58+
for image in $(IMAGES); do \
59+
kind load docker-image --name $(CLUSTER_NAME) $(E2E_IMAGE_REGISTRY)/$${image}$(E2E_IMAGE_SUFFIX):$(E2E_IMAGE_TAG); \
60+
done
1961

20-
GO_LDFLAGS += -X github.com/bitpoke/mysql-operator/pkg/version.buildDate=$(BUILD_DATE) \
21-
-X github.com/bitpoke/mysql-operator/pkg/version.gitVersion=$(VERSION) \
22-
-X github.com/bitpoke/mysql-operator/pkg/version.gitCommit=$(GIT_COMMIT) \
23-
-X github.com/bitpoke/mysql-operator/pkg/version.gitTreeState=$(GIT_TREE_STATE)

charts/mysql-operator/templates/statefulset.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ spec:
9696
- name: data
9797
mountPath: /var/lib/orchestrator/
9898
- name: config
99-
mountPath: /templates/
99+
mountPath: /usr/local/share/orchestrator/templates/
100100
livenessProbe:
101101
timeoutSeconds: 10
102102
initialDelaySeconds: 200

hack/docker/orchestrator/usr/local/bin/docker-entrypoint

-5
This file was deleted.

0 commit comments

Comments
 (0)