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 <[email protected]>
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}
 
 #

Reply via email to