Skip to content

Commit bda8d9a

Browse files
pengzhoumlPeng Zhou
andauthored
MLE-15924 Setup E2E test in Jenkins using Minikube (#42)
* MLE-15924 Jenkins with Minikube * update versions * update docker image version * removed comments * update comment --------- Co-authored-by: Peng Zhou <[email protected]>
1 parent 79fc108 commit bda8d9a

File tree

5 files changed

+31
-57
lines changed

5 files changed

+31
-57
lines changed

Jenkinsfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ void runTests() {
125125
}
126126

127127
void runE2eTests() {
128-
//TODO: this is just a place holder as kuttl needs a proper environment
129-
sh "echo make e2e-tests dockerImage=${params.dockerImage}"
128+
sh '''
129+
make e2e-setup-minikube
130+
make e2e-test
131+
'''
130132
}
131133

132134
pipeline {

Makefile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
66
VERSION ?= 0.0.1
77

8+
export E2E_DOCKER_IMAGE ?= $(IMG)
9+
export E2E_KUSTOMIZE_VERSION ?= $(KUSTOMIZE_VERSION)
10+
export E2E_CONTROLLER_TOOLS_VERSION ?= $(CONTROLLER_TOOLS_VERSION)
11+
export E2E_MARKLOGIC_IMAGE_VERSION ?= progressofficial/marklogic-db:11.3.1-ubi-rootless-2.1.0
12+
export E2E_KUBERNETES_VERSION ?= v1.30.4
13+
14+
815
# CHANNELS define the bundle channels used in the bundle.
916
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
1017
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
@@ -117,8 +124,15 @@ test: manifests generate fmt vet envtest ## Run tests.
117124

118125
# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
119126
.PHONY: e2e-test # Run the e2e tests against a Kind k8s instance that is spun up.
120-
e2e-test:
127+
e2e-test:
121128
go test -v -count=1 ./test/e2e
129+
minikube delete || true
130+
131+
e2e-setup-minikube: kustomize controller-gen build docker-build
132+
minikube delete || true
133+
minikube start --driver=docker --kubernetes-version=$(E2E_KUBERNETES_VERSION) --memory=8192 --cpus=2
134+
minikube addons enable ingress
135+
minikube image load $(IMG)
122136

123137
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
124138
GOLANGCI_LINT_VERSION ?= v1.54.2
@@ -215,11 +229,6 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
215229
KUSTOMIZE_VERSION ?= v5.5.0
216230
CONTROLLER_TOOLS_VERSION ?= v0.16.4
217231

218-
export E2E_DOCKER_IMAGE ?= $(IMG)
219-
export E2E_KUSTOMIZE_VERSION ?= $(KUSTOMIZE_VERSION)
220-
export E2E_CONTROLLER_TOOLS_VERSION ?= $(CONTROLLER_TOOLS_VERSION)
221-
export E2E_MARKLOGIC_IMAGE_VERSION ?= marklogicdb/marklogic-db:11.2.0-ubi-rootless
222-
export E2E_KUBERNETES_VERSION ?= v1.30.4
223232

224233

225234
.PHONY: kustomize

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ kind: Kustomization
55
images:
66
- name: controller
77
newName: ml-marklogic-operator-dev.bed-artifactory.bedford.progress.com/marklogic-kubernetes-operator
8-
newTag: 0.0.2
8+
newTag: 1.0.0-ea2

test/e2e/2_marklogic_cluster_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestMarklogicCluster(t *testing.T) {
8585
client := c.Client()
8686

8787
podName := "dnode-0"
88-
err := utils.WaitForPod(ctx, t, client, mlNamespace, podName, 60*time.Second)
88+
err := utils.WaitForPod(ctx, t, client, mlNamespace, podName, 90*time.Second)
8989
if err != nil {
9090
t.Fatalf("Failed to wait for pod creation: %v", err)
9191
}

test/e2e/main_test.go

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,35 @@ import (
1111
appsv1 "k8s.io/api/apps/v1"
1212
v1 "k8s.io/api/core/v1"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14+
"sigs.k8s.io/e2e-framework/klient/conf"
1415
"sigs.k8s.io/e2e-framework/klient/wait"
1516
"sigs.k8s.io/e2e-framework/klient/wait/conditions"
1617
"sigs.k8s.io/e2e-framework/pkg/env"
1718
"sigs.k8s.io/e2e-framework/pkg/envconf"
1819
"sigs.k8s.io/e2e-framework/pkg/envfuncs"
19-
"sigs.k8s.io/e2e-framework/support/kind"
2020
"sigs.k8s.io/e2e-framework/support/utils"
2121
)
2222

2323
var (
24-
testEnv env.Environment
25-
dockerImage = os.Getenv("E2E_DOCKER_IMAGE") //"ml-marklogic-operator-dev.bed-artifactory.bedford.progress.com/marklogic-kubernetes-operator:0.0.2"
26-
kustomizeVer = os.Getenv("E2E_KUSTOMIZE_VERSION")
24+
testEnv env.Environment
25+
dockerImage = os.Getenv("E2E_DOCKER_IMAGE")
26+
kustomizeVer = os.Getenv("E2E_KUSTOMIZE_VERSION")
2727
ctrlgenVer = os.Getenv("E2E_CONTROLLER_TOOLS_VERSION")
2828
marklogicImage = os.Getenv("E2E_MARKLOGIC_IMAGE_VERSION")
2929
kubernetesVer = os.Getenv("E2E_KUBERNETES_VERSION")
3030
)
3131

3232
const (
33-
namespace = "marklogic-operator-system"
33+
namespace = "marklogic-operator-system"
3434
)
3535

3636
func TestMain(m *testing.M) {
3737
testEnv = env.New()
38-
kindClusterName := "test-cluster"
39-
kindCluster := kind.NewCluster(kindClusterName)
38+
path := conf.ResolveKubeConfigFile()
39+
cfg := envconf.NewWithKubeConfig(path)
40+
testEnv = env.NewWithConfig(cfg)
41+
42+
log.Printf("Running tests with the following configurations: path=%s", path)
4043

4144
log.Printf("Docker image: %s", dockerImage)
4245
log.Printf("Kustomize version: %s", kustomizeVer)
@@ -46,7 +49,6 @@ func TestMain(m *testing.M) {
4649

4750
// Use Environment.Setup to configure pre-test setup
4851
testEnv.Setup(
49-
envfuncs.CreateClusterWithConfig(kindCluster, kindClusterName, "kind-config.yaml", kind.WithImage("kindest/node:"+kubernetesVer)),
5052
envfuncs.CreateNamespace(namespace),
5153

5254
// install tool dependencies
@@ -83,43 +85,6 @@ func TestMain(m *testing.M) {
8385
c := utils.RunCommand("controller-gen --version")
8486
log.Printf("controller-gen: %s", c.Result())
8587

86-
// generate manifest files
87-
log.Println("Generate manifests...")
88-
wd, _ := os.Getwd()
89-
log.Print(wd) // Output current working directory
90-
if p := utils.RunCommand(`controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases`); p.Err() != nil {
91-
log.Printf("Failed to generate manifests: %s: %s", p.Err(), p.Result())
92-
return ctx, p.Err()
93-
}
94-
95-
// generate api objects
96-
log.Println("Generate API objects...")
97-
if p := utils.RunCommand(`controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."`); p.Err() != nil {
98-
log.Printf("Failed to generate API objects: %s: %s", p.Err(), p.Result())
99-
return ctx, p.Err()
100-
}
101-
102-
// Build docker image
103-
log.Println("Building docker image...")
104-
if p := utils.RunCommand(fmt.Sprintf("docker build -t %s .", dockerImage)); p.Err() != nil {
105-
log.Printf("Failed to build docker image: %s: %s", p.Err(), p.Result())
106-
return ctx, p.Err()
107-
}
108-
109-
// Load docker image into kind
110-
log.Println("Loading docker image into kind cluster...")
111-
if err := kindCluster.LoadImage(ctx, dockerImage); err != nil {
112-
log.Printf("Failed to load image into kind: %s", err)
113-
return ctx, err
114-
}
115-
116-
// Load MarkLogic image into kind
117-
log.Println("Loading marklogic image into kind cluster...")
118-
if err := kindCluster.LoadImage(ctx, marklogicImage); err != nil {
119-
log.Printf("Failed to load image into kind: %s", err)
120-
return ctx, err
121-
}
122-
12388
// Deploy components
12489
log.Println("Deploying controller-manager resources...")
12590
p := utils.RunCommand(`kubectl version`)
@@ -160,8 +125,6 @@ func TestMain(m *testing.M) {
160125
return ctx, nil
161126
},
162127
envfuncs.DeleteNamespace(namespace),
163-
// envfuncs.ExportClusterLogs(kindClusterName, "../../logs"),
164-
envfuncs.DestroyCluster(kindClusterName),
165128
)
166129

167130
// Use Environment.Run to launch the test

0 commit comments

Comments
 (0)