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/08/23 10:26:23 UTC

[camel-k] branch main updated (93ddeb245 -> 44610e6b8)

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

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


    from 93ddeb245 chore: nightly coverage badge update
     new 78a0a06e1 chore(e2e): kustomize util refactoring
     new 44610e6b8 fix(e2e): helm install procedure

The 2 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:
 .github/workflows/install.yml                    |   8 ++
 e2e/{common/cli => install/helm}/files/yaml.yaml |   0
 e2e/install/helm/setup_test.go                   |  86 +++++++++++++++++
 e2e/install/kustomize/common.go                  | 117 -----------------------
 e2e/install/kustomize/setup_test.go              |  26 +++++
 e2e/support/test_support.go                      |   2 +-
 e2e/support/test_util.go                         |  62 ++++++++++++
 script/Makefile                                  |   1 +
 8 files changed, 184 insertions(+), 118 deletions(-)
 copy e2e/{common/cli => install/helm}/files/yaml.yaml (100%)
 create mode 100644 e2e/install/helm/setup_test.go
 delete mode 100644 e2e/install/kustomize/common.go


[camel-k] 02/02: fix(e2e): helm install procedure

Posted by pc...@apache.org.
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 44610e6b8f097b518a7c4ff71c5652452fa7b5b9
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Tue Aug 22 11:28:00 2023 +0200

    fix(e2e): helm install procedure
    
    Closes #4497
---
 .github/workflows/install.yml    |  8 ++++
 e2e/install/helm/files/yaml.yaml | 28 +++++++++++++
 e2e/install/helm/setup_test.go   | 86 ++++++++++++++++++++++++++++++++++++++++
 e2e/support/test_support.go      |  2 +-
 e2e/support/test_util.go         |  8 ++--
 script/Makefile                  |  1 +
 6 files changed, 128 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml
index 7c1e0c5bd..3575b29da 100644
--- a/.github/workflows/install.yml
+++ b/.github/workflows/install.yml
@@ -78,6 +78,14 @@ jobs:
       with:
         persist-credentials: false
         submodules: recursive
+    - name: Install Helm
+      shell: bash
+      run: |
+        curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
+        sudo apt-get install apt-transport-https --yes
+        echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
+        sudo apt-get update
+        sudo apt-get install helm
     - name: Convert input parameters to env vars
       shell: bash
       run: |
diff --git a/e2e/install/helm/files/yaml.yaml b/e2e/install/helm/files/yaml.yaml
new file mode 100644
index 000000000..9ccf65273
--- /dev/null
+++ b/e2e/install/helm/files/yaml.yaml
@@ -0,0 +1,28 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+- from:
+    uri: "timer:yaml"
+    parameters:
+      period: "5000"
+    steps:
+      - set-header:
+          name: "m"
+          constant: "string!"
+      - set-body:
+          simple: "Magic${header.m}"
+      - to: "log:info"
diff --git a/e2e/install/helm/setup_test.go b/e2e/install/helm/setup_test.go
new file mode 100644
index 000000000..d4441578a
--- /dev/null
+++ b/e2e/install/helm/setup_test.go
@@ -0,0 +1,86 @@
+//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 helm
+
+import (
+	"fmt"
+	"os"
+	"os/exec"
+	"testing"
+
+	corev1 "k8s.io/api/core/v1"
+
+	. "github.com/apache/camel-k/v2/e2e/support"
+	"github.com/apache/camel-k/v2/pkg/util/defaults"
+	. "github.com/onsi/gomega"
+)
+
+func TestHelmInstallRunUninstall(t *testing.T) {
+	RegisterTestingT(t)
+
+	KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY")
+	customImage := fmt.Sprintf("%s/apache/camel-k", KAMEL_INSTALL_REGISTRY)
+
+	os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../")
+
+	WithNewTestNamespace(t, func(ns string) {
+		ExpectExecSucceed(t, Make(fmt.Sprintf("CUSTOM_IMAGE=%s", customImage), "set-version"))
+		ExpectExecSucceed(t, Make("release-helm"))
+		ExpectExecSucceed(t,
+			exec.Command(
+				"helm",
+				"install",
+				"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,
+			),
+		)
+
+		Eventually(OperatorPod(ns)).ShouldNot(BeNil())
+
+		//Test a simple route
+		t.Run("simple route", func(t *testing.T) {
+			name := "yaml"
+			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!"))
+		})
+
+		ExpectExecSucceed(t,
+			exec.Command(
+				"helm",
+				"uninstall",
+				"camel-k",
+				"-n",
+				ns,
+			),
+		)
+
+		Eventually(OperatorPod(ns)).Should(BeNil())
+	})
+}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 9e8e07b1f..c1078e426 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -430,7 +430,7 @@ func MakeWithContext(ctx context.Context, rule string, args ...string) *exec.Cmd
 	defaultArgs := strings.Fields(makeArgs)
 	args = append(defaultArgs, args...)
 
-	defaultDir := "../../../../install"
+	defaultDir := "."
 	makeDir := os.Getenv("CAMEL_K_TEST_MAKE_DIR")
 	if makeDir == "" {
 		makeDir = defaultDir
diff --git a/e2e/support/test_util.go b/e2e/support/test_util.go
index 7a6cca019..88842a85d 100644
--- a/e2e/support/test_util.go
+++ b/e2e/support/test_util.go
@@ -64,8 +64,8 @@ func ExpectExecSucceed(t *testing.T, command *exec.Cmd) {
 
 	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())
+			t.Logf("Output from exec command:\n%s\n", cmdOut.String())
+			t.Logf("Error from exec command:\n%s\n", cmdErr.String())
 		}
 	}()
 
@@ -87,8 +87,8 @@ func ExpectExecError(t *testing.T, command *exec.Cmd) {
 
 	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())
+			t.Logf("Output from exec command:\n%s\n", cmdOut.String())
+			t.Logf("Error from exec command:\n%s\n", cmdErr.String())
 		}
 	}()
 
diff --git a/script/Makefile b/script/Makefile
index f4ea4aa87..96d7beb40 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -309,6 +309,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=1; \
 	go test -timeout 40m -v ./e2e/install/kustomize -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \
+	go test -timeout 40m -v ./e2e/install/helm -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \
 	exit $${FAILED}
 
 #


[camel-k] 01/02: chore(e2e): kustomize util refactoring

Posted by pc...@apache.org.
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 78a0a06e1fcc02df722888da5a05973037512bed
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Tue Aug 22 09:19:53 2023 +0200

    chore(e2e): kustomize util refactoring
---
 e2e/install/kustomize/common.go     | 117 ------------------------------------
 e2e/install/kustomize/setup_test.go |  26 ++++++++
 e2e/support/test_util.go            |  62 +++++++++++++++++++
 3 files changed, 88 insertions(+), 117 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/kustomize/setup_test.go b/e2e/install/kustomize/setup_test.go
index 429f516e7..2c9fdb0d2 100644
--- a/e2e/install/kustomize/setup_test.go
+++ b/e2e/install/kustomize/setup_test.go
@@ -32,6 +32,32 @@ import (
 	. "github.com/onsi/gomega"
 )
 
+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 TestSetupKustomizeBasic(t *testing.T) {
 	RegisterTestingT(t)
 	makeDir := testutil.MakeTempCopyDir(t, "../../../install")
diff --git a/e2e/support/test_util.go b/e2e/support/test_util.go
index b85e93060..7a6cca019 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,60 @@ 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 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()
+}