diff --git a/.github/workflows/catalogd-e2e.yaml b/.github/workflows/catalogd-e2e.yaml index 7f42c2449..323b75522 100644 --- a/.github/workflows/catalogd-e2e.yaml +++ b/.github/workflows/catalogd-e2e.yaml @@ -9,15 +9,6 @@ on: - main jobs: - e2e: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - - name: Run E2e - run: make test-catalogd-e2e upgrade-e2e: runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index ee943a9d5..a40b7c074 100644 --- a/Makefile +++ b/Makefile @@ -221,21 +221,9 @@ image-registry: ## Build the testdata catalog used for e2e tests and push it to test-e2e: KIND_CLUSTER_NAME := operator-controller-e2e test-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/e2e 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 -# Catalogd e2e tests -FOCUS := $(if $(TEST),-v -focus "$(TEST)") -ifeq ($(origin E2E_FLAGS), undefined) -E2E_FLAGS := -endif -test-catalogd-e2e: ## Run the e2e tests on existing cluster - $(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/catalogd-e2e - -catalogd-e2e: KIND_CLUSTER_NAME := catalogd-e2e -catalogd-e2e: ISSUER_KIND := Issuer -catalogd-e2e: ISSUER_NAME := selfsigned-issuer -catalogd-e2e: CATALOGD_KUSTOMIZE_BUILD_DIR := catalogd/config/overlays/e2e -catalogd-e2e: run catalogd-image-registry test-catalogd-e2e ## kind-clean 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. diff --git a/catalogd/config/components/registries-conf/registries_conf_configmap.yaml b/catalogd/config/components/registries-conf/registries_conf_configmap.yaml index 3561bbe59..2604c78f5 100644 --- a/catalogd/config/components/registries-conf/registries_conf_configmap.yaml +++ b/catalogd/config/components/registries-conf/registries_conf_configmap.yaml @@ -6,6 +6,5 @@ metadata: data: registries.conf: | [[registry]] - prefix = "docker-registry.catalogd-e2e.svc:5000" - insecure = true - location = "docker-registry.catalogd-e2e.svc:5000" + prefix = "mirrored-registry.operator-controller-e2e.svc.cluster.local:5000" + location = "docker-registry.operator-controller-e2e.svc.cluster.local:5000" diff --git a/test/catalogd-e2e/e2e_suite_test.go b/test/catalogd-e2e/e2e_suite_test.go deleted file mode 100644 index a2399bd0e..000000000 --- a/test/catalogd-e2e/e2e_suite_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package catalogde2e - -import ( - "fmt" - "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" -) - -var ( - cfg *rest.Config - c client.Client - err error - kubeClient kubernetes.Interface -) - -func TestE2E(t *testing.T) { - _, err := ctrl.GetConfig() - if err != nil { - fmt.Println("Error: Could not get current Kubernetes context. Verify the cluster configuration") - os.Exit(0) - } - RegisterFailHandler(Fail) - SetDefaultEventuallyTimeout(1 * time.Minute) - SetDefaultEventuallyPollingInterval(1 * time.Second) - RunSpecs(t, "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()) -}) diff --git a/test/catalogd-e2e/unpack_test.go b/test/catalogd-e2e/unpack_test.go deleted file mode 100644 index 4c0ad6c01..000000000 --- a/test/catalogd-e2e/unpack_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package catalogde2e - -import ( - "context" - "os" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/google/go-cmp/cmp" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - - catalogdv1 "github.com/operator-framework/operator-controller/catalogd/api/v1" - testutils "github.com/operator-framework/operator-controller/test/utils" -) - -const ( - catalogRefEnvVar = "TEST_CATALOG_IMAGE" - catalogName = "test-catalog" -) - -// catalogImageRef returns the image reference for the test catalog image, defaulting to the value of the environment -// variable TEST_CATALOG_IMAGE if set, falling back to docker-registry.catalogd-e2e.svc:5000/test-catalog:e2e otherwise. -func catalogImageRef() string { - if s := os.Getenv(catalogRefEnvVar); s != "" { - return s - } - - return "docker-registry.catalogd-e2e.svc:5000/test-catalog:e2e" -} - -var _ = Describe("ClusterCatalog Unpacking", func() { - var ( - ctx context.Context - catalog *catalogdv1.ClusterCatalog - ) - When("A ClusterCatalog is created", func() { - BeforeEach(func() { - ctx = context.Background() - var err error - - catalog = &catalogdv1.ClusterCatalog{ - ObjectMeta: metav1.ObjectMeta{ - Name: catalogName, - }, - Spec: catalogdv1.ClusterCatalogSpec{ - Source: catalogdv1.CatalogSource{ - Type: catalogdv1.SourceTypeImage, - Image: &catalogdv1.ImageSource{ - Ref: catalogImageRef(), - }, - }, - }, - } - - err = c.Create(ctx, catalog) - Expect(err).ToNot(HaveOccurred()) - }) - - It("Successfully unpacks catalog contents", func() { - By("Ensuring ClusterCatalog has Status.Condition of Progressing with a status == False and reason == Succeeded") - Eventually(func(g Gomega) { - err := c.Get(ctx, types.NamespacedName{Name: catalog.Name}, 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()) - - By("Checking that it has an appropriate name label") - Expect(catalog.ObjectMeta.Labels).To(Not(BeNil())) - Expect(catalog.ObjectMeta.Labels).To(Not(BeEmpty())) - Expect(catalog.ObjectMeta.Labels).To(HaveKeyWithValue("olm.operatorframework.io/metadata.name", catalogName)) - - By("Making sure the catalog content is available via the http server") - actualFBC, err := testutils.ReadTestCatalogServerContents(ctx, catalog, kubeClient) - Expect(err).To(Not(HaveOccurred())) - - expectedFBC, err := os.ReadFile("../../catalogd/testdata/catalogs/test-catalog/expected_all.json") - Expect(err).To(Not(HaveOccurred())) - Expect(cmp.Diff(expectedFBC, actualFBC)).To(BeEmpty()) - - By("Ensuring ClusterCatalog has Status.Condition of Type = Serving with a status == True") - Eventually(func(g Gomega) { - err := c.Get(ctx, types.NamespacedName{Name: catalog.Name}, 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()) - }) - AfterEach(func() { - Expect(c.Delete(ctx, catalog)).To(Succeed()) - Eventually(func(g Gomega) { - err = c.Get(ctx, types.NamespacedName{Name: catalog.Name}, &catalogdv1.ClusterCatalog{}) - g.Expect(errors.IsNotFound(err)).To(BeTrue()) - }).Should(Succeed()) - }) - }) -}) diff --git a/test/e2e/cluster_extension_install_test.go b/test/e2e/cluster_extension_install_test.go index 4c05df8b4..8ccca8b5e 100644 --- a/test/e2e/cluster_extension_install_test.go +++ b/test/e2e/cluster_extension_install_test.go @@ -210,9 +210,40 @@ func testInit(t *testing.T) (*ocv1.ClusterExtension, *catalogd.ClusterCatalog, * sa, err := createServiceAccount(context.Background(), name, clusterExtensionName) require.NoError(t, err) + + validateCatalogUnpack(t) + return clusterExtension, extensionCatalog, sa, ns } +func validateCatalogUnpack(t *testing.T) { + catalog := &catalogd.ClusterCatalog{} + t.Log("Ensuring ClusterCatalog has Status.Condition of Progressing with a status == True and reason == Succeeded") + require.EventuallyWithT(t, func(ct *assert.CollectT) { + err := c.Get(context.Background(), types.NamespacedName{Name: testCatalogName}, 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) + }, pollDuration, pollInterval) + + t.Log("Checking that catalog has the expected metadata label") + assert.NotNil(t, catalog.ObjectMeta.Labels) + assert.Contains(t, catalog.ObjectMeta.Labels, "olm.operatorframework.io/metadata.name") + assert.Equal(t, testCatalogName, catalog.ObjectMeta.Labels["olm.operatorframework.io/metadata.name"]) + + t.Log("Ensuring ClusterCatalog has Status.Condition of Type = Serving with status == True") + require.EventuallyWithT(t, func(ct *assert.CollectT) { + err := c.Get(context.Background(), types.NamespacedName{Name: testCatalogName}, 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) + }, pollDuration, pollInterval) +} + func ensureNoExtensionResources(t *testing.T, clusterExtensionName string) { ls := labels.Set{"olm.operatorframework.io/owner-name": clusterExtensionName}