Skip to content

Commit

Permalink
fix(e2e): helm install procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Aug 23, 2023
1 parent 78a0a06 commit 44610e6
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
28 changes: 28 additions & 0 deletions e2e/install/helm/files/yaml.yaml
Original file line number Diff line number Diff line change
@@ -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"
86 changes: 86 additions & 0 deletions e2e/install/helm/setup_test.go
Original file line number Diff line number Diff line change
@@ -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())
})
}
2 changes: 1 addition & 1 deletion e2e/support/test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions e2e/support/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}()

Expand All @@ -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())
}
}()

Expand Down
1 change: 1 addition & 0 deletions script/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}

#
Expand Down

0 comments on commit 44610e6

Please sign in to comment.