1
1
##########################
2
2
# OLM - Build and Test #
3
3
##########################
4
+ # Setting SHELL to bash allows bash commands to be executed by recipes.
5
+ # Options are set to exit when a recipe line exits non-zero or a piped command fails.
6
+ SHELL := /usr/bin/env bash -o pipefail
7
+ .SHELLFLAGS := -ec
4
8
5
9
# Undefine GOFLAGS environment variable.
6
10
ifdef GOFLAGS
@@ -22,6 +26,8 @@ SPECIFIC_UNIT_TEST := $(if $(TEST),-run $(TEST),)
22
26
LOCAL_NAMESPACE := "olm"
23
27
export GO111MODULE=on
24
28
YQ_INTERNAL := go run $(MOD_FLAGS) ./vendor/github.com/mikefarah/yq/v3/
29
+ HELM := go run $(MOD_FLAGS) ./vendor/helm.sh/helm/v3/cmd/helm
30
+ KIND := go run $(MOD_FLAGS) ./vendor/sigs.k8s.io/kind
25
31
KUBEBUILDER_ASSETS := $(or $(or $(KUBEBUILDER_ASSETS),$(dir $(shell command -v kubebuilder))),/usr/local/kubebuilder/bin)
26
32
export KUBEBUILDER_ASSETS
27
33
GO := GO111MODULE=on GOFLAGS="$(MOD_FLAGS)" go
@@ -33,6 +39,15 @@ ARCH := arm64
33
39
else
34
40
ARCH := amd64
35
41
endif
42
+
43
+ KIND_CLUSTER_NAME ?= kind-olmv0
44
+ # Not guaranteed to have patch releases available and node image tags are full versions (i.e v1.28.0 - no v1.28, v1.29, etc.)
45
+ # The KIND_NODE_VERSION is set by getting the version of the k8s.io/client-go dependency from the go.mod
46
+ # and sets major version to "1" and the patch version to "0". For example, a client-go version of v0.28.5
47
+ # will map to a KIND_NODE_VERSION of 1.28.0
48
+ KIND_NODE_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.0/')
49
+ KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION)
50
+
36
51
# Phony prerequisite for targets that rely on the go build cache to determine staleness.
37
52
.PHONY: build test clean vendor \
38
53
coverage coverage-html e2e \
@@ -118,49 +133,43 @@ deploy-local:
118
133
e2e.namespace:
119
134
@printf "e2e-tests-$(shell date +%s)-$$RANDOM" > e2e.namespace
120
135
121
- E2E_NODES ?= 1
122
- E2E_FLAKE_ATTEMPTS ?= 1
123
- E2E_TIMEOUT ?= 90m
124
- # Optionally run an individual chunk of e2e test specs.
125
- # Do not use this from the CLI; this is intended to be used by CI only.
126
- E2E_TEST_CHUNK ?= all
127
- E2E_TEST_NUM_CHUNKS ?= 4
128
- ifneq (all,$(E2E_TEST_CHUNK))
129
- TEST := $(shell go run ./test/e2e/split/... -chunks $(E2E_TEST_NUM_CHUNKS) -print-chunk $(E2E_TEST_CHUNK) ./test/e2e)
130
- endif
131
- 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
132
- E2E_INSTALL_NS ?= operator-lifecycle-manager
133
- E2E_CATALOG_NS ?= $(E2E_INSTALL_NS)
134
- E2E_TEST_NS ?= operators
135
-
136
+ .PHONY: e2e
137
+ GINKGO_E2E_OPTS += -timeout 90m -v -randomize-suites -race -trace --show-node-events
138
+ E2E_OPTS += -namespace=operators -olmNamespace=operator-lifecycle-manager -catalogNamespace=operator-lifecycle-manager -dummyImage=bitnami/nginx:latest
136
139
e2e:
137
- $(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})
138
-
139
- # See workflows/e2e-tests.yml See test/e2e/README.md for details.
140
- .PHONY: e2e-local
141
- e2e-local: BUILD_TAGS="json1 e2e experimental_metrics"
142
- e2e-local: extra_args=-kind.images=../test/e2e-local.image.tar -test-data-dir=../test/e2e/testdata -gather-artifacts-script-path=../test/e2e/collect-ci-artifacts.sh
143
- e2e-local: run=bin/e2e-local.test
144
- e2e-local: bin/e2e-local.test test/e2e-local.image.tar
145
- e2e-local: e2e
146
-
147
- # this target updates the zz_chart.go file with files found in deploy/chart
148
- # this will always fire since it has been marked as phony
149
- .PHONY: test/e2e/assets/chart/zz_chart.go
150
- test/e2e/assets/chart/zz_chart.go: $(shell find deploy/chart -type f)
151
- $(BINDATA) -o $@ -pkg chart -prefix deploy/chart/ $^
152
-
153
- # execute kind and helm end to end tests
154
- bin/e2e-local.test: FORCE test/e2e/assets/chart/zz_chart.go
155
- $(GO) test -c -tags kind,helm -o $@ ./test/e2e
156
-
157
- # 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
158
- test/e2e-local.image.tar: export GOOS=linux
159
- test/e2e-local.image.tar: export GOARCH=amd64
160
- test/e2e-local.image.tar: build_cmd=build
161
- test/e2e-local.image.tar: e2e.Dockerfile bin/wait bin/cpb $(CMDS)
140
+ $(GINKGO) $(GINKGO_E2E_OPTS) ./test/e2e -- $(E2E_OPTS)
141
+
142
+ .PHONY: kind-clean
143
+ kind-clean:
144
+ $(KIND) delete cluster --name $(KIND_CLUSTER_NAME) || true
145
+
146
+ .PHONY: kind-create
147
+ kind-create: kind-clean
148
+ $(KIND) create cluster --name $(KIND_CLUSTER_NAME) --image $(KIND_CLUSTER_IMAGE) $(KIND_CREATE_OPTS)
149
+ $(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME)
150
+
151
+ .PHONY: deploy
152
+ OLM_IMAGE := quay.io/operator-framework/olm:local
153
+ deploy:
154
+ $(KIND) load docker-image $(OLM_IMAGE) --name $(KIND_CLUSTER_NAME); \
155
+ $(HELM) install olm deploy/chart \
156
+ --set debug=true \
157
+ --set olm.image.ref=$(OLM_IMAGE) \
158
+ --set olm.image.pullPolicy=IfNotPresent \
159
+ --set catalog.image.ref=$(OLM_IMAGE) \
160
+ --set catalog.image.pullPolicy=IfNotPresent \
161
+ --set package.image.ref=$(OLM_IMAGE) \
162
+ --set package.image.pullPolicy=IfNotPresent \
163
+ $(HELM_INSTALL_OPTS) \
164
+ --wait;
165
+
166
+ .PHONY: e2e-build
167
+ e2e-build: BUILD_TAGS="json1 e2e experimental_metrics"
168
+ e2e-build: export GOOS=linux
169
+ e2e-build: export GOARCH=amd64
170
+ e2e-build: build_cmd=build
171
+ e2e-build: e2e.Dockerfile bin/wait bin/cpb $(CMDS)
162
172
docker build -t quay.io/operator-framework/olm:local -f $< bin
163
- docker save -o $@ quay.io/operator-framework/olm:local
164
173
165
174
vendor:
166
175
go mod tidy
0 commit comments