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


The following commit(s) were added to refs/heads/main by this push:
     new b2ede06b0 fix(e2e): always build bundle and set local config
b2ede06b0 is described below

commit b2ede06b09b1871b9a47e38240eaee4e42a8a795
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Mon Jun 17 11:12:39 2024 +0200

    fix(e2e): always build bundle and set local config
    
    Closes #5632
---
 .github/actions/kamel-build/action.yml        |  4 ----
 e2e/install/helm/setup_test.go                | 10 +++++----
 e2e/install/kustomize/setup_test.go           | 18 ++++++---------
 e2e/install/upgrade/kustomize_upgrade_test.go |  2 +-
 e2e/support/test_util.go                      | 32 ---------------------------
 script/Makefile                               |  4 ++--
 6 files changed, 16 insertions(+), 54 deletions(-)

diff --git a/.github/actions/kamel-build/action.yml 
b/.github/actions/kamel-build/action.yml
index 90d0ecd87..a3f3ff968 100644
--- a/.github/actions/kamel-build/action.yml
+++ b/.github/actions/kamel-build/action.yml
@@ -55,13 +55,9 @@ runs:
         image-namespace: ${{ inputs.image-namespace }}
         make-rules: ${{ inputs.make-rules }}
 
-    #
-    # By default do not build the image bundle
-    #
     - id: build-kamel-bundle
       name: Build Kamel Metadata Bundle
       uses: ./.github/actions/kamel-build-bundle
-      if: ${{ inputs.build-bundle == 'true' }}
       with:
         image-registry-push-host: ${{ inputs.image-registry-push-host }}
         image-registry-pull-host: ${{ inputs.image-registry-pull-host }}
