diff --git a/.github/workflows/catalogd-e2e.yaml b/.github/workflows/catalogd-e2e.yaml deleted file mode 100644 index 323b75522..000000000 --- a/.github/workflows/catalogd-e2e.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: catalogd-e2e - -on: - workflow_dispatch: - merge_group: - pull_request: - push: - branches: - - main - -jobs: - upgrade-e2e: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - - name: Run the upgrade e2e test - run: make test-catalogd-upgrade-e2e diff --git a/Makefile b/Makefile index c0a737df9..2de91e63c 100644 --- a/Makefile +++ b/Makefile @@ -72,8 +72,6 @@ CATALOGD_KUSTOMIZE_BUILD_DIR := catalogd/config/overlays/cert-manager .DEFAULT_GOAL := build -GINKGO := go run github.com/onsi/ginkgo/v2/ginkgo - #SECTION General # The help target prints out all targets with their descriptions organized @@ -226,26 +224,6 @@ test-e2e: GO_BUILD_FLAGS := -cover test-e2e: CATALOGD_KUSTOMIZE_BUILD_DIR := catalogd/config/overlays/e2e test-e2e: run image-registry e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster - -## image-registry target has to come after run-latest-release, -## because the image-registry depends on the olm-ca issuer. -.PHONY: test-catalogd-upgrade-e2e -test-catalogd-upgrade-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog -test-catalogd-upgrade-e2e: export TEST_CLUSTER_CATALOG_IMAGE := docker-registry.catalogd-e2e.svc:5000/test-catalog:e2e -test-catalogd-upgrade-e2e: ISSUER_KIND=ClusterIssuer -test-catalogd-upgrade-e2e: ISSUER_NAME=olmv1-ca -test-catalogd-upgrade-e2e: kind-cluster docker-build kind-load run-latest-release catalogd-image-registry catalogd-pre-upgrade-setup kind-deploy catalogd-post-upgrade-checks kind-clean ## Run upgrade e2e tests on a local kind cluster - -.PHONY: catalogd-post-upgrade-checks -catalogd-post-upgrade-checks: - $(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/catalogd-upgrade-e2e - -catalogd-pre-upgrade-setup: - ./test/tools/imageregistry/pre-upgrade-setup.sh ${TEST_CLUSTER_CATALOG_IMAGE} ${TEST_CLUSTER_CATALOG_NAME} - -catalogd-image-registry: ## Setup in-cluster image registry - ./test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME) - .PHONY: extension-developer-e2e extension-developer-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/cert-manager extension-developer-e2e: KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e #EXHELP Run extension-developer e2e on local kind cluster diff --git a/catalogd/testdata/catalogs/test-catalog/.indexignore b/catalogd/testdata/catalogs/test-catalog/.indexignore deleted file mode 100644 index 699fa6d33..000000000 --- a/catalogd/testdata/catalogs/test-catalog/.indexignore +++ /dev/null @@ -1,2 +0,0 @@ -/expected_all.json -..* diff --git a/catalogd/testdata/catalogs/test-catalog/catalog.yaml b/catalogd/testdata/catalogs/test-catalog/catalog.yaml deleted file mode 100644 index 14d33b9d9..000000000 --- a/catalogd/testdata/catalogs/test-catalog/catalog.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -schema: olm.package -name: prometheus -defaultChannel: beta ---- -schema: olm.channel -name: beta -package: prometheus -entries: - - name: prometheus-operator.0.47.0 ---- -schema: olm.bundle -name: prometheus-operator.0.47.0 -package: prometheus -image: localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0 -properties: - - type: olm.package - value: - packageName: prometheus - version: 0.47.0 diff --git a/catalogd/testdata/catalogs/test-catalog/expected_all.json b/catalogd/testdata/catalogs/test-catalog/expected_all.json deleted file mode 100644 index 554488982..000000000 --- a/catalogd/testdata/catalogs/test-catalog/expected_all.json +++ /dev/null @@ -1,3 +0,0 @@ -{"defaultChannel":"beta","name":"prometheus","schema":"olm.package"} -{"entries":[{"name":"prometheus-operator.0.47.0"}],"name":"beta","package":"prometheus","schema":"olm.channel"} -{"image":"localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0","name":"prometheus-operator.0.47.0","package":"prometheus","properties":[{"type":"olm.package","value":{"packageName":"prometheus","version":"0.47.0"}}],"schema":"olm.bundle"} diff --git a/go.mod b/go.mod index 5ca0635d8..d9d286ec5 100644 --- a/go.mod +++ b/go.mod @@ -15,8 +15,6 @@ require ( github.com/google/go-containerregistry v0.20.3 github.com/gorilla/handlers v1.5.2 github.com/klauspost/compress v1.17.11 - github.com/onsi/ginkgo/v2 v2.22.2 - github.com/onsi/gomega v1.36.2 github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.1.0 github.com/operator-framework/api v0.29.0 @@ -116,7 +114,6 @@ require ( github.com/go-openapi/strfmt v0.23.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-openapi/validate v0.24.0 // indirect - github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -125,7 +122,6 @@ require ( github.com/google/cel-go v0.22.1 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/mux v1.8.1 // indirect @@ -178,6 +174,7 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/oklog/ulid v1.3.1 // indirect + github.com/onsi/gomega v1.36.2 // indirect github.com/opencontainers/runtime-spec v1.2.0 // indirect github.com/openshift/crd-schema-checker v0.0.0-20240404194209-35a9033b1d11 // indirect github.com/operator-framework/operator-lib v0.17.0 // indirect diff --git a/test/catalogd-upgrade-e2e/unpack_test.go b/test/catalogd-upgrade-e2e/unpack_test.go deleted file mode 100644 index 07b599afd..000000000 --- a/test/catalogd-upgrade-e2e/unpack_test.go +++ /dev/null @@ -1,142 +0,0 @@ -package catalogdupgradee2e - -import ( - "bufio" - "context" - "fmt" - "os" - "strings" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/google/go-cmp/cmp" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" - - catalogdv1 "github.com/operator-framework/operator-controller/catalogd/api/v1" - testutils "github.com/operator-framework/operator-controller/test/utils" -) - -var _ = Describe("ClusterCatalog Unpacking", func() { - When("A ClusterCatalog is created", func() { - It("Successfully unpacks catalog contents", func() { - ctx := context.Background() - - var managerDeployment appsv1.Deployment - managerLabelSelector := labels.Set{"control-plane": "catalogd-controller-manager"} - By("Checking that the controller-manager deployment is updated") - Eventually(func(g Gomega) { - var managerDeployments appsv1.DeploymentList - err := c.List(ctx, &managerDeployments, client.MatchingLabels(managerLabelSelector), client.InNamespace("olmv1-system")) - g.Expect(err).ToNot(HaveOccurred()) - g.Expect(managerDeployments.Items).To(HaveLen(1)) - managerDeployment = managerDeployments.Items[0] - g.Expect(managerDeployment.Status.UpdatedReplicas).To(Equal(*managerDeployment.Spec.Replicas)) - g.Expect(managerDeployment.Status.Replicas).To(Equal(*managerDeployment.Spec.Replicas)) - g.Expect(managerDeployment.Status.AvailableReplicas).To(Equal(*managerDeployment.Spec.Replicas)) - g.Expect(managerDeployment.Status.ReadyReplicas).To(Equal(*managerDeployment.Spec.Replicas)) - }).Should(Succeed()) - - var managerPod corev1.Pod - By("Waiting for only one controller-manager pod to remain") - Eventually(func(g Gomega) { - var managerPods corev1.PodList - err := c.List(ctx, &managerPods, client.MatchingLabels(managerLabelSelector)) - g.Expect(err).ToNot(HaveOccurred()) - g.Expect(managerPods.Items).To(HaveLen(1)) - managerPod = managerPods.Items[0] - }).Should(Succeed()) - - By("Waiting for acquired leader election") - // Average case is under 1 minute but in the worst case: (previous leader crashed) - // we could have LeaseDuration (137s) + RetryPeriod (26s) +/- 163s - leaderCtx, leaderCancel := context.WithTimeout(ctx, 3*time.Minute) - defer leaderCancel() - - leaderSubstrings := []string{"successfully acquired lease"} - leaderElected, err := watchPodLogsForSubstring(leaderCtx, &managerPod, "manager", leaderSubstrings...) - Expect(err).To(Succeed()) - Expect(leaderElected).To(BeTrue()) - - By("Reading logs to make sure that ClusterCatalog was reconciled by catalogdv1") - logCtx, cancel := context.WithTimeout(ctx, time.Minute) - defer cancel() - substrings := []string{ - "reconcile ending", - fmt.Sprintf(`ClusterCatalog=%q`, testClusterCatalogName), - } - found, err := watchPodLogsForSubstring(logCtx, &managerPod, "manager", substrings...) - Expect(err).ToNot(HaveOccurred()) - Expect(found).To(BeTrue()) - - catalog := &catalogdv1.ClusterCatalog{} - By("Ensuring ClusterCatalog has Status.Condition of Progressing with a status == True, reason == Succeeded") - Eventually(func(g Gomega) { - err := c.Get(ctx, types.NamespacedName{Name: testClusterCatalogName}, catalog) - g.Expect(err).ToNot(HaveOccurred()) - cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogdv1.TypeProgressing) - g.Expect(cond).ToNot(BeNil()) - g.Expect(cond.Status).To(Equal(metav1.ConditionTrue)) - g.Expect(cond.Reason).To(Equal(catalogdv1.ReasonSucceeded)) - }).Should(Succeed()) - - expectedFBC, err := os.ReadFile("../../catalogd/testdata/catalogs/test-catalog/expected_all.json") - Expect(err).To(Not(HaveOccurred())) - - By("Making sure the catalog content is available via the http server") - Eventually(func(g Gomega) { - actualFBC, err := testutils.ReadTestCatalogServerContents(ctx, catalog, kubeClient) - g.Expect(err).To(Not(HaveOccurred())) - g.Expect(cmp.Diff(expectedFBC, actualFBC)).To(BeEmpty()) - }).Should(Succeed()) - - By("Ensuring ClusterCatalog has Status.Condition of Serving with a status == True, reason == Available") - Eventually(func(g Gomega) { - err := c.Get(ctx, types.NamespacedName{Name: testClusterCatalogName}, catalog) - g.Expect(err).ToNot(HaveOccurred()) - cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogdv1.TypeServing) - g.Expect(cond).ToNot(BeNil()) - g.Expect(cond.Status).To(Equal(metav1.ConditionTrue)) - g.Expect(cond.Reason).To(Equal(catalogdv1.ReasonAvailable)) - }).Should(Succeed()) - }) - }) -}) - -func watchPodLogsForSubstring(ctx context.Context, pod *corev1.Pod, container string, substrings ...string) (bool, error) { - podLogOpts := corev1.PodLogOptions{ - Follow: true, - Container: container, - } - - req := kubeClient.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &podLogOpts) - podLogs, err := req.Stream(ctx) - if err != nil { - return false, err - } - defer podLogs.Close() - - scanner := bufio.NewScanner(podLogs) - for scanner.Scan() { - line := scanner.Text() - - foundCount := 0 - for _, substring := range substrings { - if strings.Contains(line, substring) { - foundCount++ - } - } - if foundCount == len(substrings) { - return true, nil - } - } - - return false, scanner.Err() -} diff --git a/test/catalogd-upgrade-e2e/upgrade_suite_test.go b/test/catalogd-upgrade-e2e/upgrade_suite_test.go deleted file mode 100644 index 76e0114e8..000000000 --- a/test/catalogd-upgrade-e2e/upgrade_suite_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package catalogdupgradee2e - -import ( - "os" - "testing" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - catalogdv1 "github.com/operator-framework/operator-controller/catalogd/api/v1" -) - -const ( - testClusterCatalogNameEnv = "TEST_CLUSTER_CATALOG_NAME" -) - -var ( - cfg *rest.Config - c client.Client - err error - kubeClient kubernetes.Interface - - testClusterCatalogName string -) - -func TestUpgradeE2E(t *testing.T) { - RegisterFailHandler(Fail) - SetDefaultEventuallyTimeout(1 * time.Minute) - SetDefaultEventuallyPollingInterval(1 * time.Second) - RunSpecs(t, "Upgrade E2E Suite") -} - -var _ = BeforeSuite(func() { - cfg = ctrl.GetConfigOrDie() - - sch := scheme.Scheme - Expect(catalogdv1.AddToScheme(sch)).To(Succeed()) - c, err = client.New(cfg, client.Options{Scheme: sch}) - Expect(err).To(Not(HaveOccurred())) - kubeClient, err = kubernetes.NewForConfig(cfg) - Expect(err).ToNot(HaveOccurred()) - - var ok bool - testClusterCatalogName, ok = os.LookupEnv(testClusterCatalogNameEnv) - Expect(ok).To(BeTrue()) -}) diff --git a/test/tools/imageregistry/imagebuilder.yaml b/test/tools/imageregistry/imagebuilder.yaml deleted file mode 100644 index a9035ccdd..000000000 --- a/test/tools/imageregistry/imagebuilder.yaml +++ /dev/null @@ -1,32 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: kaniko - namespace: catalogd-e2e -spec: - template: - spec: - containers: - - name: kaniko - image: gcr.io/kaniko-project/executor:latest - args: ["--dockerfile=/workspace/test-catalog.Dockerfile", - "--context=/workspace/", - "--destination=docker-registry.catalogd-e2e.svc:5000/test-catalog:e2e", - "--skip-tls-verify"] - terminationMessagePolicy: FallbackToLogsOnError - volumeMounts: - - name: dockerfile - mountPath: /workspace/ - - name: build-contents - mountPath: /workspace/test-catalog/ - restartPolicy: Never - volumes: - - name: dockerfile - configMap: - name: catalogd-e2e.dockerfile - items: - - key: test-catalog.Dockerfile - path: test-catalog.Dockerfile - - name: build-contents - configMap: - name: catalogd-e2e.build-contents diff --git a/test/tools/imageregistry/imgreg.yaml b/test/tools/imageregistry/imgreg.yaml deleted file mode 100644 index c8a104351..000000000 --- a/test/tools/imageregistry/imgreg.yaml +++ /dev/null @@ -1,75 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: catalogd-e2e ---- -apiVersion: cert-manager.io/v1 -kind: Issuer -metadata: - name: selfsigned-issuer - namespace: catalogd-e2e -spec: - selfSigned: {} ---- -apiVersion: cert-manager.io/v1 -kind: Certificate -metadata: - name: catalogd-e2e-registry - namespace: catalogd-e2e -spec: - secretName: catalogd-e2e-registry - isCA: true - dnsNames: - - docker-registry.catalogd-e2e.svc - privateKey: - algorithm: ECDSA - size: 256 - issuerRef: - name: ${ISSUER_NAME} - kind: ${ISSUER_KIND} - group: cert-manager.io ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: docker-registry - namespace: catalogd-e2e - labels: - app: registry -spec: - replicas: 1 - selector: - matchLabels: - app: registry - template: - metadata: - labels: - app: registry - spec: - containers: - - name: registry - image: registry:2 - volumeMounts: - - name: certs-vol - mountPath: "/certs" - env: - - name: REGISTRY_HTTP_TLS_CERTIFICATE - value: "/certs/tls.crt" - - name: REGISTRY_HTTP_TLS_KEY - value: "/certs/tls.key" - volumes: - - name: certs-vol - secret: - secretName: catalogd-e2e-registry ---- -apiVersion: v1 -kind: Service -metadata: - name: docker-registry - namespace: catalogd-e2e -spec: - selector: - app: registry - ports: - - port: 5000 - targetPort: 5000 diff --git a/test/tools/imageregistry/pre-upgrade-setup.sh b/test/tools/imageregistry/pre-upgrade-setup.sh deleted file mode 100755 index 707e2c9e6..000000000 --- a/test/tools/imageregistry/pre-upgrade-setup.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -euo pipefail - - -help="pre-upgrade-setup.sh is used to create some basic resources -which will later be used in upgrade testing. - -Usage: - pre-upgrade-setup.sh [TEST_CLUSTER_CATALOG_IMAGE] [TEST_CLUSTER_CATALOG_NAME] -" - -if [[ "$#" -ne 2 ]]; then - echo "Illegal number of arguments passed" - echo "${help}" - exit 1 -fi - -export TEST_CLUSTER_CATALOG_IMAGE=$1 -export TEST_CLUSTER_CATALOG_NAME=$2 - -kubectl apply -f - << EOF -apiVersion: olm.operatorframework.io/v1 -kind: ClusterCatalog -metadata: - name: ${TEST_CLUSTER_CATALOG_NAME} -spec: - source: - type: Image - image: - ref: ${TEST_CLUSTER_CATALOG_IMAGE} -EOF - -kubectl wait --for=condition=Serving --timeout=60s ClusterCatalog "$TEST_CLUSTER_CATALOG_NAME" diff --git a/test/tools/imageregistry/registry.sh b/test/tools/imageregistry/registry.sh deleted file mode 100755 index 969dff3ec..000000000 --- a/test/tools/imageregistry/registry.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# registry.sh will create an in-cluster image registry useful for end-to-end testing -# of catalogd's unpacking process. It does a few things: -# 1. Installs cert-manager for creating a self-signed certificate for the image registry -# 2. Creates all the resources necessary for deploying the image registry in the catalogd-e2e namespace -# 3. Creates ConfigMaps containing the test catalog + Dockerfile to be mounted to the kaniko pod -# 4. Waits for kaniko pod to have Condition Complete == true, indicating the test catalog image has been built + pushed -# to the test image registry -# Usage: -# registry.sh - -if [[ "$#" -ne 2 ]]; then - echo "Incorrect number of arguments passed" - echo "Usage: registry.sh " - exit 1 -fi - -export ISSUER_KIND=$1 -export ISSUER_NAME=$2 - -# create the image registry with all the certs -envsubst '${ISSUER_KIND},${ISSUER_NAME}' < test/tools/imageregistry/imgreg.yaml | kubectl apply -f - -kubectl wait -n catalogd-e2e --for=condition=Available deployment/docker-registry --timeout=60s - -# Load the testdata onto the cluster as a configmap so it can be used with kaniko -kubectl create configmap -n catalogd-e2e --from-file=catalogd/testdata/catalogs/test-catalog.Dockerfile catalogd-e2e.dockerfile -kubectl create configmap -n catalogd-e2e --from-file=catalogd/testdata/catalogs/test-catalog catalogd-e2e.build-contents - -# Create the kaniko pod to build the test image and push it to the test registry. -kubectl apply -f test/tools/imageregistry/imagebuilder.yaml -kubectl wait --for=condition=Complete -n catalogd-e2e jobs/kaniko --timeout=60s diff --git a/test/upgrade-e2e/post_upgrade_test.go b/test/upgrade-e2e/post_upgrade_test.go index 0f60210c5..6b5d0b39c 100644 --- a/test/upgrade-e2e/post_upgrade_test.go +++ b/test/upgrade-e2e/post_upgrade_test.go @@ -25,8 +25,78 @@ import ( const ( artifactName = "operator-controller-upgrade-e2e" + container = "manager" ) +func TestClusterCatalogUnpacking(t *testing.T) { + ctx := context.Background() + + t.Log("Checking that the controller-manager deployment is updated") + managerLabelSelector := labels.Set{"control-plane": "catalogd-controller-manager"} + var managerDeployment appsv1.Deployment + require.EventuallyWithT(t, func(ct *assert.CollectT) { + var managerDeployments appsv1.DeploymentList + err := c.List(ctx, &managerDeployments, client.MatchingLabels(managerLabelSelector), client.InNamespace("olmv1-system")) + assert.NoError(ct, err) + assert.Len(ct, managerDeployments.Items, 1) + managerDeployment = managerDeployments.Items[0] + assert.Equal(ct, *managerDeployment.Spec.Replicas, managerDeployment.Status.UpdatedReplicas) + assert.Equal(ct, *managerDeployment.Spec.Replicas, managerDeployment.Status.Replicas) + assert.Equal(ct, *managerDeployment.Spec.Replicas, managerDeployment.Status.AvailableReplicas) + assert.Equal(ct, *managerDeployment.Spec.Replicas, managerDeployment.Status.ReadyReplicas) + }, time.Minute, time.Second) + + var managerPod corev1.Pod + t.Log("Waiting for only one controller-manager pod to remain") + require.EventuallyWithT(t, func(ct *assert.CollectT) { + var managerPods corev1.PodList + err := c.List(ctx, &managerPods, client.MatchingLabels(managerLabelSelector)) + assert.NoError(ct, err) + assert.Len(ct, managerPods.Items, 1) + managerPod = managerPods.Items[0] + }, time.Minute, time.Second) + + t.Log("Waiting for acquired leader election") + leaderCtx, leaderCancel := context.WithTimeout(ctx, 3*time.Minute) + defer leaderCancel() + leaderSubstrings := []string{"successfully acquired lease"} + leaderElected, err := watchPodLogsForSubstring(leaderCtx, &managerPod, leaderSubstrings...) + require.NoError(t, err) + require.True(t, leaderElected) + + t.Log("Reading logs to make sure that ClusterCatalog was reconciled by catalogdv1") + logCtx, cancel := context.WithTimeout(ctx, time.Minute) + defer cancel() + substrings := []string{ + "reconcile ending", + fmt.Sprintf(`ClusterCatalog=%q`, testClusterCatalogName), + } + found, err := watchPodLogsForSubstring(logCtx, &managerPod, substrings...) + require.NoError(t, err) + require.True(t, found) + + catalog := &catalogd.ClusterCatalog{} + t.Log("Ensuring ClusterCatalog has Status.Condition of Progressing with a status == True, reason == Succeeded") + require.EventuallyWithT(t, func(ct *assert.CollectT) { + err := c.Get(ctx, types.NamespacedName{Name: testClusterCatalogName}, catalog) + assert.NoError(ct, err) + cond := apimeta.FindStatusCondition(catalog.Status.Conditions, catalogd.TypeProgressing) + assert.NotNil(ct, cond) + assert.Equal(ct, metav1.ConditionTrue, cond.Status) + assert.Equal(ct, catalogd.ReasonSucceeded, cond.Reason) + }, time.Minute, time.Second) + + t.Log("Ensuring ClusterCatalog has Status.Condition of Serving with a status == True, reason == Available") + require.EventuallyWithT(t, func(ct *assert.CollectT) { + err := c.Get(ctx, types.NamespacedName{Name: testClusterCatalogName}, catalog) + assert.NoError(ct, err) + cond := apimeta.FindStatusCondition(catalog.Status.Conditions, catalogd.TypeServing) + assert.NotNil(ct, cond) + assert.Equal(ct, metav1.ConditionTrue, cond.Status) + assert.Equal(ct, catalogd.ReasonAvailable, cond.Reason) + }, time.Minute, time.Second) +} + func TestClusterExtensionAfterOLMUpgrade(t *testing.T) { t.Log("Starting checks after OLM upgrade") ctx := context.Background() @@ -47,7 +117,7 @@ func TestClusterExtensionAfterOLMUpgrade(t *testing.T) { defer leaderCancel() leaderSubstrings := []string{"successfully acquired lease"} - leaderElected, err := watchPodLogsForSubstring(leaderCtx, managerPod, "manager", leaderSubstrings...) + leaderElected, err := watchPodLogsForSubstring(leaderCtx, managerPod, leaderSubstrings...) require.NoError(t, err) require.True(t, leaderElected) @@ -59,7 +129,7 @@ func TestClusterExtensionAfterOLMUpgrade(t *testing.T) { "reconcile ending", fmt.Sprintf(`ClusterExtension=%q`, testClusterExtensionName), } - found, err := watchPodLogsForSubstring(logCtx, managerPod, "manager", substrings...) + found, err := watchPodLogsForSubstring(logCtx, managerPod, substrings...) require.NoError(t, err) require.True(t, found) @@ -153,7 +223,7 @@ func waitForDeployment(t *testing.T, ctx context.Context, controlPlaneLabel stri return &managerPods.Items[0] } -func watchPodLogsForSubstring(ctx context.Context, pod *corev1.Pod, container string, substrings ...string) (bool, error) { +func watchPodLogsForSubstring(ctx context.Context, pod *corev1.Pod, substrings ...string) (bool, error) { podLogOpts := corev1.PodLogOptions{ Follow: true, Container: container,