This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit db7148ca467d2988a98bd10810cf20bd43414744
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Wed Aug 7 14:10:40 2024 +0200

    chore(ci): use operator-sdk to test OLM
---
 .github/actions/release-nightly/action.yml |  2 +-
 .github/workflows/common.yml               |  4 ++--
 .github/workflows/install.yml              | 11 ++++++++---
 e2e/install/kustomize/setup_test.go        |  6 ++++++
 e2e/install/olm/olm_install_test.go        | 25 +++++++++++++++++-------
 e2e/install/upgrade/upgrade_test.go        | 31 ++++++++++++++++++------------
 e2e/support/test_support.go                | 11 -----------
 e2e/support/test_util.go                   |  6 ++++--
 8 files changed, 58 insertions(+), 38 deletions(-)

diff --git a/.github/actions/release-nightly/action.yml 
b/.github/actions/release-nightly/action.yml
index 49c8ff055..11faae62c 100644
--- a/.github/actions/release-nightly/action.yml
+++ b/.github/actions/release-nightly/action.yml
@@ -96,7 +96,7 @@ runs:
     - name: Set up QEMU (required by multi platform build)
       uses: docker/setup-qemu-action@v3
 
-    - name: Login to Container Registry
+    - name: Login to staging container registry
       uses: docker/login-action@v3
       with:
         username: ${{ inputs.secretDockerHubUser }}
diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml
index 2b576b15e..1f3e9130a 100644
--- a/.github/workflows/common.yml
+++ b/.github/workflows/common.yml
@@ -58,7 +58,7 @@ concurrency:
   cancel-in-progress: true
 
 jobs:
-  common-it:
+  common:
     runs-on: ubuntu-latest
     steps:
     - name: Checkout code
@@ -82,7 +82,7 @@ jobs:
       run: |
         DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make 
test-common
 
-  advanced-it:
+  advanced:
     runs-on: ubuntu-latest
     steps:
     - name: Checkout code
diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml
index 088ecb69e..caaa94111 100644
--- a/.github/workflows/install.yml
+++ b/.github/workflows/install.yml
@@ -90,13 +90,18 @@ jobs:
           kubectl create -f 
https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/olm.yaml
           kubectl wait --for=jsonpath='{.status.phase}'=Succeeded csv 
packageserver -n olm --timeout=2m
 
+    - name: Login to staging container registry
+      uses: docker/login-action@v3
+      with:
+        username: ${{ secrets.TEST_DOCKER_HUB_USERNAME }}
+        password: ${{ secrets.TEST_DOCKER_HUB_PASSWORD }}
+
     - name: Build and push OLM bundle
       shell: bash
       run: |
-        echo "BUNDLE_IMAGE_NAME=docker.io/squakez/camel-k-bundle" >> 
$GITHUB_ENV
+        echo "BUNDLE_IMAGE_NAME=docker.io/testcamelk/camel-k-bundle" >> 
$GITHUB_ENV
         echo "Setting bundle image name as as $BUNDLE_IMAGE_NAME which is 
required by OLM tests"
-        # TODO publish in a staging environment accordingly
-        # BUNDLE_IMAGE_NAME=docker.io/squakez/camel-k-bundle make bundle-push
+        BUNDLE_IMAGE_NAME=docker.io/testcamelk/camel-k-bundle make bundle-push
 
     - name: Run tests
       shell: bash
