Skip to content

Commit 5c0959e

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 d22e45e commit 5c0959e

File tree

4 files changed

+111
-33
lines changed

4 files changed

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

staging/operator-lifecycle-manager/Makefile

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ ARCH := arm64
3434
else
3535
ARCH := 386
3636
endif
37+
38+
# Take operator registry tag from operator registry version in go.mod
39+
export OPERATOR_REGISTRY_TAG ?= $(shell go list -m github.com/operator-framework/operator-registry | cut -d" " -f2)
40+
41+
# Pin operator registry images to the OPERATOR_REGISTRY_TAG
42+
export OPERATOR_REGISTRY_IMAGE ?= quay.io/operator-framework/opm:$(OPERATOR_REGISTRY_TAG)
43+
export CONFIGMAP_SERVER_IMAGE ?= quay.io/operator-framework/configmap-operator-registry:$(OPERATOR_REGISTRY_TAG)
44+
3745
# Phony prerequisite for targets that rely on the go build cache to determine staleness.
3846
.PHONY: build test clean vendor \
3947
coverage coverage-html e2e \
@@ -123,29 +131,17 @@ deploy-local:
123131
e2e.namespace:
124132
@printf "e2e-tests-$(shell date +%s)-$$RANDOM" > e2e.namespace
125133

126-
# useful if running e2e directly with `go test -tags=bare`
127-
setup-bare: clean e2e.namespace
128-
. ./scripts/build_bare.sh
129-
. ./scripts/package_release.sh 1.0.0 test/e2e/resources test/e2e/e2e-bare-values.yaml
130-
. ./scripts/install_bare.sh $(shell cat ./e2e.namespace) test/e2e/resources
131-
132-
E2E_NODES ?= 1
133-
E2E_FLAKE_ATTEMPTS ?= 1
134+
.PHONY: e2e
134135
E2E_TIMEOUT ?= 90m
135-
# Optionally run an individual chunk of e2e test specs.
136-
# Do not use this from the CLI; this is intended to be used by CI only.
137-
E2E_TEST_CHUNK ?= all
138-
E2E_TEST_NUM_CHUNKS ?= 4
139-
ifneq (all,$(E2E_TEST_CHUNK))
140-
TEST := $(shell go run ./test/e2e/split/... -chunks $(E2E_TEST_NUM_CHUNKS) -print-chunk $(E2E_TEST_CHUNK) ./test/e2e)
141-
endif
142-
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
136+
E2E_TEST_NS ?= operators
143137
E2E_INSTALL_NS ?= operator-lifecycle-manager
144138
E2E_CATALOG_NS ?= $(E2E_INSTALL_NS)
145-
E2E_TEST_NS ?= operators
146-
139+
GINKGO_OPTS += -v -randomize-suites -race -trace --show-node-events
147140
e2e:
148-
$(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})
141+
$(GINKGO) -timeout $(E2E_TIMEOUT) $(GINKGO_OPTS) ./test/e2e -- -namespace=$(E2E_TEST_NS) -olmNamespace=$(E2E_INSTALL_NS) -catalogNamespace=$(E2E_CATALOG_NS) $(E2E_OPTS)
142+
143+
.PHONY: e2e-local
144+
e2e-local: e2e-build kind-create deploy e2e
149145

150146
# See workflows/e2e-tests.yml See test/e2e/README.md for details.
151147
.PHONY: e2e-local
@@ -161,15 +157,28 @@ e2e-local: e2e
161157
test/e2e/assets/chart/zz_chart.go: $(shell find deploy/chart -type f)
162158
$(BINDATA) -o $@ -pkg chart -prefix deploy/chart/ $^
163159

164-
# execute kind and helm end to end tests
165-
bin/e2e-local.test: FORCE test/e2e/assets/chart/zz_chart.go
166-
$(GO) test -c -tags kind,helm -o $@ ./test/e2e
167-
168-
# 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
169-
test/e2e-local.image.tar: export GOOS=linux
170-
test/e2e-local.image.tar: export GOARCH=386
171-
test/e2e-local.image.tar: build_cmd=build
172-
test/e2e-local.image.tar: e2e.Dockerfile bin/wait bin/cpb $(CMDS)
160+
.PHONY: deploy
161+
OLM_IMAGE := quay.io/operator-framework/olm:local
162+
deploy:
163+
$(KIND) load docker-image $(OLM_IMAGE) --name $(KIND_CLUSTER_NAME); \
164+
$(HELM) upgrade --install olm deploy/chart \
165+
--set debug=true \
166+
--set olm.image.ref=$(OLM_IMAGE) \
167+
--set olm.image.pullPolicy=IfNotPresent \
168+
--set catalog.image.ref=$(OLM_IMAGE) \
169+
--set catalog.image.pullPolicy=IfNotPresent \
170+
--set catalog.commandArgs=--configmapServerImage=$(CONFIGMAP_SERVER_IMAGE) \
171+
--set catalog.opmImageArgs=--opmImage=$(OPERATOR_REGISTRY_IMAGE) \
172+
--set package.image.ref=$(OLM_IMAGE) \
173+
--set package.image.pullPolicy=IfNotPresent \
174+
$(HELM_INSTALL_OPTS) \
175+
--wait;
176+
177+
.PHONY: e2e-build
178+
e2e-build: BUILD_TAGS="json1 e2e experimental_metrics"
179+
e2e-build: export GOOS=linux
180+
e2e-build: build_cmd=build
181+
e2e-build: e2e.Dockerfile bin/wait bin/cpb $(CMDS)
173182
docker build -t quay.io/operator-framework/olm:local -f $< bin
174183
docker save -o $@ quay.io/operator-framework/olm:local
175184

@@ -230,25 +239,34 @@ verify-manifests: manifests
230239

231240
verify: verify-codegen verify-mockgen verify-manifests
232241

242+
.PHONY: pull-opm
243+
pull-opm:
244+
docker pull $(OPERATOR_REGISTRY_IMAGE)
245+
233246
# before running release, bump the version in OLM_VERSION and push to master,
234247
# then tag those builds in quay with the version in OLM_VERSION
235248
release: ver=v$(shell cat OLM_VERSION)
236-
release: manifests
249+
# pull the opm image to get the digest
250+
release: pull-opm manifests
237251
@echo "Generating the $(ver) release"
238252
docker pull $(IMAGE_REPO):$(ver)
239253
$(MAKE) target=upstream ver=$(ver) quickstart=true package
240254

241255
package: olmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' $(IMAGE_REPO):$(ver))
256+
package: opmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' $(OPERATOR_REGISTRY_IMAGE))
242257
package:
243258
ifndef target
244259
$(error target is undefined)
245260
endif
246261
ifndef ver
247262
$(error ver is undefined)
248263
endif
264+
@echo "Getting operator registry image"
265+
docker pull $(OPERATOR_REGISTRY_IMAGE)
249266
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml olm.image.ref $(olmref)
250267
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml catalog.image.ref $(olmref)
251268
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml package.image.ref $(olmref)
269+
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml -- catalog.opmImageArgs "--opmImage=$(opmref)"
252270
./scripts/package_release.sh $(ver) deploy/$(target)/manifests/$(ver) deploy/$(target)/values.yaml
253271
ln -sfFn ./$(ver) deploy/$(target)/manifests/latest
254272
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/opm"
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)