Skip to content

Commit 6595326

Browse files
perdasilvaPer Goncalves da Silva
andcommitted
🌱 parameterizes the e2e target and pins opm images (#3275)
* parameterize e2e target Signed-off-by: Per Goncalves da Silva <[email protected]> * pin opm image Signed-off-by: Per Goncalves da Silva <[email protected]> * update default chart values to point to pinned opm image Signed-off-by: Per Goncalves da Silva <[email protected]> --------- Signed-off-by: Per Goncalves da Silva <[email protected]> Co-authored-by: Per Goncalves da Silva <[email protected]> Upstream-repository: operator-lifecycle-manager Upstream-commit: 1f5e0dc8e55aba20f3cd637e0b021f081e5761bb
1 parent 4cc5232 commit 6595326

File tree

4 files changed

+128
-33
lines changed

4 files changed

+128
-33
lines changed

staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,63 @@ jobs:
1919
- uses: actions/setup-go@v3
2020
with:
2121
go-version-file: "go.mod"
22-
- run: mkdir -p artifacts
23-
- run: make e2e-local E2E_TEST_CHUNK=${{ matrix.parallel-id }} E2E_TEST_NUM_CHUNKS=${{ strategy.job-total }} E2E_NODES=2 ARTIFACT_DIR=./artifacts/ SKIP='\[FLAKE\]'
24-
- name: Archive Test Artifacts # test results, failed or not, are always uploaded.
22+
23+
# load the olm image
24+
- name: Load OLM Docker image
25+
uses: actions/download-artifact@v4
26+
with:
27+
name: olm-image.tar
28+
path: .
29+
- run: docker load < olm-image.tar
30+
31+
# set e2e environment variables
32+
# Set ginkgo output and parallelism
33+
- run: echo "GINKGO_OPTS=-output-dir ${ARTIFACT_DIR} -junit-report junit_e2e.xml -nodes ${E2E_NODES}" >> $GITHUB_ENV
34+
35+
# Setting -kubeconfig-root tells the e2e test suite to look for kubeconfigs
36+
# in <kubeconfig-root>/kubeconfig-<node-number>
37+
# This is used to run tests in parallel on multiple clusters as the current e2e
38+
# test suite does not support running tests in parallel on a single cluster
39+
- run: echo "E2E_OPTS=-kubeconfig-root=${E2E_KUBECONFIG_ROOT}" >> $GITHUB_ENV
40+
41+
# run e2e tests
42+
# create artifacts directory
43+
- run: mkdir -p ${ARTIFACT_DIR}
44+
45+
# deploy test clusters
46+
- name: Deploy test cluster(s)
47+
# create kubeconfig root and store the kubeconfig for each cluster within it as you create the clusters
48+
# Add kind and helm options to specify kubeconfig location
49+
# Deploy the new cluster and helm install olm for testing
50+
run: |
51+
mkdir -p ${E2E_KUBECONFIG_ROOT}
52+
for i in $(seq 1 ${E2E_NODES}); do
53+
KIND_CLUSTER_NAME="kind-olmv0-${i}" \
54+
KIND_CREATE_OPTS="--kubeconfig=${E2E_KUBECONFIG_ROOT}/kubeconfig-${i}" \
55+
HELM_INSTALL_OPTS="--kubeconfig ${E2E_KUBECONFIG_ROOT}/kubeconfig-${i}" \
56+
make kind-create deploy;
57+
done
58+
59+
# run non-flakes if matrix-id is not 'flakes'
60+
- name: Run e2e tests
61+
if: ${{ matrix.parallel-id != 'flakes' }}
62+
# calculate the number of chunks as the number of parallel jobs minus 1 (flakes job)
63+
# use the split tool to split the test suite into chunks and run the chunk corresponding to the matrix-id
64+
# focus on those tests and skip tests marked as FLAKE
65+
run: |
66+
E2E_TEST_NUM_CHUNKS=$(( ${{ strategy.job-total }} - 1 )) \
67+
GINKGO_OPTS="${GINKGO_OPTS} -focus '$(go run ./test/e2e/split/... -chunks $E2E_TEST_NUM_CHUNKS -print-chunk $E2E_TEST_CHUNK ./test/e2e)' -skip '\[FLAKE\]'" \
68+
make e2e;
69+
70+
# run e2e tests for flakes if matrix-id is 'flakes'
71+
- name: Run flaky e2e tests
72+
if: ${{ matrix.parallel-id == 'flakes' }}
73+
# focus on tests marked as FLAKE
74+
run: |
75+
GINKGO_OPTS="${GINKGO_OPTS} -focus '\[FLAKE\]'" make e2e
76+
77+
# archive test results
78+
- name: Archive Test Artifacts
2579
if: ${{ always() }}
2680
uses: actions/upload-artifact@v2
2781
with:

staging/operator-lifecycle-manager/Makefile

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,31 @@ GO := GO111MODULE=on GOFLAGS="$(MOD_FLAGS)" go
2929
GINKGO := $(GO) run github.com/onsi/ginkgo/v2/ginkgo
3030
BINDATA := $(GO) run github.com/go-bindata/go-bindata/v3/go-bindata
3131
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)
3257