diff --git a/e2e/install/kustomize/setup_test.go 
b/e2e/install/kustomize/setup_test.go
index f6a6d197b..926ab1d68 100644
--- a/e2e/install/kustomize/setup_test.go
+++ b/e2e/install/kustomize/setup_test.go
@@ -43,6 +43,9 @@ func TestKustomizeNamespaced(t *testing.T) {
        KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
        kustomizeDir := testutil.MakeTempCopyDir(t, "../../../install")
        WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               // Let's make sure no CRD is yet available in the cluster
+               // as we must make the procedure to install them accordingly
+               g.Eventually(CRDs(t)).Should(BeNil(), "No Camel K CRDs should 
be previously installed for this test")
                g.Expect(KAMEL_INSTALL_REGISTRY).NotTo(Equal(""))
                // We must change a few values in the Kustomize config
                ExpectExecSucceed(t, g,
@@ -123,6 +126,9 @@ func TestKustomizeDescoped(t *testing.T) {
        KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
        kustomizeDir := testutil.MakeTempCopyDir(t, "../../../install")
        WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               // Let's make sure no CRD is yet available in the cluster
+               // as we must make the procedure to install them accordingly
+               g.Eventually(CRDs(t)).Should(BeNil(), "No Camel K CRDs should 
be previously installed for this test")
                g.Expect(KAMEL_INSTALL_REGISTRY).NotTo(Equal(""))
                // We must change a few values in the Kustomize config
                ExpectExecSucceed(t, g,
diff --git a/e2e/install/olm/olm_install_test.go 
b/e2e/install/olm/olm_install_test.go
index bf4834e51..31d7f322d 100644
--- a/e2e/install/olm/olm_install_test.go
+++ b/e2e/install/olm/olm_install_test.go
@@ -27,6 +27,7 @@ import (
        "fmt"
        "os"
        "testing"
+       "time"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        . "github.com/onsi/gomega"
@@ -44,10 +45,13 @@ const installCatalogSourceName = "test-camel-k-source"
 
 func TestOLMInstallation(t *testing.T) {
        WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               // Let's make sure no CRD is yet available in the cluster
+               // as we must make the procedure to install them accordingly
+               g.Eventually(CRDs(t)).Should(BeNil(), "No Camel K CRDs should 
be previously installed for this test")
                bundleImageName, ok := os.LookupEnv("BUNDLE_IMAGE_NAME")
-               g.Expect(ok).To(BeTrue())
+               g.Expect(ok).To(BeTrue(), "Missing bundle image: you need to 
build and push to a container registry and set BUNDLE_IMAGE_NAME env var")
                containerRegistry, ok := os.LookupEnv("KAMEL_INSTALL_REGISTRY")
-               g.Expect(ok).To(BeTrue())
+               g.Expect(ok).To(BeTrue(), "Missing local container registry: 
you need to set it into KAMEL_INSTALL_REGISTRY env var")
                os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../")
                // Install staged bundle (it must be available by building it 
before running the test)
                // You can build it locally via `make bundle-push` action
@@ -69,9 +73,12 @@ func TestOLMInstallation(t *testing.T) {
                g.Eventually(OperatorPodPhase(t, ctx, ns), 
TestTimeoutMedium).Should(Equal(corev1.PodRunning))
                g.Eventually(OperatorImage(t, ctx, ns), 
TestTimeoutShort).Should(Equal(defaults.OperatorImage()))
 
+               // This is required in order to wait the availability of 
IntegrationPlatform CRDs
+               g.Eventually(CRDs(t)).Should(HaveLen(ExpectedCRDs))
                // Check the IntegrationPlatform has been reconciled after 
setting the expected container registry
                g.Expect(UpdatePlatform(t, ctx, ns, func(ip 
*v1.IntegrationPlatform) {
                        ip.Spec.Build.Registry.Address = containerRegistry
+                       ip.Spec.Build.Registry.Insecure = true
                })).To(Succeed())
                g.Eventually(PlatformPhase(t, ctx, ns), 
TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
                g.Eventually(PlatformVersion(t, ctx, ns), 
TestTimeoutMedium).Should(Equal(defaults.Version))
@@ -89,10 +96,14 @@ func TestOLMInstallation(t *testing.T) {
                g.Eventually(IntegrationConditionStatus(t, ctx, ns, "yaml", 
v1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
                g.Eventually(IntegrationLogs(t, ctx, ns, "yaml"), 
TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
 
-               // TODO Remove OLM CSV and test
-               // g.Eventually(OperatorPod(t, ctx, ns)).Should(BeNil())
-               // g.Eventually(Platform(t, ctx, ns)).Should(BeNil())
-               // g.Eventually(Integration(t, ctx, ns, "yaml"), 
TestTimeoutShort).ShouldNot(BeNil())
-               // g.Eventually(IntegrationConditionStatus(t, ctx, ns, "yaml", 
v1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+               // Remove OLM CSV and test Integration is still existing
+               csv := ClusterServiceVersion(t, ctx, noAdditionalConditions, 
ns)()
+               g.Expect(TestClient(t).Delete(ctx, csv)).To(Succeed())
+               g.Eventually(OperatorPod(t, ctx, ns)).Should(BeNil())
+
+               g.Consistently(Integration(t, ctx, ns, "yaml"), 15*time.Second, 
5*time.Second).ShouldNot(BeNil())
+               g.Consistently(
+                       IntegrationConditionStatus(t, ctx, ns, "yaml", 
v1.IntegrationConditionReady), 15*time.Second, 5*time.Second).
+                       Should(Equal(corev1.ConditionTrue))
        })
 }
diff --git a/e2e/install/upgrade/upgrade_test.go 
b/e2e/install/upgrade/upgrade_test.go
index b699a2579..28d6ad76c 100644
--- a/e2e/install/upgrade/upgrade_test.go
+++ b/e2e/install/upgrade/upgrade_test.go
@@ -41,9 +41,12 @@ import (
 
 func TestUpgrade(t *testing.T) {
        WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               // Let's make sure no CRD is yet available in the cluster
+               // as we must make the procedure to install them accordingly
+               g.Eventually(CRDs(t)).Should(BeNil(), "No Camel K CRDs should 
be previously installed for this test")
                // We start the test by installing previous version operator
                lastVersion, ok := os.LookupEnv("LAST_RELEASED_VERSION")
-               g.Expect(ok).To(BeTrue())
+               g.Expect(ok).To(BeTrue(), "Missing last released version: you 
need to set it into LAST_RELEASED_VERSION env var")
                lastVersionDir := fmt.Sprintf("/tmp/camel-k-v-%s", lastVersion)
                // We clone and install the previous installed operator
                // from source with tag
@@ -88,19 +91,20 @@ func TestUpgrade(t *testing.T) {
                        // Run the Integration
                        name := RandomizedSuffixName("yaml")
                        g.Expect(Kamel(t, ctx, "run", "-n", nsIntegration, 
"--name", name, "files/yaml.yaml").Execute()).To(Succeed())
-                       g.Eventually(IntegrationPodPhase(t, ctx, nsIntegration, 
name)).Should(Equal(corev1.PodRunning))
-                       g.Eventually(IntegrationConditionStatus(t, ctx, 
nsIntegration, name, 
v1.IntegrationConditionReady)).Should(Equal(corev1.ConditionTrue))
+                       g.Eventually(IntegrationPodPhase(t, ctx, nsIntegration, 
name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+                       g.Eventually(IntegrationConditionStatus(t, ctx, 
nsIntegration, name, v1.IntegrationConditionReady)).
+                               Should(Equal(corev1.ConditionTrue))
                        // Check the Integration version
                        g.Eventually(IntegrationVersion(t, ctx, nsIntegration, 
name)).Should(Equal(lastVersion))
 
                        // Let's upgrade the operator with the newer 
installation
-                       ExpectExecSucceed(t, g,
-                               exec.Command(
-                                       "make",
-                                       "install-k8s-global",
-                                       fmt.Sprintf("NAMESPACE=%s", ns),
-                               ),
+                       installNextCmd := exec.Command(
+                               "make",
+                               "install-k8s-global",
+                               fmt.Sprintf("NAMESPACE=%s", ns),
                        )
+                       installNextCmd.Dir = "../../.."
+                       ExpectExecSucceed(t, g, installNextCmd)
 
                        // Check the operator image is the current built one
                        g.Eventually(OperatorImage(t, ctx, 
ns)).Should(ContainSubstring(defaults.Version))
@@ -111,7 +115,8 @@ func TestUpgrade(t *testing.T) {
                        g.Eventually(PlatformVersion(t, ctx, ns), 
TestTimeoutMedium).Should(Equal(defaults.Version))
 
                        // Check the Integration hasn't been upgraded
-                       g.Consistently(IntegrationVersion(t, ctx, 
nsIntegration, name), 15*time.Second, 3*time.Second).Should(Equal(lastVersion))
+                       g.Consistently(IntegrationVersion(t, ctx, 
nsIntegration, name), 15*time.Second, 3*time.Second).
+                               Should(Equal(lastVersion))
                        // Make sure that any Pod rollout is completing 
successfully
                        // otherwise we are probably in front of a non breaking 
compatibility change
                        g.Consistently(IntegrationConditionStatus(t, ctx, 
nsIntegration, name, v1.IntegrationConditionReady),
@@ -141,8 +146,10 @@ func TestUpgrade(t *testing.T) {
                        g.Eventually(IntegrationPodImage(t, ctx, nsIntegration, 
name)).Should(Equal(kit.Status.Image))
 
                        // Check the Integration runs correctly
-                       g.Eventually(IntegrationPodPhase(t, ctx, nsIntegration, 
name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-                       g.Eventually(IntegrationConditionStatus(t, ctx, 
nsIntegration, name, v1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+                       g.Eventually(IntegrationPodPhase(t, ctx, nsIntegration, 
name), TestTimeoutMedium).
+                               Should(Equal(corev1.PodRunning))
+                       g.Eventually(IntegrationConditionStatus(t, ctx, 
nsIntegration, name, v1.IntegrationConditionReady)).
+                               Should(Equal(corev1.ConditionTrue))
                })
                // TODO: we should verify new CRDs installed are the same as 
the one defined in the source core here
        })
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index f8f8a659a..2341911ed 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -2210,17 +2210,6 @@ func AssignPlatformToOperator(t *testing.T, ctx 
context.Context, ns, operator st
        return TestClient(t).Update(ctx, pl)
 }
 
-func GetExpectedCRDs(releaseVersion string) int {
-       switch releaseVersion {
-       case "2.2.0":
-               return 8
-       case defaults.Version:
-               return ExpectedCRDs
-       }
-
-       return ExpectedCRDs
-}
-
 func CRDs(t *testing.T) func() []metav1.APIResource {
        return func() []metav1.APIResource {
 
diff --git a/e2e/support/test_util.go b/e2e/support/test_util.go
index c95f5d1fd..aecc1e709 100644
--- a/e2e/support/test_util.go
+++ b/e2e/support/test_util.go
@@ -142,9 +142,11 @@ func ExpectExecSucceedWithTimeout(t *testing.T, g *WithT, 
command *exec.Cmd, tim
        var cmdErr strings.Builder
 
        defer func() {
+               t.Logf(`Executing "%s" ...
+`, command)
+               t.Logf("[OUT] %s\n", cmdOut.String())
                if t.Failed() {
-                       t.Logf("Output from exec command:\n%s\n", 
cmdOut.String())
-                       t.Logf("Error from exec command:\n%s\n", 
cmdErr.String())
+                       t.Logf("[ERR] %s\n", cmdErr.String())
                }
        }()
 

Reply via email to