diff --git a/Makefile b/Makefile index 4557963b53..a267a32bae 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,9 @@ e2e/operator-registry: ## Run e2e registry tests $(MAKE) e2e WHAT=operator-registry e2e/olm: ## Run e2e olm tests - $(MAKE) e2e WHAT=operator-lifecycle-manager E2E_CATALOG_NS=openshift-marketplace E2E_INSTALL_NS=openshift-operator-lifecycle-manager E2E_TEST_NS=openshift-operators E2E_TIMEOUT=120m KUBECTL=oc + # the operator-registry version is pinned to v1.39.0 - later versions are not compatible with 4.12 + # this is important for a few tests would rely on :latest + $(MAKE) e2e OPERATOR_REGISTRY_TAG=v1.39.0 WHAT=operator-lifecycle-manager E2E_CATALOG_NS=openshift-marketplace E2E_INSTALL_NS=openshift-operator-lifecycle-manager E2E_TEST_NS=openshift-operators E2E_TIMEOUT=120m KUBECTL=oc .PHONY: update-plugin-deps update-plugin-deps: diff --git a/staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml b/staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml index 55eea714ca..857eaf8de7 100644 --- a/staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml +++ b/staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml @@ -19,9 +19,63 @@ jobs: - uses: actions/setup-go@v3 with: go-version-file: "go.mod" - - run: mkdir -p artifacts - - 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\]' - - name: Archive Test Artifacts # test results, failed or not, are always uploaded. + + # load the olm image + - name: Load OLM Docker image + uses: actions/download-artifact@v4 + with: + name: olm-image.tar + path: . + - run: docker load < olm-image.tar + + # set e2e environment variables + # Set ginkgo output and parallelism + - 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- + # This is used to run tests in parallel on multiple clusters as the current e2e + # test suite does not support running tests in parallel on a single cluster + - run: echo "E2E_OPTS=-kubeconfig-root=${E2E_KUBECONFIG_ROOT}" >> $GITHUB_ENV + + # run e2e tests + # create artifacts directory + - run: mkdir -p ${ARTIFACT_DIR} + + # deploy test clusters + - name: Deploy test cluster(s) + # create kubeconfig root and store the kubeconfig for each cluster within it as you create the clusters + # Add kind and helm options to specify kubeconfig location + # Deploy the new cluster and helm install olm for testing + run: | + mkdir -p ${E2E_KUBECONFIG_ROOT} + for i in $(seq 1 ${E2E_NODES}); do + KIND_CLUSTER_NAME="kind-olmv0-${i}" \ + KIND_CREATE_OPTS="--kubeconfig=${E2E_KUBECONFIG_ROOT}/kubeconfig-${i}" \ + HELM_INSTALL_OPTS="--kubeconfig ${E2E_KUBECONFIG_ROOT}/kubeconfig-${i}" \ + make kind-create deploy; + done + + # run non-flakes if matrix-id is not 'flakes' + - name: Run e2e tests + if: ${{ matrix.parallel-id != 'flakes' }} + # calculate the number of chunks as the number of parallel jobs minus 1 (flakes job) + # use the split tool to split the test suite into chunks and run the chunk corresponding to the matrix-id + # focus on those tests and skip tests marked as FLAKE + run: | + E2E_TEST_NUM_CHUNKS=$(( ${{ strategy.job-total }} - 1 )) \ + 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_OPTS="${GINKGO_OPTS} -focus '\[FLAKE\]'" make e2e + + # archive test results + - name: Archive Test Artifacts if: ${{ always() }} uses: actions/upload-artifact@v2 with: diff --git a/staging/operator-lifecycle-manager/Makefile b/staging/operator-lifecycle-manager/Makefile index f892f12e95..dd9d1b74c3 100644 --- a/staging/operator-lifecycle-manager/Makefile +++ b/staging/operator-lifecycle-manager/Makefile @@ -29,6 +29,18 @@ GO := GO111MODULE=on GOFLAGS="$(MOD_FLAGS)" go GINKGO := $(GO) run github.com/onsi/ginkgo/v2/ginkgo BINDATA := $(GO) run github.com/go-bindata/go-bindata/v3/go-bindata GIT_COMMIT := $(shell git rev-parse HEAD) +ifeq ($(shell arch), arm64) +ARCH := arm64 +else +ARCH := 386 +endif + +# 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 \ @@ -223,15 +235,21 @@ verify-manifests: manifests verify: 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) @@ -239,15 +257,19 @@ 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) ./scripts/package_quickstart.sh deploy/$(target)/manifests/$(ver) deploy/$(target)/quickstart/olm.yaml deploy/$(target)/quickstart/crds.yaml deploy/$(target)/quickstart/install.sh endif + ################################ # OLM - Install/Uninstall/Run # ################################ diff --git a/staging/operator-lifecycle-manager/deploy/chart/values.yaml b/staging/operator-lifecycle-manager/deploy/chart/values.yaml index 5870f3230a..ffb5891842 100644 --- a/staging/operator-lifecycle-manager/deploy/chart/values.yaml +++ b/staging/operator-lifecycle-manager/deploy/chart/values.yaml @@ -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 diff --git a/staging/operator-lifecycle-manager/pkg/controller/operators/olm/operator_test.go b/staging/operator-lifecycle-manager/pkg/controller/operators/olm/operator_test.go index f3fba8603f..0c49a95b60 100644 --- a/staging/operator-lifecycle-manager/pkg/controller/operators/olm/operator_test.go +++ b/staging/operator-lifecycle-manager/pkg/controller/operators/olm/operator_test.go @@ -3923,9 +3923,10 @@ func TestUpdates(t *testing.T) { simulateSuccessfulRollout(current, op.opClient) } for current.Status.Phase != e.whenIn.phase { - fmt.Printf("waiting for (when) %s to be %s\n", e.whenIn.name, e.whenIn.phase) csvsToSync = syncCSVs(csvsToSync, deletedCSVs(e.shouldBe)) current = csvsToSync[e.whenIn.name] + fmt.Printf("waiting for (when) %s to be %s\n", e.whenIn.name, e.whenIn.phase) + time.Sleep(1 * time.Second) } // sync the other csvs until they're in the expected status diff --git a/staging/operator-lifecycle-manager/test/e2e/magic_catalog.go b/staging/operator-lifecycle-manager/test/e2e/magic_catalog.go index 983340b083..68bb5c3a5f 100644 --- a/staging/operator-lifecycle-manager/test/e2e/magic_catalog.go +++ b/staging/operator-lifecycle-manager/test/e2e/magic_catalog.go @@ -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" @@ -257,12 +258,16 @@ func (c *MagicCatalog) makeCatalogSource() *operatorsv1alpha1.CatalogSource { func (c *MagicCatalog) makeCatalogSourcePod() *corev1.Pod { const ( - image = "quay.io/operator-framework/upstream-opm-builder" 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,