@@ -29,6 +29,31 @@ GO := GO111MODULE=on GOFLAGS="$(MOD_FLAGS)" go
29
29
GINKGO := $(GO ) run github.com/onsi/ginkgo/v2/ginkgo
30
30
BINDATA := $(GO ) run github.com/go-bindata/go-bindata/v3/go-bindata
31
31
GIT_COMMIT := $(shell git rev-parse HEAD)
32
+ ifeq ($(shell arch) , arm64)
33
+ ARCH := arm64
34
+ else
35
+ ARCH := 386
36
+ endif
37
+
38
+ # Track the minor version of kubernetes we are building against by looking at the client-go dependency version
39
+ # For example, a client-go version of v0.28.5 will map to kube version 1.28
40
+ KUBE_MINOR ?= $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1/')
41
+
42
+ # Unit test against the latest available version for the minor version of kubernetes we are building against e.g. 1.30.x
43
+ ENVTEST_KUBE_VERSION ?= $(KUBE_MINOR ) .x
44
+
45
+ # Kind node image tags are in the format x.y.z we pin to version x.y.0 because patch releases and node images
46
+ # are not guaranteed to be available when a new version of the kube apis is released
47
+ KIND_NODE_VERSION ?= $(KUBE_MINOR ) .0
48
+ KIND_CLUSTER_NAME ?= kind-olmv0
49
+ KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION )
50
+
51
+ # Take operator registry tag from operator registry version in go.mod
52
+ export OPERATOR_REGISTRY_TAG ?= $(shell go list -m github.com/operator-framework/operator-registry | cut -d" " -f2)
53
+
54
+ # Pin operator registry images to the OPERATOR_REGISTRY_TAG
55
+ export OPERATOR_REGISTRY_IMAGE ?= quay.io/operator-framework/opm :$(OPERATOR_REGISTRY_TAG )
56
+ export CONFIGMAP_SERVER_IMAGE ?= quay.io/operator-framework/configmap-operator-registry :$(OPERATOR_REGISTRY_TAG )
32
57
33
58
# Phony prerequisite for targets that rely on the go build cache to determine staleness.
34
59
.PHONY : build test clean vendor \
@@ -116,29 +141,17 @@ deploy-local:
116
141
e2e.namespace :
117
142
@printf " e2e-tests-$( shell date +%s) -$$ RANDOM" > e2e.namespace
118
143
119
- # useful if running e2e directly with `go test -tags=bare`
120
- setup-bare : clean e2e.namespace
121
- . ./scripts/build_bare.sh
122
- . ./scripts/package_release.sh 1.0.0 test/e2e/resources test/e2e/e2e-bare-values.yaml
123
- . ./scripts/install_bare.sh $(shell cat ./e2e.namespace) test/e2e/resources
124
-
125
- E2E_NODES ?= 1
126
- E2E_FLAKE_ATTEMPTS ?= 1
144
+ .PHONY : e2e
127
145
E2E_TIMEOUT ?= 90m
128
- # Optionally run an individual chunk of e2e test specs.
129
- # Do not use this from the CLI; this is intended to be used by CI only.
130
- E2E_TEST_CHUNK ?= all
131
- E2E_TEST_NUM_CHUNKS ?= 4
132
- ifneq (all,$(E2E_TEST_CHUNK ) )
133
- TEST := $(shell go run ./test/e2e/split/... -chunks $(E2E_TEST_NUM_CHUNKS ) -print-chunk $(E2E_TEST_CHUNK ) ./test/e2e)
134
- endif
135
- E2E_OPTS ?= $(if $(E2E_SEED ) ,-seed '$(E2E_SEED ) ') $(if $(SKIP ) , -skip '$(SKIP ) ') $(if $(TEST ) ,-focus '$(TEST ) ') $(if $(ARTIFACT_DIR ) , -output-dir $(ARTIFACT_DIR ) -junit-report junit_e2e.xml) -flake-attempts $(E2E_FLAKE_ATTEMPTS ) -nodes $(E2E_NODES ) -timeout $(E2E_TIMEOUT ) -v -randomize-suites -race -trace -progress
146
+ E2E_TEST_NS ?= operators
136
147
E2E_INSTALL_NS ?= operator-lifecycle-manager
137
148
E2E_CATALOG_NS ?= $(E2E_INSTALL_NS )
138
- E2E_TEST_NS ?= operators
139
-
149
+ GINKGO_OPTS += -v -randomize-suites -race -trace --show-node-events
140
150
e2e :
141
- $(GINKGO ) $(E2E_OPTS ) $(or $(run ) , ./test/e2e) $< -- -namespace=$(E2E_TEST_NS ) -olmNamespace=$(E2E_INSTALL_NS ) -catalogNamespace=$(E2E_CATALOG_NS ) -dummyImage=bitnami/nginx:latest $(or $(extra_args ) , -kubeconfig=${KUBECONFIG})
151
+ $(GINKGO ) -timeout $(E2E_TIMEOUT ) $(GINKGO_OPTS ) ./test/e2e -- -namespace=$(E2E_TEST_NS ) -olmNamespace=$(E2E_INSTALL_NS ) -catalogNamespace=$(E2E_CATALOG_NS ) $(E2E_OPTS )
152
+
153
+ .PHONY : e2e-local
154
+ e2e-local : e2e-build kind-create deploy e2e
142
155
143
156
# See workflows/e2e-tests.yml See test/e2e/README.md for details.
144
157
.PHONY : e2e-local
@@ -154,15 +167,28 @@ e2e-local: e2e
154
167
test/e2e/assets/chart/zz_chart.go : $(shell find deploy/chart -type f)
155
168
$(BINDATA ) -o $@ -pkg chart -prefix deploy/chart/ $^
156
169
157
- # execute kind and helm end to end tests
158
- bin/e2e-local.test : FORCE test/e2e/assets/chart/zz_chart.go
159
- $(GO ) test -c -tags kind,helm -o $@ ./test/e2e
160
-
161
- # set go env and other vars, ensure that the dockerfile exists, and then build wait, cpb, and other command binaries and finally the kind image archive
162
- test/e2e-local.image.tar : export GOOS=linux
163
- test/e2e-local.image.tar : export GOARCH=386
164
- test/e2e-local.image.tar : build_cmd=build
165
- test/e2e-local.image.tar : e2e.Dockerfile bin/wait bin/cpb $(CMDS )
170
+ .PHONY : deploy
171
+ OLM_IMAGE := quay.io/operator-framework/olm:local
172
+ deploy :
173
+ $(KIND ) load docker-image $(OLM_IMAGE ) --name $(KIND_CLUSTER_NAME ) ; \
174
+ $(HELM ) upgrade --install olm deploy/chart \
175
+ --set debug=true \
176
+ --set olm.image.ref=$(OLM_IMAGE ) \
177
+ --set olm.image.pullPolicy=IfNotPresent \
178
+ --set catalog.image.ref=$(OLM_IMAGE ) \
179
+ --set catalog.image.pullPolicy=IfNotPresent \
180
+ --set catalog.commandArgs=--configmapServerImage=$(CONFIGMAP_SERVER_IMAGE ) \
181
+ --set catalog.opmImageArgs=--opmImage=$(OPERATOR_REGISTRY_IMAGE ) \
182
+ --set package.image.ref=$(OLM_IMAGE ) \
183
+ --set package.image.pullPolicy=IfNotPresent \
184
+ $(HELM_INSTALL_OPTS ) \
185
+ --wait;
186
+
187
+ .PHONY : e2e-build
188
+ e2e-build : BUILD_TAGS="json1 e2e experimental_metrics"
189
+ e2e-build : export GOOS=linux
190
+ e2e-build : build_cmd=build
191
+ e2e-build : e2e.Dockerfile bin/wait bin/cpb $(CMDS )
166
192
docker build -t quay.io/operator-framework/olm:local -f $< bin
167
193
docker save -o $@ quay.io/operator-framework/olm:local
168
194
@@ -223,25 +249,34 @@ verify-manifests: manifests
223
249
224
250
verify : verify-codegen verify-mockgen verify-manifests
225
251
252
+ .PHONY : pull-opm
253
+ pull-opm :
254
+ docker pull $(OPERATOR_REGISTRY_IMAGE )
255
+
226
256
# before running release, bump the version in OLM_VERSION and push to master,
227
257
# then tag those builds in quay with the version in OLM_VERSION
228
258
release : ver=v$(shell cat OLM_VERSION)
229
- release : manifests
259
+ # pull the opm image to get the digest
260
+ release : pull-opm manifests
230
261
@echo " Generating the $( ver) release"
231
262
docker pull $(IMAGE_REPO ) :$(ver )
232
263
$(MAKE ) target=upstream ver=$(ver ) quickstart=true package
233
264
234
265
package : olmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' $(IMAGE_REPO ) :$(ver ) )
266
+ package : opmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' $(OPERATOR_REGISTRY_IMAGE ) )
235
267
package :
236
268
ifndef target
237
269
$(error target is undefined)
238
270
endif
239
271
ifndef ver
240
272
$(error ver is undefined)
241
273
endif
274
+ @echo "Getting operator registry image"
275
+ docker pull $(OPERATOR_REGISTRY_IMAGE)
242
276
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml olm.image.ref $(olmref)
243
277
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml catalog.image.ref $(olmref)
244
278
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml package.image.ref $(olmref)
279
+ $(YQ_INTERNAL) w -i deploy/$(target)/values.yaml -- catalog.opmImageArgs "--opmImage=$(opmref)"
245
280
./scripts/package_release.sh $(ver) deploy/$(target)/manifests/$(ver) deploy/$(target)/values.yaml
246
281
ln -sfFn ./$(ver) deploy/$(target)/manifests/latest
247
282
ifeq ($(quickstart ) , true)
0 commit comments