Skip to content

Commit

Permalink
🌱 parameterizes the e2e target and pins opm images (operator-framewor…
Browse files Browse the repository at this point in the history
…k#3275)

* parameterize e2e target

Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>

* pin opm image

Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>

* update default chart values to point to pinned opm image

Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>

---------

Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
Co-authored-by: Per Goncalves da Silva <pegoncal@redhat.com>
  • Loading branch information
perdasilva and Per Goncalves da Silva authored May 24, 2024
1 parent f9485ff commit 1f5e0dc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

# set e2e environment variables
# Set ginkgo output and parallelism
- run: echo "GINKGO_E2E_OPTS=-output-dir ${ARTIFACT_DIR} -junit-report junit_e2e.xml -nodes ${E2E_NODES}" >> $GITHUB_ENV
- run: echo "GINKGO_OPTS=-output-dir ${ARTIFACT_DIR} -junit-report junit_e2e.xml -nodes ${E2E_NODES}" >> $GITHUB_ENV

# Setting -kubeconfig-root tells the e2e test suite to look for kubeconfigs
# in <kubeconfig-root>/kubeconfig-<node-number>
Expand Down Expand Up @@ -98,15 +98,15 @@ jobs:
# focus on those tests and skip tests marked as FLAKE
run: |
E2E_TEST_NUM_CHUNKS=$(( ${{ strategy.job-total }} - 1 )) \
GINKGO_E2E_OPTS="${GINKGO_E2E_OPTS} -focus '$(go run ./test/e2e/split/... -chunks $E2E_TEST_NUM_CHUNKS -print-chunk $E2E_TEST_CHUNK ./test/e2e)' -skip '\[FLAKE\]'" \
GINKGO_OPTS="${GINKGO_OPTS} -focus '$(go run ./test/e2e/split/... -chunks $E2E_TEST_NUM_CHUNKS -print-chunk $E2E_TEST_CHUNK ./test/e2e)' -skip '\[FLAKE\]'" \
make e2e;
# run e2e tests for flakes if matrix-id is 'flakes'
- name: Run flaky e2e tests
if: ${{ matrix.parallel-id == 'flakes' }}
# focus on tests marked as FLAKE
run: |
GINKGO_E2E_OPTS="${GINKGO_E2E_OPTS} -focus '\[FLAKE\]'" make e2e
GINKGO_OPTS="${GINKGO_OPTS} -focus '\[FLAKE\]'" make e2e
# archive test results
- name: Archive Test Artifacts
Expand Down
35 changes: 29 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ KIND_NODE_VERSION ?= $(KUBE_MINOR).0
KIND_CLUSTER_NAME ?= kind-olmv0
KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION)

# Take operator registry tag from operator registry version in go.mod
export OPERATOR_REGISTRY_TAG ?= $(shell go list -m github.com/operator-framework/operator-registry | cut -d" " -f2)

# Pin operator registry images to the OPERATOR_REGISTRY_TAG
export OPERATOR_REGISTRY_IMAGE ?= quay.io/operator-framework/opm:$(OPERATOR_REGISTRY_TAG)
export CONFIGMAP_SERVER_IMAGE ?= quay.io/operator-framework/configmap-operator-registry:$(OPERATOR_REGISTRY_TAG)

# Phony prerequisite for targets that rely on the go build cache to determine staleness.
.PHONY: build test clean vendor \
coverage coverage-html e2e \
Expand Down Expand Up @@ -126,10 +133,16 @@ e2e.namespace:
@printf "e2e-tests-$(shell date +%s)-$$RANDOM" > e2e.namespace

.PHONY: e2e
GINKGO_E2E_OPTS += -timeout 90m -v -randomize-suites -race -trace --show-node-events
E2E_OPTS += -namespace=operators -olmNamespace=operator-lifecycle-manager -catalogNamespace=operator-lifecycle-manager -dummyImage=bitnami/nginx:latest
E2E_TIMEOUT ?= 90m
E2E_TEST_NS ?= operators
E2E_INSTALL_NS ?= operator-lifecycle-manager
E2E_CATALOG_NS ?= $(E2E_INSTALL_NS)
GINKGO_OPTS += -v -randomize-suites -race -trace --show-node-events
e2e:
$(GINKGO) $(GINKGO_E2E_OPTS) ./test/e2e -- $(E2E_OPTS)
$(GINKGO) -timeout $(E2E_TIMEOUT) $(GINKGO_OPTS) ./test/e2e -- -namespace=$(E2E_TEST_NS) -olmNamespace=$(E2E_INSTALL_NS) -catalogNamespace=$(E2E_CATALOG_NS) $(E2E_OPTS)