diff --git a/e2e/install/helm/setup_test.go b/e2e/install/helm/setup_test.go
index 62ff7c5fc..e65395b6b 100644
--- a/e2e/install/helm/setup_test.go
+++ b/e2e/install/helm/setup_test.go
@@ -38,11 +38,13 @@ import (
 )
 
 func TestHelmInstallRunUninstall(t *testing.T) {
+       // Ensure no CRDs are already installed
+       ctx := TestContext()
+       Cleanup(t, ctx)
+       KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
+
        WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
-               // Ensure no CRDs are already installed
-               Cleanup(t, ctx)
-               KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
-               CheckLocalInstallRegistry(t, g)
+               g.Expect(KAMEL_INSTALL_REGISTRY).NotTo(Equal(""))
                os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../")
                ExpectExecSucceed(t, g, Make(t, "release-helm"))
                ExpectExecSucceed(t, g,
diff --git a/e2e/install/kustomize/setup_test.go 
b/e2e/install/kustomize/setup_test.go
index 238784508..ceacdb156 100644
--- a/e2e/install/kustomize/setup_test.go
+++ b/e2e/install/kustomize/setup_test.go
@@ -40,18 +40,16 @@ import (
 )
 
 func TestKustomizeNamespaced(t *testing.T) {
-       g := NewWithT(t)
-       CheckLocalInstallRegistry(t, g)
        // TODO, likely we need to adjust this test with a Kustomize overlay 
for Openshift
        // which would not require the registry setting
-       registry := os.Getenv("KIND_REGISTRY")
+       KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
        kustomizeDir := testutil.MakeTempCopyDir(t, "../../../install")
        ctx := TestContext()
-       g.Expect(registry).NotTo(Equal(""))
        // Ensure no CRDs are already installed
        Cleanup(t, ctx)
 
        WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               g.Expect(KAMEL_INSTALL_REGISTRY).NotTo(Equal(""))
                // We must change a few values in the Kustomize config
                ExpectExecSucceed(t, g,
                        exec.Command(
@@ -70,7 +68,7 @@ func TestKustomizeNamespaced(t *testing.T) {
                        exec.Command(
                                "sed",
                                "-i",
-                               fmt.Sprintf("s/address: .*/address: %s/", 
registry),
+                               fmt.Sprintf("s/address: .*/address: %s/", 
KAMEL_INSTALL_REGISTRY),
                                
fmt.Sprintf("%s/overlays/platform/integration-platform.yaml", kustomizeDir),
                        ))
                ExpectExecSucceed(t, g, Kubectl(
@@ -100,7 +98,7 @@ func TestKustomizeNamespaced(t *testing.T) {
                )
                g.Eventually(Platform(t, ctx, ns)).ShouldNot(BeNil())
                g.Eventually(PlatformHas(t, ctx, ns, func(pl 
*v1.IntegrationPlatform) bool {
-                       return pl.Status.Build.Registry.Address == registry
+                       return pl.Status.Build.Registry.Address == 
KAMEL_INSTALL_REGISTRY
                }), TestTimeoutShort).Should(BeTrue())
 
                // Test a simple integration is running
@@ -139,18 +137,16 @@ func TestKustomizeNamespaced(t *testing.T) {
 }
 
 func TestKustomizeDescoped(t *testing.T) {
-       g := NewWithT(t)
-       CheckLocalInstallRegistry(t, g)
        // TODO, likely we need to adjust this test with a Kustomize overlay 
for Openshift
        // which would not require the registry setting
-       registry := os.Getenv("KIND_REGISTRY")
+       KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
        kustomizeDir := testutil.MakeTempCopyDir(t, "../../../install")
        ctx := TestContext()
-       g.Expect(registry).NotTo(Equal(""))
        // Ensure no CRDs are already installed
        Cleanup(t, ctx)
 
        WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               g.Expect(KAMEL_INSTALL_REGISTRY).NotTo(Equal(""))
                // We must change a few values in the Kustomize config
                ExpectExecSucceed(t, g,
                        exec.Command(
@@ -169,7 +165,7 @@ func TestKustomizeDescoped(t *testing.T) {
                        exec.Command(
                                "sed",
                                "-i",
-                               fmt.Sprintf("s/address: .*/address: %s/", 
registry),
+                               fmt.Sprintf("s/address: .*/address: %s/", 
KAMEL_INSTALL_REGISTRY),
                                
fmt.Sprintf("%s/overlays/platform/integration-platform.yaml", kustomizeDir),
                        ))
                ExpectExecSucceed(t, g, Kubectl(
diff --git a/e2e/install/upgrade/kustomize_upgrade_test.go 
b/e2e/install/upgrade/kustomize_upgrade_test.go
index 2e6736ef0..73b4894f3 100644
--- a/e2e/install/upgrade/kustomize_upgrade_test.go
+++ b/e2e/install/upgrade/kustomize_upgrade_test.go
@@ -91,8 +91,8 @@ func TestKustomizeUpgrade(t *testing.T) {
 
                        // Upgrade the operator by installing the current 
version
                        registry := os.Getenv("KIND_REGISTRY")
-                       kustomizeDir := testutil.MakeTempCopyDir(t, 
"../../../install")
                        g.Expect(registry).NotTo(Equal(""))
+                       kustomizeDir := testutil.MakeTempCopyDir(t, 
"../../../install")
                        // We must change a few values in the Kustomize config
                        ExpectExecSucceed(t, g,
                                exec.Command(
diff --git a/e2e/support/test_util.go b/e2e/support/test_util.go
index 8ada6abe3..88bca3ec7 100644
--- a/e2e/support/test_util.go
+++ b/e2e/support/test_util.go
@@ -24,7 +24,6 @@ package support
 
 import (
        "context"
-       "fmt"
        "os"
        "os/exec"
        "strings"
@@ -82,27 +81,6 @@ func ExpectExecSucceed(t *testing.T, g *WithT, command 
*exec.Cmd) {
        assert.NotContains(t, strings.ToUpper(cmdErr.String()), "ERROR")
 }
 
-// ExpectExecError Expect a command error with an exit code of 1
-func ExpectExecError(t *testing.T, g *WithT, command *exec.Cmd) {
-       t.Helper()
-
-       var cmdOut strings.Builder
-       var cmdErr strings.Builder
-
-       defer func() {
-               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())
-               }
-       }()
-
-       session, err := gexec.Start(command, &cmdOut, &cmdErr)
-       session.Wait()
-       g.Eventually(session).ShouldNot(gexec.Exit(0))
-       require.NoError(t, err)
-       assert.Contains(t, strings.ToUpper(cmdErr.String()), "ERROR")
-}
-
 // Cleanup Clean up the cluster ready for the next set of tests
 func Cleanup(t *testing.T, ctx context.Context) {
        // Remove the locally installed operator
@@ -125,13 +103,3 @@ func UninstallAll(t *testing.T, ctx context.Context) error 
{
 func UninstallFromNamespace(t *testing.T, ctx context.Context, ns string) 
error {
        return Kamel(t, ctx, "uninstall", "--olm=false", "-n", ns).Execute()
 }
-
-func CheckLocalInstallRegistry(t *testing.T, g *WithT) {
-       KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
-       if KAMEL_INSTALL_REGISTRY != "" {
-               t.Logf("Detected a local registry for Camel K %s. Setting 
custom image accordingly.", KAMEL_INSTALL_REGISTRY)
-               customImage := fmt.Sprintf("%s/apache/camel-k", 
KAMEL_INSTALL_REGISTRY)
-               os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../")
-               ExpectExecSucceed(t, g, Make(t, fmt.Sprintf("CUSTOM_IMAGE=%s", 
customImage), "set-version"))
-       }
-}
diff --git a/script/Makefile b/script/Makefile
index 6ba3626bc..e144d6afb 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -322,7 +322,7 @@ test-install: do-build
        FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
        go test -timeout 40m -v ./e2e/install/cli -tags=integration 
$(TEST_INSTALL_RUN) $(GOTESTFMT) || ((FAILED++)); \
        go test -timeout 40m -v ./e2e/install/kustomize -tags=integration 
$(TEST_INSTALL_RUN) $(GOTESTFMT) || ((FAILED++)); \
-       go test -timeout 40m -v ./e2e/install/helm -tags=integration 
$(TEST_INSTALL_RUN) $(GOTESTFMT) || ((FAILED++)); \
+       go test -timeout 60m -v ./e2e/install/helm -tags=integration 
$(TEST_INSTALL_RUN) $(GOTESTFMT) || ((FAILED++)); \
        exit $${FAILED}
 
 #
@@ -767,7 +767,7 @@ $(GOIMPORT): $(LOCALBIN)
 #####
 
 KUSTOMIZE_DIR = "install/overlays/kubernetes/descoped"
-MINIKUBE_REGISTRY = "$(shell kubectl -n kube-system get service registry -o 
jsonpath='{.spec.clusterIP}')"
+MINIKUBE_REGISTRY = "$(shell kubectl -n kube-system get service registry -o 
jsonpath='{.spec.clusterIP}' 2> /dev/null)"
 DEFAULT_NS = "camel-k"
 
 .PHONY: install install-k8s-global install-k8s-ns install-openshift-global 
install-openshift-ns

Reply via email to