3358
# Phony prerequisite for targets that rely on the go build cache to determine staleness.
3459
.PHONY: build test clean vendor \
@@ -116,29 +141,17 @@ deploy-local:
116141
e2e.namespace:
117142
@printf "e2e-tests-$(shell date +%s)-$$RANDOM" > e2e.namespace
118143

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
127145
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
136147
E2E_INSTALL_NS ?= operator-lifecycle-manager
137148
E2E_CATALOG_NS ?= $(E2E_INSTALL_NS)
138-
E2E_TEST_NS ?= operators
139-
149+
GINKGO_OPTS += -v -randomize-suites -race -trace --show-node-events
140150
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
142155

143156
# See workflows/e2e-tests.yml See test/e2e/README.md for details.
144157
.PHONY: e2e-local
@@ -154,15 +167,28 @@ e2e-local: e2e
154167
test/e2e/assets/chart/zz_chart.go: $(shell find deploy/chart -type f)
155168
$(BINDATA) -o $@ -pkg chart -prefix deploy/chart/ $^
156169

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)
166192
docker build -t quay.io/operator-framework/olm:local -f $< bin
167193
docker save -o $@ quay.io/operator-framework/olm:local
168194

@@ -223,25 +249,34 @@ verify-manifests: manifests
223249

224250
verify: verify-codegen verify-mockgen verify-manifests
225251

252+
.PHONY: pull-opm
253+
pull-opm:
254+
docker pull $(OPERATOR_REGISTRY_IMAGE)
255+
226256
# before running release, bump the version in OLM_VERSION and push to master,
227257
# then tag those builds in quay with the version in OLM_VERSION
228258
release: ver=v$(shell cat OLM_VERSION)
229-
release: manifests
259+
# pull the opm image to get the digest
260+
release: pull-opm manifests
230261
@echo "Generating the $(ver) release"
231262
docker pull $(IMAGE_REPO):$(ver)
232263
$(MAKE) target=upstream ver=$(ver) quickstart=true package
233264

234265
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))
235267
package:
236268
ifndef target
237269
$(error target is undefined)
238270
endif
239271
ifndef ver
240272
$(error ver is undefined)
241273
endif
274+
@echo "Getting operator registry image"
275+
docker pull $(OPERATOR_REGISTRY_IMAGE)
242276
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml olm.image.ref $(olmref)
243277
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml catalog.image.ref $(olmref)
244278
$(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)"
245280
./scripts/package_release.sh $(ver) deploy/$(target)/manifests/$(ver) deploy/$(target)/values.yaml
246281
ln -sfFn ./$(ver) deploy/$(target)/manifests/latest
247282
ifeq ($(quickstart), true)

staging/operator-lifecycle-manager/deploy/chart/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ catalog:
4040
setWorkloadUserID: true
4141
replicaCount: 1
4242
commandArgs: --configmapServerImage=quay.io/operator-framework/configmap-operator-registry:latest
43+
opmImageArgs: --opmImage=quay.io/operator-framework/opm:latest
4344
image:
4445
ref: quay.io/operator-framework/olm:master
4546
pullPolicy: Always

staging/operator-lifecycle-manager/test/e2e/magic_catalog.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package e2e
33
import (
44
"context"
55
"fmt"
6+
"os"
67

78
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
89
corev1 "k8s.io/api/core/v1"
@@ -257,12 +258,16 @@ func (c *MagicCatalog) makeCatalogSource() *operatorsv1alpha1.CatalogSource {
257258
func (c *MagicCatalog) makeCatalogSourcePod() *corev1.Pod {
258259

259260
const (
260-
image = "quay.io/operator-framework/upstream-opm-builder"
261261
readinessDelay int32 = 5
262262
livenessDelay int32 = 10
263263
volumeMountName string = "fbc-catalog"
264264
)
265265

266+
var image = "quay.io/operator-framework/opm"
267+
if os.Getenv("OPERATOR_REGISTRY_TAG") != "" {
268+
image = fmt.Sprintf("quay.io/operator-framework/opm:%s", os.Getenv("OPERATOR_REGISTRY_TAG"))
269+
}
270+
266271
return &corev1.Pod{
267272
ObjectMeta: metav1.ObjectMeta{
268273
Name: c.podName,

0 commit comments

Comments
 (0)