.PHONY: e2e-local
e2e-local: e2e-build kind-create deploy e2e

.PHONY: kind-clean
kind-clean:
Expand All @@ -144,12 +157,14 @@ kind-create: kind-clean
OLM_IMAGE := quay.io/operator-framework/olm:local
deploy:
$(KIND) load docker-image $(OLM_IMAGE) --name $(KIND_CLUSTER_NAME); \
$(HELM) install olm deploy/chart \
$(HELM) upgrade --install olm deploy/chart \
--set debug=true \
--set olm.image.ref=$(OLM_IMAGE) \
--set olm.image.pullPolicy=IfNotPresent \
--set catalog.image.ref=$(OLM_IMAGE) \
--set catalog.image.pullPolicy=IfNotPresent \
--set catalog.commandArgs=--configmapServerImage=$(CONFIGMAP_SERVER_IMAGE) \
--set catalog.opmImageArgs=--opmImage=$(OPERATOR_REGISTRY_IMAGE) \
--set package.image.ref=$(OLM_IMAGE) \
--set package.image.pullPolicy=IfNotPresent \
$(HELM_INSTALL_OPTS) \
Expand All @@ -158,7 +173,6 @@ deploy:
.PHONY: e2e-build
e2e-build: BUILD_TAGS="json1 e2e experimental_metrics"
e2e-build: export GOOS=linux
e2e-build: export GOARCH=amd64
e2e-build: build_cmd=build
e2e-build: e2e.Dockerfile bin/wait bin/cpb $(CMDS)
docker build -t quay.io/operator-framework/olm:local -f $< bin
Expand Down Expand Up @@ -213,25 +227,34 @@ verify-manifests: manifests

verify: vendor verify-codegen verify-mockgen verify-manifests

.PHONY: pull-opm
pull-opm:
docker pull $(OPERATOR_REGISTRY_IMAGE)

# before running release, bump the version in OLM_VERSION and push to master,
# then tag those builds in quay with the version in OLM_VERSION
release: ver=v$(shell cat OLM_VERSION)
release: manifests
# pull the opm image to get the digest
release: pull-opm manifests
@echo "Generating the $(ver) release"
docker pull $(IMAGE_REPO):$(ver)
$(MAKE) target=upstream ver=$(ver) quickstart=true package

package: olmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' $(IMAGE_REPO):$(ver))
package: opmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' $(OPERATOR_REGISTRY_IMAGE))
package:
ifndef target
$(error target is undefined)
endif
ifndef ver
$(error ver is undefined)
endif
@echo "Getting operator registry image"
docker pull $(OPERATOR_REGISTRY_IMAGE)
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml olm.image.ref $(olmref)
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml catalog.image.ref $(olmref)
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml package.image.ref $(olmref)
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml -- catalog.opmImageArgs "--opmImage=$(opmref)"
./scripts/package_release.sh $(ver) deploy/$(target)/manifests/$(ver) deploy/$(target)/values.yaml
ln -sfFn ./$(ver) deploy/$(target)/manifests/latest
ifeq ($(quickstart), true)
Expand Down
1 change: 1 addition & 0 deletions deploy/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ catalog:
setWorkloadUserID: true
replicaCount: 1
commandArgs: --configmapServerImage=quay.io/operator-framework/configmap-operator-registry:latest
opmImageArgs: --opmImage=quay.io/operator-framework/opm:latest
image:
ref: quay.io/operator-framework/olm:master
pullPolicy: Always
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/magic_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package e2e
import (
"context"
"fmt"
"os"

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

const (
image = "quay.io/operator-framework/opm"
readinessDelay int32 = 5
livenessDelay int32 = 10
volumeMountName string = "fbc-catalog"
)

var image = "quay.io/operator-framework/opm"
if os.Getenv("OPERATOR_REGISTRY_TAG") != "" {
image = fmt.Sprintf("quay.io/operator-framework/opm:%s", os.Getenv("OPERATOR_REGISTRY_TAG"))
}

return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: c.podName,
Expand Down

0 comments on commit 1f5e0dc

Please sign in to comment.