You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/12/07 07:19:46 UTC

(camel-k) branch release-2.0.x updated (32c18beaf -> 262eacc7d)

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

pcongiusti pushed a change to branch release-2.0.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git


    from 32c18beaf chore: nightly SBOM update
     new fae38f81f fix(e2e): Upgrade helm procedure test
     new fa0dd4c1a fix(doc): Handle CRDs in helm upgrade/delete
     new 556fe5450 chore(e2e): Refactor resources number const
     new 262eacc7d fix(e2e): Execute helm upgrade test only on main branch

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 e2e/install/kustomize/common.go          | 117 -----------------------
 e2e/install/upgrade/helm_upgrade_test.go | 157 +++++++++++++++++++++++++++++++
 e2e/support/test_support.go              |  24 +++++
 e2e/support/test_util.go                 |  60 ++++++++++++
 helm/camel-k/README.md                   |  27 +++++-
 5 files changed, 266 insertions(+), 119 deletions(-)
 delete mode 100644 e2e/install/kustomize/common.go
 create mode 100644 e2e/install/upgrade/helm_upgrade_test.go


(camel-k) 01/04: fix(e2e): Upgrade helm procedure test

Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fae38f81f714b2f740928a92510c00b8513966fc
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Tue Dec 5 16:55:03 2023 +0100

    fix(e2e): Upgrade helm procedure test
---
 e2e/install/upgrade/helm_upgrade_test.go | 148 +++++++++++++++++++++++++++++++
 e2e/support/test_util.go                 |  60 +++++++++++++
 2 files changed, 208 insertions(+)

