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 20299a877a7a2edf587840f6e8ca4115784d2d1a
Author: phantomjinx <[email protected]>
AuthorDate: Thu Mar 3 21:28:37 2022 +0000

    fix(e2e): fixes for upgrade testing on OCP
    
    * replaces attribute required in olm.channel syntax to ensure OLM knows
      to upgrade from the last release to the current.
    
    * incorrect regex for localhost replacement
    
    * Fixes integration stalling at "Building Kit" phase due to circular
      attempts to assign the rebuilt integrationkit
---
 .github/actions/kamel-build-bundle/build-index-image.sh |  3 ++-
 e2e/upgrade/cli_upgrade_test.go                         |  1 -
 e2e/upgrade/olm_upgrade_test.go                         |  1 +
 pkg/apis/camel/v1/integration_types_support.go          |  5 +++++
 pkg/controller/integration/build_kit.go                 | 10 +++++++++-
 pkg/trait/trait.go                                      |  4 ++++
 6 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/.github/actions/kamel-build-bundle/build-index-image.sh 
b/.github/actions/kamel-build-bundle/build-index-image.sh
index 9cd3faf64..1fdd22f95 100755
--- a/.github/actions/kamel-build-bundle/build-index-image.sh
+++ b/.github/actions/kamel-build-bundle/build-index-image.sh
@@ -131,7 +131,7 @@ if [ "${PULL_REGISTRY}" != "${PUSH_REGISTRY}" ]; then
   #
   # Only add PULL_HOST if not already added (avoids repeated appended)
   #
-  sudo sed -i "/${PULL_HOST}/!s/localhost /&${PULL_HOST} /" /etc/hosts
+  sudo sed -i "/${PULL_HOST}/!s/localhost/& ${PULL_HOST} /" /etc/hosts
 
   #
   # Bring up the registry:2 instance if not already started
@@ -186,6 +186,7 @@ package: camel-k
 name: stable-$(make get-version | grep -Po "\d.\d")
 entries:
   - name: camel-k.v$(make get-version | grep -Po "\d.\d.\d")
+    replaces: $(make get-last-released-img-name).v$(make 
get-last-released-version | grep -Po "\d.\d.\d")
 EOF
 opm validate ${CATALOG_DIR}
 opm generate dockerfile ${CATALOG_DIR}
diff --git a/e2e/upgrade/cli_upgrade_test.go b/e2e/upgrade/cli_upgrade_test.go
index f8f3eeee6..b60dca606 100644
--- a/e2e/upgrade/cli_upgrade_test.go
+++ b/e2e/upgrade/cli_upgrade_test.go
@@ -75,7 +75,6 @@ func TestOperatorUpgrade(t *testing.T) {
                Expect(os.Setenv("KAMEL_BIN", "")).To(Succeed())
 
                // Upgrade the operator by installing the current version
-               Expect(Kamel("install", "--olm=false", "--cluster-setup", 
"--force").Execute()).To(Succeed())
                Expect(Kamel("install", "-n", ns, "--olm=false", "--force", 
"--operator-image", image).Execute()).To(Succeed())
 
                // Check the operator image is the current built one
diff --git a/e2e/upgrade/olm_upgrade_test.go b/e2e/upgrade/olm_upgrade_test.go
index fe0d25fe1..5a05a7008 100644
--- a/e2e/upgrade/olm_upgrade_test.go
+++ b/e2e/upgrade/olm_upgrade_test.go
@@ -28,6 +28,7 @@ import (
        "testing"
        "time"
 
+       . "github.com/apache/camel-k/e2e/support"
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
diff --git a/pkg/apis/camel/v1/integration_types_support.go 
b/pkg/apis/camel/v1/integration_types_support.go
index a35520be7..360c1df48 100644
--- a/pkg/apis/camel/v1/integration_types_support.go
+++ b/pkg/apis/camel/v1/integration_types_support.go
@@ -267,6 +267,11 @@ func (in *Integration) SetIntegrationPlatform(platform 
*IntegrationPlatform) {
 }
 
 func (in *Integration) SetIntegrationKit(kit *IntegrationKit) {
+       if kit == nil {
+               in.Status.IntegrationKit = nil
+               return
+       }
+
        cs := corev1.ConditionTrue
        message := kit.Name
        if kit.Status.Phase != IntegrationKitPhaseReady {
diff --git a/pkg/controller/integration/build_kit.go 
b/pkg/controller/integration/build_kit.go
index 0feddc951..3acd1e0a6 100644
--- a/pkg/controller/integration/build_kit.go
+++ b/pkg/controller/integration/build_kit.go
@@ -59,7 +59,12 @@ func (action *buildKitAction) Handle(ctx context.Context, 
integration *v1.Integr
                return integration, nil
        }
 
+       //
+       // IntegrationKit may be nil if its being upgraded
+       //
        if integration.Status.IntegrationKit != nil {
+
+               // IntegrationKit fully defined so find it
                kit, err := kubernetes.GetIntegrationKit(ctx, action.client, 
integration.Status.IntegrationKit.Name, 
integration.Status.IntegrationKit.Namespace)
                if err != nil {
                        return nil, errors.Wrapf(err, "unable to find 
integration kit %s/%s, %s", integration.Status.IntegrationKit.Namespace, 
integration.Status.IntegrationKit.Name, err)
@@ -73,7 +78,10 @@ func (action *buildKitAction) Handle(ctx context.Context, 
integration *v1.Integr
                                // We need to re-generate a kit, or search for 
a new one that
                                // matches the integration, so let's remove the 
association
                                // with the kit.
-                               
integration.SetIntegrationKit(&v1.IntegrationKit{})
+                               //
+                               // All tests & conditionals check for a nil 
assignment
+                               //
+                               integration.SetIntegrationKit(nil)
                                return integration, nil
                        }
                }
diff --git a/pkg/trait/trait.go b/pkg/trait/trait.go
index e0a308e9a..ca5fa5050 100644
--- a/pkg/trait/trait.go
+++ b/pkg/trait/trait.go
@@ -84,6 +84,10 @@ func newEnvironment(ctx context.Context, c client.Client, 
integration *v1.Integr
                }
        }
 
+       //
+       // kit can still be nil if integration kit is yet
+       // to finish building and be assigned to the integration
+       //
        env := Environment{
                Ctx:                   ctx,
                Platform:              pl,

Reply via email to