diff --git a/e2e/install/upgrade/helm_upgrade_test.go b/e2e/install/upgrade/helm_upgrade_test.go
new file mode 100644
index 000000000..768da149c
--- /dev/null
+++ b/e2e/install/upgrade/helm_upgrade_test.go
@@ -0,0 +1,148 @@
+//go:build integration
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+   http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package upgrade
+
+import (
+	"fmt"
+	"os"
+	"os/exec"
+	"testing"
+
+	. "github.com/apache/camel-k/v2/e2e/support"
+	"github.com/apache/camel-k/v2/pkg/util/defaults"
+	. "github.com/onsi/gomega"
+	corev1 "k8s.io/api/core/v1"
+)
+
+// WARNING: this test is not OLM specific but needs certain setting we provide in OLM installation scenario
+func TestHelmOperatorUpgrade(t *testing.T) {
+	RegisterTestingT(t)
+
+	KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
+	// need to add last release version
+	releaseVersion := os.Getenv("KAMEL_K_TEST_RELEASE_VERSION")
+	customImage := fmt.Sprintf("%s/apache/camel-k", KAMEL_INSTALL_REGISTRY)
+
+	os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../")
+
+	// Ensure no CRDs are already installed
+	UninstallAll()
+	Eventually(CRDs()).Should(HaveLen(0))
+
+	WithNewTestNamespace(t, func(ns string) {
+
+		// Install operator in last released version
+		ExpectExecSucceed(t,
+			exec.Command(
+				"helm",
+				"install",
+				"camel-k",
+				fmt.Sprintf("../../../docs/charts/camel-k-%s.tgz", releaseVersion),
+				"--set",
+				fmt.Sprintf("platform.build.registry.address=%s", KAMEL_INSTALL_REGISTRY),
+				"--set",
+				"platform.build.registry.insecure=true",
+				"-n",
+				ns,
+			),
+		)
+
+		Eventually(OperatorPod(ns)).ShouldNot(BeNil())
+		Eventually(OperatorImage(ns)).Should(ContainSubstring(releaseVersion))
+		Eventually(CRDs()).Should(HaveLen(8))
+
+		//Test a simple route
+		t.Run("simple route", func(t *testing.T) {
+			name := "simpleyaml"
+			Expect(KamelRun(ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
+			Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+		})
+
+		// Upgrade CRDs with kustomize
+		ExpectExecSucceed(t,
+			exec.Command(
+				"kubectl",
+				"replace",
+				"-f",
+				"../../../helm/camel-k/crds/",
+				"-n",
+				ns,
+			),
+		)
+
+		// Upgrade operator to current version
+		ExpectExecSucceed(t, Make(fmt.Sprintf("CUSTOM_IMAGE=%s", customImage), "set-version"))
+		ExpectExecSucceed(t, Make("release-helm"))
+		ExpectExecSucceed(t,
+			exec.Command(
+				"helm",
+				"upgrade",
+				"camel-k",
+				fmt.Sprintf("../../../docs/charts/camel-k-%s.tgz", defaults.Version),
+				"--set",
+				fmt.Sprintf("platform.build.registry.address=%s", KAMEL_INSTALL_REGISTRY),
+				"--set",
+				"platform.build.registry.insecure=true",
+				"-n",
+				ns,
+				"--force",
+			),
+		)
+
+		Eventually(OperatorPod(ns)).ShouldNot(BeNil())
+		Eventually(OperatorImage(ns)).Should(ContainSubstring(defaults.Version))
+
+		//Test again a simple route
+		t.Run("simple route upgraded", func(t *testing.T) {
+			name := "upgradedyaml"
+			Expect(KamelRun(ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
+			Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+		})
+
+		// Uninstall with helm
+		ExpectExecSucceed(t,
+			exec.Command(
+				"helm",
+				"uninstall",
+				"camel-k",
+				"-n",
+				ns,
+			),
+		)
+		Eventually(OperatorPod(ns)).Should(BeNil())
+
+		//  helm does not remove the CRDs
+		Eventually(CRDs()).Should(HaveLen(8))
+		ExpectExecSucceed(t,
+			exec.Command(
+				"kubectl",
+				"delete",
+				"-k",
+				"../../../config/crd/",
+				"-n",
+				ns,
+			),
+		)
+		Eventually(CRDs()).Should(HaveLen(0))
+	})
+}
diff --git a/e2e/support/test_util.go b/e2e/support/test_util.go
index b85e93060..61fbc3f2f 100644
--- a/e2e/support/test_util.go
+++ b/e2e/support/test_util.go
@@ -24,10 +24,15 @@ package support
 
 import (
 	"os"
+	"os/exec"
+	"strings"
+	"testing"
 
 	. "github.com/onsi/gomega"
+	"github.com/onsi/gomega/gexec"
 	. "github.com/onsi/gomega/gstruct"
 	"github.com/onsi/gomega/types"
+	"github.com/stretchr/testify/assert"
 )
 
 func init() {
@@ -50,3 +55,58 @@ func GetEnvOrDefault(key string, deflt string) string {
 		return deflt
 	}
 }
+
+func ExpectExecSucceed(t *testing.T, 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()
+	Eventually(session).Should(gexec.Exit(0))
+	assert.NoError(t, err)
+	assert.NotContains(t, strings.ToUpper(cmdErr.String()), "ERROR")
+}
+
+// Expect a command error with an exit code of 1
+func ExpectExecError(t *testing.T, 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()
+	Eventually(session).ShouldNot(gexec.Exit(0))
+	assert.NoError(t, err)
+	assert.Contains(t, strings.ToUpper(cmdErr.String()), "ERROR")
+}
+
+// Clean up the cluster ready for the next set of tests
+func Cleanup() {
+	// Remove the locally installed operator
+	UninstallAll()
+
+	// Ensure the CRDs & ClusterRoles are reinstalled if not already
+	Kamel("install", "--olm=false", "--cluster-setup").Execute()
+}
+
+// Removes all items
+func UninstallAll() {
+	Kamel("uninstall", "--olm=false", "--all").Execute()
+}


(camel-k) 04/04: fix(e2e): Execute helm upgrade test only on main branch

Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 262eacc7d21da86cf4fd4b4dd7e5a6af91372363
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Tue Dec 5 16:57:36 2023 +0100

    fix(e2e): Execute helm upgrade test only on main branch
---
 e2e/install/upgrade/helm_upgrade_test.go | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/e2e/install/upgrade/helm_upgrade_test.go b/e2e/install/upgrade/helm_upgrade_test.go
index f966acb42..7f7d98f39 100644
--- a/e2e/install/upgrade/helm_upgrade_test.go
+++ b/e2e/install/upgrade/helm_upgrade_test.go
@@ -21,6 +21,7 @@ limitations under the License.
 package upgrade
 
 import (
+	"errors"
 	"fmt"
 	"os"
 	"os/exec"
@@ -39,6 +40,14 @@ func TestHelmOperatorUpgrade(t *testing.T) {
 	KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
 	// need to add last release version
 	releaseVersion := os.Getenv("KAMEL_K_TEST_RELEASE_VERSION")
+
+	// if the last released version chart is not present skip the test
+	releaseChart := fmt.Sprintf("../../../docs/charts/camel-k-%s.tgz", releaseVersion)
+	if _, err := os.Stat(releaseChart); errors.Is(err, os.ErrNotExist) {
+		t.Skip("last release version chart not found: skipping")
+		return
+	}
+
 	customImage := fmt.Sprintf("%s/apache/camel-k", KAMEL_INSTALL_REGISTRY)
 
 	os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../")
@@ -55,7 +64,7 @@ func TestHelmOperatorUpgrade(t *testing.T) {
 				"helm",
 				"install",
 				"camel-k",
-				fmt.Sprintf("../../../docs/charts/camel-k-%s.tgz", releaseVersion),
+				releaseChart,
 				"--set",
 				fmt.Sprintf("platform.build.registry.address=%s", KAMEL_INSTALL_REGISTRY),
 				"--set",


(camel-k) 02/04: fix(doc): Handle CRDs in helm upgrade/delete

Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fa0dd4c1aa2cb1918e5378cbc00f88372e700e6c
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Fri Nov 24 11:24:14 2023 +0100

    fix(doc): Handle CRDs in helm upgrade/delete
---
 helm/camel-k/README.md | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/helm/camel-k/README.md b/helm/camel-k/README.md
index 64807c12f..838d78a8e 100644
--- a/helm/camel-k/README.md
+++ b/helm/camel-k/README.md
@@ -56,15 +56,38 @@ additional parameters that can be set during installation.
 
 > **Tip**: List all releases using `helm list`
 
+## Upgrading the Chart
+
+If you are upgrading the `camel-k` Deployment, you should always use a specific version of the chart and pre-install the CRDS:
+
+```bash
+# Upgrade the CRDs
+$ curl -LO "https://github.com/apache/camel-k/raw/main/docs/charts/camel-k-x.y.z.tgz"
+$ tar xvzf camel-k-x.y.z.tgz
+$ kubectl replace -f camel-k/crds
+# Upgrade the `camel-k` Deployment
+$ helm upgrade camel-k/camel-k --version x.y.z
+```
+
+> **Note**: If you are using a custom ClusterRole instead of the default one `camel-k:edit` from `camel-k/crds/cluster-role.yaml` you should handle it appropriately.
+
+
 ## Uninstalling the Chart
 
 To uninstall/delete the `camel-k` Deployment:
 
 ```bash
-$ helm delete camel-k
+$ helm uninstall camel-k
 ```
 
-The command removes all the Kubernetes resources installed.
+The command removes all of the Kubernetes resources installed, except the CRDs.
+
+To remove them:
+```bash
+$ curl -LO "https://github.com/apache/camel-k/raw/main/docs/charts/camel-k-x.y.z.tgz"
+$ tar xvzf camel-k-x.y.z.tgz
+$ kubectl delete -f camel-k/crds
+```
 
 ## Configuration
 


(camel-k) 03/04: chore(e2e): Refactor resources number const

Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 556fe54505854fe8ec6cc5026ac97cc335a787e4
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Tue Dec 5 17:05:03 2023 +0100

    chore(e2e): Refactor resources number const
---
 e2e/install/kustomize/common.go          | 117 -------------------------------
 e2e/install/upgrade/helm_upgrade_test.go |   4 +-
 e2e/support/test_support.go              |  24 +++++++
 3 files changed, 26 insertions(+), 119 deletions(-)

diff --git a/e2e/install/kustomize/common.go b/e2e/install/kustomize/common.go
deleted file mode 100644
index 88009ccfd..000000000
--- a/e2e/install/kustomize/common.go
+++ /dev/null
@@ -1,117 +0,0 @@
-//go:build integration
-// +build integration
-
-// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
-
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package kustomize
-
-import (
-	"os/exec"
-	"strings"
-	"testing"
-
-	. "github.com/apache/camel-k/v2/e2e/support"
-	. "github.com/onsi/gomega"
-	"github.com/onsi/gomega/gexec"
-	"github.com/stretchr/testify/assert"
-)
-
-const (
-	// v1.Build,          v1.Integration
-	// v1.IntegrationKit, v1.IntegrationPlatform
-	// v1.Kamelet,  v1.Pipe,
-	// v1alpha1.Kamelet, v1alpha1.KameletBinding
-	ExpectedCRDs = 8
-
-	// camel-k-operator,             camel-k-operator-events,
-	// camel-k-operator-knative,     camel-k-operator-leases,
-	// camel-k-operator-podmonitors, camel-k-operator-strimzi,
-	// camel-k-operator-keda
-	ExpectedKubePromoteRoles = 7
-
-	// camel-k-edit
-	// camel-k-operator-custom-resource-definitions
-	// camel-k-operator-bind-addressable-resolver
-	// camel-k-operator-local-registry
-	ExpectedKubeClusterRoles = 4
-
-	// camel-k-operator-openshift
-	ExpectedOSPromoteRoles = 1
-
-	// camel-k-operator-console-openshift
-	ExpectedOSClusterRoles = 1
-)
-
-func ExpectExecSucceed(t *testing.T, command *exec.Cmd) {
-	t.Helper()
-
-	var cmdOut strings.Builder
-	var cmdErr strings.Builder
-
-	defer func() {
-		if t.Failed() {
-			t.Logf("Output from make command:\n%s\n", cmdOut.String())
-			t.Logf("Error from make command:\n%s\n", cmdErr.String())
-		}
-	}()
-
-	session, err := gexec.Start(command, &cmdOut, &cmdErr)
-	session.Wait()
-	Eventually(session).Should(gexec.Exit(0))
-	assert.NoError(t, err)
-	assert.NotContains(t, strings.ToUpper(cmdErr.String()), "ERROR")
-}
-
-//
-// Expect a command error with an exit code of 1
-//
-func ExpectExecError(t *testing.T, command *exec.Cmd) {
-	t.Helper()
-
-	var cmdOut strings.Builder
-	var cmdErr strings.Builder
-
-	defer func() {
-		if t.Failed() {
-			t.Logf("Output from make command:\n%s\n", cmdOut.String())
-			t.Logf("Error from make command:\n%s\n", cmdErr.String())
-		}
-	}()
-
-	session, err := gexec.Start(command, &cmdOut, &cmdErr)
-	session.Wait()
-	Eventually(session).ShouldNot(gexec.Exit(0))
-	assert.NoError(t, err)
-	assert.Contains(t, strings.ToUpper(cmdErr.String()), "ERROR")
-}
-
-// Clean up the cluster ready for the next set of tests
-func Cleanup() {
-	// Remove the locally installed operator
-	UninstallAll()
-
-	// Ensure the CRDs & ClusterRoles are reinstalled if not already
-	Kamel("install", "--olm=false", "--cluster-setup").Execute()
-}
-
-// Removes all items
-func UninstallAll() {
-	Kamel("uninstall", "--olm=false", "--all").Execute()
-}
diff --git a/e2e/install/upgrade/helm_upgrade_test.go b/e2e/install/upgrade/helm_upgrade_test.go
index 768da149c..f966acb42 100644
--- a/e2e/install/upgrade/helm_upgrade_test.go
+++ b/e2e/install/upgrade/helm_upgrade_test.go
@@ -67,7 +67,7 @@ func TestHelmOperatorUpgrade(t *testing.T) {
 
 		Eventually(OperatorPod(ns)).ShouldNot(BeNil())
 		Eventually(OperatorImage(ns)).Should(ContainSubstring(releaseVersion))
-		Eventually(CRDs()).Should(HaveLen(8))
+		Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
 
 		//Test a simple route
 		t.Run("simple route", func(t *testing.T) {
@@ -132,7 +132,7 @@ func TestHelmOperatorUpgrade(t *testing.T) {
 		Eventually(OperatorPod(ns)).Should(BeNil())
 
 		//  helm does not remove the CRDs
-		Eventually(CRDs()).Should(HaveLen(8))
+		Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
 		ExpectExecSucceed(t,
 			exec.Command(
 				"kubectl",
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index d6908752e..4677e296b 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -92,6 +92,30 @@ import (
 const kubeConfigEnvVar = "KUBECONFIG"
 const ciPID = "/tmp/ci-k8s-pid"
 
+// v1.Build,          v1.Integration
+// v1.IntegrationKit, v1.IntegrationPlatform
+// v1.Kamelet,  v1.Pipe,
+// v1alpha1.Kamelet, v1alpha1.KameletBinding
+const ExpectedCRDs = 8
+
+// camel-k-operator,             camel-k-operator-events,
+// camel-k-operator-knative,     camel-k-operator-leases,
+// camel-k-operator-podmonitors, camel-k-operator-strimzi,
+// camel-k-operator-keda
+const ExpectedKubePromoteRoles = 7
+
+// camel-k-edit
+// camel-k-operator-custom-resource-definitions
+// camel-k-operator-bind-addressable-resolver
+// camel-k-operator-local-registry
+const ExpectedKubeClusterRoles = 4
+
+// camel-k-operator-openshift
+const ExpectedOSPromoteRoles = 1
+
+// camel-k-operator-console-openshift
+const ExpectedOSClusterRoles = 1
+
 var TestTimeoutShort = 1 * time.Minute
 var TestTimeoutMedium = 5 * time.Minute
 var TestTimeoutLong = 15 * time.Minute