You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cd...@apache.org on 2024/03/08 19:35:54 UTC
(camel-k) 01/10: chore(e2e): Improve E2E tests
This is an automated email from the ASF dual-hosted git repository.
cdeppisch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 773622571d0e6241880c93dd4305c9b7e1eb9155
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Tue Feb 27 12:01:44 2024 +0100
chore(e2e): Improve E2E tests
- Improve common-it to use separate test namespace and default global operator
- Create default integration kits with global operator before tests are run
- TestMain func() creates commonly used Camel K integrations before the test so the integration kits are reused during the test run
- Reuse default integration kits (type=external image) in all test namespaces with custom operator installation
- Reduces builds of integration kits in tests
- Fix missing IntegrationProfile CRD
- Fix flaky update install tests
---
.github/actions/e2e-common/exec-tests.sh | 2 +
e2e/advanced/build_order_strategy_test.go | 2 +
e2e/advanced/builder_test.go | 1 +
e2e/advanced/catalog_builder_test.go | 1 +
e2e/advanced/debug_test.go | 1 +
e2e/advanced/deployment_test.go | 1 +
e2e/advanced/dump_test.go | 1 +
e2e/advanced/environment_test.go | 3 +-
e2e/advanced/incremental_build_test.go | 1 +
e2e/advanced/kamelet_repo_test.go | 1 +
e2e/advanced/local_platform_test.go | 1 +
e2e/advanced/main_test.go | 68 ++
e2e/advanced/maven_http_proxy_test.go | 5 +-
e2e/advanced/operator_id_filtering_test.go | 2 +
e2e/advanced/platform_traits_test.go | 1 +
e2e/advanced/promote_test.go | 2 +
e2e/advanced/reset_test.go | 1 +
e2e/advanced/synthetic_test.go | 2 +
e2e/common/cli/bind_test.go | 57 +-
e2e/common/cli/config_test.go | 42 +-
e2e/common/cli/default.go | 9 +-
e2e/common/cli/delete_test.go | 74 +--
e2e/common/cli/describe_test.go | 67 +-
e2e/common/cli/dev_mode_test.go | 196 +++---
e2e/common/cli/get_test.go | 74 +--
e2e/common/cli/log_test.go | 40 +-
e2e/common/cli/run_test.go | 325 +++++-----
e2e/common/config/config_reload_test.go | 206 ++++---
e2e/common/config/config_test.go | 576 +++++++++--------
e2e/common/config/default.go | 9 +-
e2e/common/config/kamelet_config_test.go | 407 ++++++------
e2e/common/config/pipe_config_test.go | 387 ++++++------
e2e/common/languages/default.go | 9 +-
e2e/common/languages/groovy_test.go | 17 +-
e2e/common/languages/java_test.go | 17 +-
e2e/common/languages/js_test.go | 17 +-
e2e/common/languages/kotlin_test.go | 17 +-
e2e/common/languages/polyglot_test.go | 21 +-
e2e/common/languages/xml_test.go | 17 +-
e2e/common/languages/yaml_test.go | 17 +-
e2e/common/misc/client_test.go | 55 +-
e2e/common/misc/cron_test.go | 75 +--
e2e/common/misc/default.go | 9 +-
e2e/common/misc/integration_fail_test.go | 293 ++++-----
e2e/common/misc/integration_trait_update_test.go | 31 +-
e2e/common/misc/kamelet_test.go | 49 +-
e2e/common/misc/kamelet_update_test.go | 17 +-
e2e/common/misc/maven_repository_test.go | 35 +-
e2e/common/misc/pipe_test.go | 141 ++---
e2e/common/misc/pipe_with_image_test.go | 119 ++--
e2e/common/misc/registry_maven_wagon_test.go | 2 +-
e2e/common/misc/rest_test.go | 59 +-
e2e/common/misc/scale_binding_test.go | 177 +++---
e2e/common/misc/scale_integration_test.go | 177 +++---
e2e/common/misc/structured_logs_test.go | 46 +-
e2e/common/runtimes/default.go | 9 +-
e2e/common/runtimes/runtimes_test.go | 65 +-
e2e/common/setup/main_test.go | 63 ++
e2e/common/setup/testdata/Java.java | 28 +
e2e/common/setup/testdata/yaml.yaml | 28 +
e2e/common/support/startup_test.go | 51 --
e2e/common/support/teardown_test.go | 40 --
e2e/common/traits/affinity_test.go | 135 ++--
e2e/common/traits/builder_test.go | 486 +++++++--------
e2e/common/traits/camel_test.go | 63 +-
e2e/common/traits/container_test.go | 141 ++---
e2e/common/traits/default.go | 9 +-
e2e/common/traits/deployment_test.go | 120 ++--
e2e/common/traits/error_handler_test.go | 31 +-
e2e/common/traits/errored_trait_test.go | 77 +--
e2e/common/traits/health_test.go | 753 ++++++++++++-----------
e2e/common/traits/istio_test.go | 47 +-
e2e/common/traits/jolokia_test.go | 68 +-
e2e/common/traits/jvm_test.go | 49 +-
e2e/common/traits/kamelet_test.go | 51 +-
e2e/common/traits/master_test.go | 79 +--
e2e/common/traits/openapi_test.go | 45 +-
e2e/common/traits/pdb_test.go | 201 +++---
e2e/common/traits/pod_test.go | 113 ++--
e2e/common/traits/prometheus_test.go | 75 +--
e2e/common/traits/pull_secret_test.go | 101 +--
e2e/common/traits/route_test.go | 301 ++++-----
e2e/common/traits/service_binding_test.go | 127 ++--
e2e/common/traits/service_test.go | 167 ++---
e2e/common/traits/toleration_test.go | 177 +++---
e2e/install/cli/uninstall_test.go | 2 +-
e2e/install/kustomize/operator_test.go | 9 +-
e2e/install/kustomize/setup_test.go | 10 +-
e2e/install/kustomize/uninstall_test.go | 9 +-
e2e/install/upgrade/cli_upgrade_test.go | 12 +
e2e/install/upgrade/helm_upgrade_test.go | 35 +-
e2e/install/upgrade/olm_upgrade_test.go | 14 +-
e2e/knative/default.go | 9 +-
e2e/knative/knative_platform_test.go | 4 +-
e2e/knative/support/startup_test.go | 51 --
e2e/knative/support/teardown_test.go | 40 --
e2e/support/test_support.go | 80 ++-
e2e/support/test_util.go | 19 +-
e2e/support/util/dump.go | 2 +-
e2e/telemetry/telemetry_test.go | 4 +-
pkg/cmd/install.go | 2 +-
pkg/cmd/uninstall.go | 2 +-
pkg/platform/platform.go | 4 +-
pkg/util/olm/available.go | 4 +-
script/Makefile | 8 +-
105 files changed, 4097 insertions(+), 3905 deletions(-)
diff --git a/.github/actions/e2e-common/exec-tests.sh b/.github/actions/e2e-common/exec-tests.sh
index 3a412782c..3f68f0572 100755
--- a/.github/actions/e2e-common/exec-tests.sh
+++ b/.github/actions/e2e-common/exec-tests.sh
@@ -137,6 +137,8 @@ else
export CAMEL_K_GLOBAL_OPERATOR_NS="default"
fi
+export CAMEL_K_E2E_FAST_SETUP="true"
+
# Then run all integration tests rather than ending on first failure
set -e
exit_code=0
diff --git a/e2e/advanced/build_order_strategy_test.go b/e2e/advanced/build_order_strategy_test.go
index 1f5debb4c..5dd64120d 100644
--- a/e2e/advanced/build_order_strategy_test.go
+++ b/e2e/advanced/build_order_strategy_test.go
@@ -38,6 +38,7 @@ func TestRunBuildOrderStrategyMatchingDependencies(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-build-order-deps"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns,
"--max-running-pipelines", "4",
"--build-order-strategy", string(v1.BuildOrderStrategyDependencies)).Execute()).To(Succeed())
@@ -124,6 +125,7 @@ func TestRunBuildOrderStrategyFIFO(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-build-order-fifo"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns, "--build-order-strategy", string(v1.BuildOrderStrategyFIFO)).Execute()).To(Succeed())
Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
diff --git a/e2e/advanced/builder_test.go b/e2e/advanced/builder_test.go
index b79651cfd..78867b16e 100644
--- a/e2e/advanced/builder_test.go
+++ b/e2e/advanced/builder_test.go
@@ -39,6 +39,7 @@ func TestBuilderTimeout(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
Eventually(Platform(ns)).ShouldNot(BeNil())
diff --git a/e2e/advanced/catalog_builder_test.go b/e2e/advanced/catalog_builder_test.go
index 2917b1030..d67cfacd9 100644
--- a/e2e/advanced/catalog_builder_test.go
+++ b/e2e/advanced/catalog_builder_test.go
@@ -40,6 +40,7 @@ func TestCamelCatalogBuilder(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
Eventually(Platform(ns)).ShouldNot(BeNil())
diff --git a/e2e/advanced/debug_test.go b/e2e/advanced/debug_test.go
index 1a0fb8bc8..38c422cee 100644
--- a/e2e/advanced/debug_test.go
+++ b/e2e/advanced/debug_test.go
@@ -42,6 +42,7 @@ func TestKamelCLIDebug(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
diff --git a/e2e/advanced/deployment_test.go b/e2e/advanced/deployment_test.go
index cd8acc44d..4d489e2dd 100644
--- a/e2e/advanced/deployment_test.go
+++ b/e2e/advanced/deployment_test.go
@@ -38,6 +38,7 @@ func TestDeploymentFailureShouldReportIntegrationCondition(t *testing.T) {
operatorID := "camel-k-failing-deploy"
nsRestr := "restr"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns, "--global", "--force").Execute()).To(Succeed())
// Create restricted namespace
ExpectExecSucceed(t,
diff --git a/e2e/advanced/dump_test.go b/e2e/advanced/dump_test.go
index 587c8116d..31a31825e 100644
--- a/e2e/advanced/dump_test.go
+++ b/e2e/advanced/dump_test.go
@@ -48,6 +48,7 @@ func TestKamelCLIDump(t *testing.T) {
t.Run("dump non-empty namespace", func(t *testing.T) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
diff --git a/e2e/advanced/environment_test.go b/e2e/advanced/environment_test.go
index 4bfffb429..2befe92fe 100644
--- a/e2e/advanced/environment_test.go
+++ b/e2e/advanced/environment_test.go
@@ -50,7 +50,7 @@ func TestEnvironmentTrait(t *testing.T) {
}
// Retrieve the Kubernetes Service ClusterIPs to populate the NO_PROXY environment variable
- svc := Service("default", "kubernetes")()
+ svc := Service(TestDefaultNamespace, "kubernetes")()
Expect(svc).NotTo(BeNil())
noProxy = append(noProxy, svc.Spec.ClusterIPs...)
@@ -66,6 +66,7 @@ func TestEnvironmentTrait(t *testing.T) {
// Install Camel K with the HTTP proxy environment variable
operatorID := "camel-k-trait-environment"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns,
"--operator-env-vars", fmt.Sprintf("HTTP_PROXY=%s", httpProxy),
"--operator-env-vars", "NO_PROXY="+strings.Join(noProxy, ","),
diff --git a/e2e/advanced/incremental_build_test.go b/e2e/advanced/incremental_build_test.go
index dc7bcf16e..a28510e78 100644
--- a/e2e/advanced/incremental_build_test.go
+++ b/e2e/advanced/incremental_build_test.go
@@ -39,6 +39,7 @@ func TestRunIncrementalBuildRoutine(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-incremental-build"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
diff --git a/e2e/advanced/kamelet_repo_test.go b/e2e/advanced/kamelet_repo_test.go
index 04ee0be25..08a9ad3d5 100644
--- a/e2e/advanced/kamelet_repo_test.go
+++ b/e2e/advanced/kamelet_repo_test.go
@@ -39,6 +39,7 @@ func TestKameletFromCustomRepository(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
diff --git a/e2e/advanced/local_platform_test.go b/e2e/advanced/local_platform_test.go
index e896dcaaa..64516768e 100644
--- a/e2e/advanced/local_platform_test.go
+++ b/e2e/advanced/local_platform_test.go
@@ -37,6 +37,7 @@ func TestLocalPlatform(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-platform-local"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns, "--global", "--force").Execute()).To(Succeed())
Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
diff --git a/e2e/advanced/main_test.go b/e2e/advanced/main_test.go
new file mode 100644
index 000000000..d403140de
--- /dev/null
+++ b/e2e/advanced/main_test.go
@@ -0,0 +1,68 @@
+//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 advanced
+
+import (
+ "fmt"
+ "os"
+ "testing"
+
+ . "github.com/onsi/gomega"
+
+ . "github.com/apache/camel-k/v2/e2e/support"
+ v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/v2/pkg/platform"
+
+ corev1 "k8s.io/api/core/v1"
+)
+
+func TestMain(m *testing.M) {
+ fastSetup := GetEnvOrDefault("CAMEL_K_E2E_FAST_SETUP", "false")
+ if fastSetup != "true" {
+ os.Exit(m.Run())
+ }
+
+ operatorID := platform.DefaultPlatformName
+ ns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)
+
+ g := NewGomega(func(message string, callerSkip ...int) {
+ fmt.Printf("Test fast setup failed! - %s\n", message)
+ })
+
+ g.Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
+ g.Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ g.Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ g.Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ g.Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
+ g.Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ g.Eventually(IntegrationConditionStatus(ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ g.Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ g.Expect(KamelRunWithID(operatorID, ns, "files/timer-source.groovy").Execute()).To(Succeed())
+ g.Eventually(IntegrationPodPhase(ns, "timer-source"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ g.Eventually(IntegrationConditionStatus(ns, "timer-source", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ g.Eventually(IntegrationLogs(ns, "timer-source"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ os.Exit(m.Run())
+}
diff --git a/e2e/advanced/maven_http_proxy_test.go b/e2e/advanced/maven_http_proxy_test.go
index ef092942d..358e7ca17 100644
--- a/e2e/advanced/maven_http_proxy_test.go
+++ b/e2e/advanced/maven_http_proxy_test.go
@@ -135,7 +135,7 @@ func TestMavenProxy(t *testing.T) {
}),
))
- svc := Service("default", "kubernetes")()
+ svc := Service(TestDefaultNamespace, "kubernetes")()
Expect(svc).NotTo(BeNil())
// It may be needed to populate the values from the cluster, machine and service network CIDRs
@@ -149,7 +149,8 @@ func TestMavenProxy(t *testing.T) {
// Install Camel K with the HTTP proxy
operatorID := "camel-k-maven-proxy"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
- olm, olmErr := olm.IsAPIAvailable(TestContext, TestClient(), ns)
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
+ olm, olmErr := olm.IsAPIAvailable(TestClient())
installed, inErr := kubernetes.IsAPIResourceInstalled(TestClient(), configv1.GroupVersion.String(), reflect.TypeOf(configv1.Proxy{}).Name())
permission, pErr := kubernetes.CheckPermission(TestContext, TestClient(), configv1.GroupName, reflect.TypeOf(configv1.Proxy{}).Name(), "", "cluster", "edit")
olmInstall := pErr == nil && olmErr == nil && inErr == nil && olm && installed && permission
diff --git a/e2e/advanced/operator_id_filtering_test.go b/e2e/advanced/operator_id_filtering_test.go
index 5305722ca..970dd229d 100644
--- a/e2e/advanced/operator_id_filtering_test.go
+++ b/e2e/advanced/operator_id_filtering_test.go
@@ -50,12 +50,14 @@ func TestOperatorIDFiltering(t *testing.T) {
WithNewTestNamespace(t, func(nsop1 string) {
operator1 := "operator-1"
Expect(CopyCamelCatalog(nsop1, operator1)).To(Succeed())
+ Expect(CopyIntegrationKits(nsop1, operator1)).To(Succeed())
Expect(KamelInstallWithIDAndKameletCatalog(operator1, nsop1, "--global", "--force").Execute()).To(Succeed())
Eventually(PlatformPhase(nsop1), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
WithNewTestNamespace(t, func(nsop2 string) {
operator2 := "operator-2"
Expect(CopyCamelCatalog(nsop2, operator2)).To(Succeed())
+ Expect(CopyIntegrationKits(nsop2, operator2)).To(Succeed())
Expect(KamelInstallWithIDAndKameletCatalog(operator2, nsop2, "--global", "--force").Execute()).To(Succeed())
Eventually(PlatformPhase(nsop2), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
diff --git a/e2e/advanced/platform_traits_test.go b/e2e/advanced/platform_traits_test.go
index ca5d1a920..0e0ef5d16 100644
--- a/e2e/advanced/platform_traits_test.go
+++ b/e2e/advanced/platform_traits_test.go
@@ -39,6 +39,7 @@ func TestTraitOnIntegrationPlatform(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-platform-trait-test"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
containerTestName := "testname"
diff --git a/e2e/advanced/promote_test.go b/e2e/advanced/promote_test.go
index 15580920a..40b4124c8 100644
--- a/e2e/advanced/promote_test.go
+++ b/e2e/advanced/promote_test.go
@@ -40,6 +40,7 @@ func TestKamelCLIPromote(t *testing.T) {
WithNewTestNamespace(t, func(nsDev string) {
operatorDevID := "camel-k-cli-promote-dev"
Expect(CopyCamelCatalog(nsDev, operatorDevID)).To(Succeed())
+ Expect(CopyIntegrationKits(nsDev, operatorDevID)).To(Succeed())
Expect(KamelInstallWithID(operatorDevID, nsDev).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(nsDev, operatorDevID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
@@ -82,6 +83,7 @@ func TestKamelCLIPromote(t *testing.T) {
WithNewTestNamespace(t, func(nsProd string) {
operatorProdID := "camel-k-cli-promote-prod"
Expect(CopyCamelCatalog(nsProd, operatorProdID)).To(Succeed())
+ Expect(CopyIntegrationKits(nsProd, operatorProdID)).To(Succeed())
Expect(KamelInstallWithID(operatorProdID, nsProd).Execute()).To(Succeed())
Eventually(PlatformPhase(nsProd), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
diff --git a/e2e/advanced/reset_test.go b/e2e/advanced/reset_test.go
index 3ab367410..4768ec0f7 100644
--- a/e2e/advanced/reset_test.go
+++ b/e2e/advanced/reset_test.go
@@ -36,6 +36,7 @@ func TestKamelReset(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-cli-reset"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
diff --git a/e2e/advanced/synthetic_test.go b/e2e/advanced/synthetic_test.go
index 67539964f..236a1fae8 100644
--- a/e2e/advanced/synthetic_test.go
+++ b/e2e/advanced/synthetic_test.go
@@ -40,6 +40,7 @@ func TestSyntheticIntegrationOff(t *testing.T) {
// Install Camel K without synthetic Integration feature variable (default)
operatorID := "camel-k-synthetic-env-off"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
@@ -62,6 +63,7 @@ func TestSyntheticIntegrationFromDeployment(t *testing.T) {
// Install Camel K with the synthetic Integration feature variable
operatorID := "camel-k-synthetic-env"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
+ Expect(CopyIntegrationKits(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns,
"--operator-env-vars", "CAMEL_K_SYNTHETIC_INTEGRATIONS=true",
).Execute()).To(Succeed())
diff --git a/e2e/common/cli/bind_test.go b/e2e/common/cli/bind_test.go
index f9a526311..e888bf597 100644
--- a/e2e/common/cli/bind_test.go
+++ b/e2e/common/cli/bind_test.go
@@ -33,33 +33,34 @@ import (
)
func TestKamelCLIBind(t *testing.T) {
- RegisterTestingT(t)
-
- kameletName := "test-timer-source"
- Expect(CreateTimerKamelet(ns, kameletName)()).To(Succeed())
-
- t.Run("bind timer to log", func(t *testing.T) {
- Expect(KamelBindWithID(operatorID, ns, kameletName, "log:info", "-p", "source.message=helloTest").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "test-timer-source-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, "test-timer-source-to-log")).Should(ContainSubstring("Body: helloTest"))
- Expect(KamelBindWithID(operatorID, ns, "test-timer-source", "log:info", "-p", "source.message=newText").Execute()).To(Succeed())
- Eventually(IntegrationLogs(ns, "test-timer-source-to-log")).Should(ContainSubstring("Body: newText"))
+ WithNewTestNamespace(t, func(ns string) {
+ kameletName := "test-timer-source"
+ Expect(CreateTimerKamelet(ns, kameletName)()).To(Succeed())
+
+ t.Run("bind timer to log", func(t *testing.T) {
+ Expect(KamelBindWithID(operatorID, ns, kameletName, "log:info", "-p", "source.message=helloTest").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "test-timer-source-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, "test-timer-source-to-log")).Should(ContainSubstring("Body: helloTest"))
+ Expect(KamelBindWithID(operatorID, ns, "test-timer-source", "log:info", "-p", "source.message=newText").Execute()).To(Succeed())
+ Eventually(IntegrationLogs(ns, "test-timer-source-to-log")).Should(ContainSubstring("Body: newText"))
+ })
+
+ t.Run("unsuccessful binding, no property", func(t *testing.T) {
+ opns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)
+ Expect(KamelBindWithID(operatorID, ns, opns+"/timer-source", "log:info").Execute()).NotTo(Succeed())
+ })
+
+ t.Run("bind uris", func(t *testing.T) {
+ Expect(KamelBindWithID(operatorID, ns, "timer:foo", "log:bar").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "timer-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, "timer-to-log")).Should(ContainSubstring("Body is null"))
+ })
+
+ t.Run("bind with custom SA", func(t *testing.T) {
+ Expect(KamelBindWithID(operatorID, ns, "timer:foo", "log:bar", "--service-account", "my-service-account").Execute()).To(Succeed())
+ Eventually(IntegrationSpecSA(ns, "timer-to-log")).Should(Equal("my-service-account"))
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- t.Run("unsuccessful binding, no property", func(t *testing.T) {
- Expect(KamelBindWithID(operatorID, ns, "timer-source", "log:info").Execute()).NotTo(Succeed())
- })
-
- t.Run("bind uris", func(t *testing.T) {
- Expect(KamelBindWithID(operatorID, ns, "timer:foo", "log:bar").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "timer-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, "timer-to-log")).Should(ContainSubstring("Body is null"))
- })
-
- t.Run("bind with custom SA", func(t *testing.T) {
- Expect(KamelBindWithID(operatorID, ns, "timer:foo", "log:bar", "--service-account", "my-service-account").Execute()).To(Succeed())
- Eventually(IntegrationSpecSA(ns, "timer-to-log")).Should(Equal("my-service-account"))
- })
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/cli/config_test.go b/e2e/common/cli/config_test.go
index 184aba58f..20390ee89 100644
--- a/e2e/common/cli/config_test.go
+++ b/e2e/common/cli/config_test.go
@@ -39,30 +39,30 @@ import (
)
func TestKamelCLIConfig(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("check default namespace", func(t *testing.T) {
+ _, err := os.Stat(cmd.DefaultConfigLocation)
+ assert.True(t, os.IsNotExist(err), "No file at "+cmd.DefaultConfigLocation+" was expected")
+ t.Cleanup(func() { os.Remove(cmd.DefaultConfigLocation) })
+ Expect(Kamel("config", "--default-namespace", ns).Execute()).To(Succeed())
+ _, err = os.Stat(cmd.DefaultConfigLocation)
+ require.NoError(t, err, "A file at "+cmd.DefaultConfigLocation+" was expected")
+ Expect(Kamel("run", "--operator-id", operatorID, "files/yaml.yaml").Execute()).To(Succeed())
- t.Run("check default namespace", func(t *testing.T) {
- _, err := os.Stat(cmd.DefaultConfigLocation)
- assert.True(t, os.IsNotExist(err), "No file at "+cmd.DefaultConfigLocation+" was expected")
- t.Cleanup(func() { os.Remove(cmd.DefaultConfigLocation) })
- Expect(Kamel("config", "--default-namespace", ns).Execute()).To(Succeed())
- _, err = os.Stat(cmd.DefaultConfigLocation)
- require.NoError(t, err, "A file at "+cmd.DefaultConfigLocation+" was expected")
- Expect(Kamel("run", "--operator-id", operatorID, "files/yaml.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ // first line of the integration logs
+ logs := strings.Split(IntegrationLogs(ns, "yaml")(), "\n")[0]
+ podName := IntegrationPod(ns, "yaml")().Name
- // first line of the integration logs
- logs := strings.Split(IntegrationLogs(ns, "yaml")(), "\n")[0]
- podName := IntegrationPod(ns, "yaml")().Name
+ logsCLI := GetOutputStringAsync(Kamel("log", "yaml"))
+ Eventually(logsCLI).Should(ContainSubstring("Monitoring pod " + podName))
+ Eventually(logsCLI).Should(ContainSubstring(logs))
+ })
- logsCLI := GetOutputStringAsync(Kamel("log", "yaml"))
- Eventually(logsCLI).Should(ContainSubstring("Monitoring pod " + podName))
- Eventually(logsCLI).Should(ContainSubstring(logs))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all").Execute()).To(Succeed())
}
diff --git a/e2e/common/cli/default.go b/e2e/common/cli/default.go
index dbd4ae0b2..74e73354d 100644
--- a/e2e/common/cli/default.go
+++ b/e2e/common/cli/default.go
@@ -20,7 +20,10 @@ limitations under the License.
package cli
-import "github.com/apache/camel-k/v2/e2e/support"
+import (
+ "github.com/apache/camel-k/v2/e2e/support"
+ "github.com/apache/camel-k/v2/pkg/platform"
+)
-var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.GetCIProcessID())
-var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", support.GetCIProcessID())
+var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.TestDefaultNamespace)
+var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", platform.DefaultPlatformName)
diff --git a/e2e/common/cli/delete_test.go b/e2e/common/cli/delete_test.go
index ea69bde92..01935ea56 100644
--- a/e2e/common/cli/delete_test.go
+++ b/e2e/common/cli/delete_test.go
@@ -33,47 +33,47 @@ import (
)
func TestKamelCLIDelete(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("delete running integration", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, "yaml")).Should(BeNil())
+ Eventually(IntegrationPod(ns, "yaml"), TestTimeoutLong).Should(BeNil())
+ })
- t.Run("delete running integration", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, "yaml")).Should(BeNil())
- Eventually(IntegrationPod(ns, "yaml"), TestTimeoutLong).Should(BeNil())
- })
+ t.Run("delete building integration", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, "yaml")).Should(BeNil())
+ Eventually(IntegrationPod(ns, "yaml"), TestTimeoutLong).Should(BeNil())
+ })
- t.Run("delete building integration", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
- Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, "yaml")).Should(BeNil())
- Eventually(IntegrationPod(ns, "yaml"), TestTimeoutLong).Should(BeNil())
- })
+ t.Run("delete several integrations", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, "yaml")).Should(BeNil())
+ Eventually(IntegrationPod(ns, "yaml"), TestTimeoutLong).Should(BeNil())
+ Expect(Kamel("delete", "java", "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, "java")).Should(BeNil())
+ Eventually(IntegrationPod(ns, "java"), TestTimeoutLong).Should(BeNil())
+ })
- t.Run("delete several integrations", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, "yaml")).Should(BeNil())
- Eventually(IntegrationPod(ns, "yaml"), TestTimeoutLong).Should(BeNil())
- Expect(Kamel("delete", "java", "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, "java")).Should(BeNil())
- Eventually(IntegrationPod(ns, "java"), TestTimeoutLong).Should(BeNil())
- })
+ t.Run("delete all integrations", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, "yaml")).Should(BeNil())
+ Eventually(IntegrationPod(ns, "yaml"), TestTimeoutLong).Should(BeNil())
+ Eventually(Integration(ns, "java")).Should(BeNil())
+ Eventually(IntegrationPod(ns, "java"), TestTimeoutLong).Should(BeNil())
+ })
- t.Run("delete all integrations", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, "yaml")).Should(BeNil())
- Eventually(IntegrationPod(ns, "yaml"), TestTimeoutLong).Should(BeNil())
- Eventually(Integration(ns, "java")).Should(BeNil())
- Eventually(IntegrationPod(ns, "java"), TestTimeoutLong).Should(BeNil())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/cli/describe_test.go b/e2e/common/cli/describe_test.go
index 567801a55..ce7cb7a28 100644
--- a/e2e/common/cli/describe_test.go
+++ b/e2e/common/cli/describe_test.go
@@ -36,49 +36,52 @@ import (
)
func TestKamelCliDescribe(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- t.Run("Test kamel describe integration", func(t *testing.T) {
- integration := GetOutputString(Kamel("describe", "integration", "yaml", "-n", ns))
- r, _ := regexp.Compile("(?sm).*Name:\\s+yaml.*")
- Expect(integration).To(MatchRegexp(r.String()))
+ t.Run("Test kamel describe integration", func(t *testing.T) {
+ integration := GetOutputString(Kamel("describe", "integration", "yaml", "-n", ns))
+ r, _ := regexp.Compile("(?sm).*Name:\\s+yaml.*")
+ Expect(integration).To(MatchRegexp(r.String()))
- r, _ = regexp.Compile("(?sm).*Phase:\\s+Running.*")
- Expect(integration).To(MatchRegexp(r.String()))
+ r, _ = regexp.Compile("(?sm).*Phase:\\s+Running.*")
+ Expect(integration).To(MatchRegexp(r.String()))
- Expect(integration).To(ContainSubstring("Dependencies:"))
- Expect(integration).To(ContainSubstring("Conditions:"))
- })
+ Expect(integration).To(ContainSubstring("Dependencies:"))
+ Expect(integration).To(ContainSubstring("Conditions:"))
+ })
- t.Run("Test kamel describe integration kit", func(t *testing.T) {
- kitName := Integration(ns, "yaml")().Status.IntegrationKit.Name
- kit := GetOutputString(Kamel("describe", "kit", kitName, "-n", ns))
+ t.Run("Test kamel describe integration kit", func(t *testing.T) {
+ kitName := Integration(ns, "yaml")().Status.IntegrationKit.Name
+ kitNamespace := Integration(ns, "yaml")().Status.IntegrationKit.Namespace
+ kit := GetOutputString(Kamel("describe", "kit", kitName, "-n", kitNamespace))
- r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + ns + ".*")
- Expect(kit).To(MatchRegexp(r.String()))
+ r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + kitNamespace + ".*")
+ Expect(kit).To(MatchRegexp(r.String()))
- r, _ = regexp.Compile("(?sm).*Runtime Version:\\s+" + defaults.DefaultRuntimeVersion + ".*")
- Expect(kit).To(MatchRegexp(r.String()))
+ r, _ = regexp.Compile("(?sm).*Runtime Version:\\s+" + defaults.DefaultRuntimeVersion + ".*")
+ Expect(kit).To(MatchRegexp(r.String()))
- Expect(kit).To(ContainSubstring("camel-quarkus-core"))
+ Expect(kit).To(ContainSubstring("camel-quarkus-core"))
- Expect(kit).To(ContainSubstring("Artifacts:"))
- Expect(kit).To(ContainSubstring("Dependencies:"))
- })
+ Expect(kit).To(ContainSubstring("Artifacts:"))
+ Expect(kit).To(ContainSubstring("Dependencies:"))
+ })
- t.Run("Test kamel describe integration platform", func(t *testing.T) {
- platform := GetOutputString(Kamel("describe", "platform", operatorID, "-n", ns))
- Expect(platform).To(ContainSubstring(fmt.Sprintf("Name: %s", operatorID)))
+ t.Run("Test kamel describe integration platform", func(t *testing.T) {
+ opns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)
+ platform := GetOutputString(Kamel("describe", "platform", operatorID, "-n", opns))
+ Expect(platform).To(ContainSubstring(fmt.Sprintf("Name: %s", operatorID)))
- r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + ns + ".*")
- Expect(platform).To(MatchRegexp(r.String()))
+ r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + opns + ".*")
+ Expect(platform).To(MatchRegexp(r.String()))
- r, _ = regexp.Compile("(?sm).*Runtime Version:\\s+" + defaults.DefaultRuntimeVersion + ".*")
- Expect(platform).To(MatchRegexp(r.String()))
- })
+ r, _ = regexp.Compile("(?sm).*Runtime Version:\\s+" + defaults.DefaultRuntimeVersion + ".*")
+ Expect(platform).To(MatchRegexp(r.String()))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/cli/dev_mode_test.go b/e2e/common/cli/dev_mode_test.go
index f617bf7a5..bc0a67636 100644
--- a/e2e/common/cli/dev_mode_test.go
+++ b/e2e/common/cli/dev_mode_test.go
@@ -37,120 +37,120 @@ import (
)
func TestRunDevMode(t *testing.T) {
- RegisterTestingT(t)
-
- /*
- * TODO
- * The changing of the yaml file constant from "string" to "magic" is not being
- * picked up when deploying on OCP4 and so the test is failing.
- *
- * Adding CAMEL_K_TEST_SKIP_PROBLEMATIC env var for the moment.
- */
- if os.Getenv("CAMEL_K_TEST_SKIP_PROBLEMATIC") == "true" {
- t.Skip("WARNING: Test marked as problematic ... skipping")
- }
-
- t.Run("run yaml dev mode", func(t *testing.T) {
- RegisterTestingT(t)
- ctx, cancel := context.WithCancel(TestContext)
- defer cancel()
- piper, pipew := io.Pipe()
- defer pipew.Close()
- defer piper.Close()
-
- file := util.MakeTempCopy(t, "files/yaml.yaml")
- name := RandomizedSuffixName("yaml")
-
- kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, "--name", name, "--dev")
- kamelRun.SetOut(pipew)
-
- logScanner := util.NewLogScanner(ctx, piper, `integration "`+name+`" in phase Running`, "Magicstring!", "Magicjordan!")
-
- args := os.Args
- defer func() { os.Args = args }()
-
- os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--name", name, "--dev"}
- go kamelRun.Execute()
-
- Eventually(logScanner.IsFound(`integration "`+name+`" in phase Running`), TestTimeoutMedium).Should(BeTrue())
- Eventually(logScanner.IsFound("Magicstring!"), TestTimeoutMedium).Should(BeTrue())
- Expect(logScanner.IsFound("Magicjordan!")()).To(BeFalse())
-
- util.ReplaceInFile(t, file, "string!", "jordan!")
- Eventually(logScanner.IsFound("Magicjordan!"), TestTimeoutMedium).Should(BeTrue())
- })
+ WithNewTestNamespace(t, func(ns string) {
+ /*
+ * TODO
+ * The changing of the yaml file constant from "string" to "magic" is not being
+ * picked up when deploying on OCP4 and so the test is failing.
+ *
+ * Adding CAMEL_K_TEST_SKIP_PROBLEMATIC env var for the moment.
+ */
+ if os.Getenv("CAMEL_K_TEST_SKIP_PROBLEMATIC") == "true" {
+ t.Skip("WARNING: Test marked as problematic ... skipping")
+ }
+
+ t.Run("run yaml dev mode", func(t *testing.T) {
+ RegisterTestingT(t)
+ ctx, cancel := context.WithCancel(TestContext)
+ defer cancel()
+ piper, pipew := io.Pipe()
+ defer pipew.Close()
+ defer piper.Close()
- t.Run("run yaml remote dev mode", func(t *testing.T) {
- RegisterTestingT(t)
- ctx, cancel := context.WithCancel(TestContext)
- defer cancel()
- piper, pipew := io.Pipe()
- defer pipew.Close()
- defer piper.Close()
+ file := util.MakeTempCopy(t, "files/yaml.yaml")
+ name := RandomizedSuffixName("yaml")
- remoteFile := "https://raw.githubusercontent.com/apache/camel-k/b29333f0a878d5d09fb3965be8fe586d77dd95d0/e2e/common/files/yaml.yaml"
- name := RandomizedSuffixName("yaml")
- kamelRun := KamelRunWithContext(ctx, operatorID, ns, remoteFile, "--name", name, "--dev")
- kamelRun.SetOut(pipew)
+ kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, "--name", name, "--dev")
+ kamelRun.SetOut(pipew)
- logScanner := util.NewLogScanner(ctx, piper, "Magicstring!")
+ logScanner := util.NewLogScanner(ctx, piper, `integration "`+name+`" in phase Running`, "Magicstring!", "Magicjordan!")
- args := os.Args
- defer func() { os.Args = args }()
+ args := os.Args
+ defer func() { os.Args = args }()
- os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, remoteFile, "--name", name, "--dev"}
+ os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--name", name, "--dev"}
+ go kamelRun.Execute()
- go kamelRun.Execute()
+ Eventually(logScanner.IsFound(`integration "`+name+`" in phase Running`), TestTimeoutMedium).Should(BeTrue())
+ Eventually(logScanner.IsFound("Magicstring!"), TestTimeoutMedium).Should(BeTrue())
+ Expect(logScanner.IsFound("Magicjordan!")()).To(BeFalse())
- Eventually(logScanner.IsFound("Magicstring!"), TestTimeoutMedium).Should(BeTrue())
- })
+ util.ReplaceInFile(t, file, "string!", "jordan!")
+ Eventually(logScanner.IsFound("Magicjordan!"), TestTimeoutMedium).Should(BeTrue())
+ })
- // This test makes sure that `kamel run --dev` runs in seconds after initial build is
- // already done for the same integration.
- t.Run("dev mode rebuild in seconds", func(t *testing.T) {
- /*
- * !!! NOTE !!!
- * If you find this test flaky, instead of thinking it as simply unstable, investigate
- * why it does not finish in a few seconds and remove the bottlenecks which are lagging
- * the integration startup.
- */
- RegisterTestingT(t)
- name := RandomizedSuffixName("yaml")
+ t.Run("run yaml remote dev mode", func(t *testing.T) {
+ RegisterTestingT(t)
+ ctx, cancel := context.WithCancel(TestContext)
+ defer cancel()
+ piper, pipew := io.Pipe()
+ defer pipew.Close()
+ defer piper.Close()
- // First run (warm up)
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name)).Should(BeNil())
- Eventually(IntegrationPod(ns, name), TestTimeoutMedium).Should(BeNil())
+ remoteFile := "https://raw.githubusercontent.com/apache/camel-k/b29333f0a878d5d09fb3965be8fe586d77dd95d0/e2e/common/files/yaml.yaml"
+ name := RandomizedSuffixName("yaml")
+ kamelRun := KamelRunWithContext(ctx, operatorID, ns, remoteFile, "--name", name, "--dev")
+ kamelRun.SetOut(pipew)
- // Second run (rebuild)
- ctx, cancel := context.WithCancel(TestContext)
- defer cancel()
- piper, pipew := io.Pipe()
- defer pipew.Close()
- defer piper.Close()
+ logScanner := util.NewLogScanner(ctx, piper, "Magicstring!")
- file := util.MakeTempCopy(t, "files/yaml.yaml")
+ args := os.Args
+ defer func() { os.Args = args }()
- kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, "--name", name, "--dev")
- kamelRun.SetOut(pipew)
+ os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, remoteFile, "--name", name, "--dev"}
- logScanner := util.NewLogScanner(ctx, piper, `integration "`+name+`" in phase Running`, "Magicstring!")
+ go kamelRun.Execute()
- args := os.Args
- defer func() { os.Args = args }()
+ Eventually(logScanner.IsFound("Magicstring!"), TestTimeoutMedium).Should(BeTrue())
+ })
- os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--name", name, "--dev"}
+ // This test makes sure that `kamel run --dev` runs in seconds after initial build is
+ // already done for the same integration.
+ t.Run("dev mode rebuild in seconds", func(t *testing.T) {
+ /*
+ * !!! NOTE !!!
+ * If you find this test flaky, instead of thinking it as simply unstable, investigate
+ * why it does not finish in a few seconds and remove the bottlenecks which are lagging
+ * the integration startup.
+ */
+ RegisterTestingT(t)
+ name := RandomizedSuffixName("yaml")
- go kamelRun.Execute()
+ // First run (warm up)
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name)).Should(BeNil())
+ Eventually(IntegrationPod(ns, name), TestTimeoutMedium).Should(BeNil())
- // Second run should start up within a few seconds
- timeout := 10 * time.Second
- Eventually(logScanner.IsFound(`integration "`+name+`" in phase Running`), timeout).Should(BeTrue())
- Eventually(logScanner.IsFound("Magicstring!"), timeout).Should(BeTrue())
- })
+ // Second run (rebuild)
+ ctx, cancel := context.WithCancel(TestContext)
+ defer cancel()
+ piper, pipew := io.Pipe()
+ defer pipew.Close()
+ defer piper.Close()
+
+ file := util.MakeTempCopy(t, "files/yaml.yaml")
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, "--name", name, "--dev")
+ kamelRun.SetOut(pipew)
+
+ logScanner := util.NewLogScanner(ctx, piper, `integration "`+name+`" in phase Running`, "Magicstring!")
+
+ args := os.Args
+ defer func() { os.Args = args }()
+
+ os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--name", name, "--dev"}
+
+ go kamelRun.Execute()
+
+ // Second run should start up within a few seconds
+ timeout := 10 * time.Second
+ Eventually(logScanner.IsFound(`integration "`+name+`" in phase Running`), timeout).Should(BeTrue())
+ Eventually(logScanner.IsFound("Magicstring!"), timeout).Should(BeTrue())
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/cli/get_test.go b/e2e/common/cli/get_test.go
index e1a461b3b..88cdffda2 100644
--- a/e2e/common/cli/get_test.go
+++ b/e2e/common/cli/get_test.go
@@ -34,42 +34,46 @@ import (
)
func TestKamelCLIGet(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("get integration", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- // regex is used for the compatibility of tests between OC and vanilla K8
- // kamel get may have different output depending on the platform
- Eventually(IntegrationKit(ns, "yaml")).ShouldNot(Equal(""))
- kitName := IntegrationKit(ns, "yaml")()
- regex := fmt.Sprintf("^NAME\tPHASE\tKIT\n\\s*yaml\tRunning\t(%s/%s|%s)", ns, kitName, kitName)
- Expect(GetOutputString(Kamel("get", "-n", ns))).To(MatchRegexp(regex))
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("get integration", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ // regex is used for the compatibility of tests between OC and vanilla K8
+ // kamel get may have different output depending on the platform
+ Eventually(IntegrationKit(ns, "yaml")).ShouldNot(Equal(""))
+ kitName := IntegrationKit(ns, "yaml")()
+ kitNamespace := IntegrationKitNamespace(ns, "yaml")()
+ regex := fmt.Sprintf("^NAME\tPHASE\tKIT\n\\s*yaml\tRunning\t(%s/%s|%s)", kitNamespace, kitName, kitName)
+ Expect(GetOutputString(Kamel("get", "-n", ns))).To(MatchRegexp(regex))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("get several integrations", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+ Eventually(IntegrationKit(ns, "java")).ShouldNot(Equal(""))
+ Eventually(IntegrationKit(ns, "yaml")).ShouldNot(Equal(""))
+ kitName1 := IntegrationKit(ns, "java")()
+ kitName2 := IntegrationKit(ns, "yaml")()
+ kitNamespace1 := IntegrationKitNamespace(ns, "java")()
+ kitNamespace2 := IntegrationKitNamespace(ns, "yaml")()
+ regex := fmt.Sprintf("^NAME\tPHASE\tKIT\n\\s*java\tRunning\t"+
+ "(%s/%s|%s)\n\\s*yaml\tRunning\t(%s/%s|%s)\n", kitNamespace1, kitName1, kitName1, kitNamespace2, kitName2, kitName2)
+ Expect(GetOutputString(Kamel("get", "-n", ns))).To(MatchRegexp(regex))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("get no integrations", func(t *testing.T) {
+ Expect(GetOutputString(Kamel("get", "-n", ns))).NotTo(ContainSubstring("Running"))
+ Expect(GetOutputString(Kamel("get", "-n", ns))).NotTo(ContainSubstring("Building Kit"))
+ })
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- t.Run("get several integrations", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- Eventually(IntegrationKit(ns, "java")).ShouldNot(Equal(""))
- Eventually(IntegrationKit(ns, "yaml")).ShouldNot(Equal(""))
- kitName1 := IntegrationKit(ns, "java")()
- kitName2 := IntegrationKit(ns, "yaml")()
- regex := fmt.Sprintf("^NAME\tPHASE\tKIT\n\\s*java\tRunning\t"+
- "(%s/%s|%s)\n\\s*yaml\tRunning\t(%s/%s|%s)\n", ns, kitName1, kitName1, ns, kitName2, kitName2)
- Expect(GetOutputString(Kamel("get", "-n", ns))).To(MatchRegexp(regex))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("get no integrations", func(t *testing.T) {
- Expect(GetOutputString(Kamel("get", "-n", ns))).NotTo(ContainSubstring("Running"))
- Expect(GetOutputString(Kamel("get", "-n", ns))).NotTo(ContainSubstring("Building Kit"))
- })
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/cli/log_test.go b/e2e/common/cli/log_test.go
index 3396948db..093872822 100644
--- a/e2e/common/cli/log_test.go
+++ b/e2e/common/cli/log_test.go
@@ -32,24 +32,26 @@ import (
)
func TestKamelCLILog(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("check integration log", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", "log-yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "log-yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- // first line of the integration logs
- firstLine := strings.Split(IntegrationLogs(ns, "log-yaml")(), "\n")[0]
- podName := IntegrationPod(ns, "log-yaml")().Name
-
- logsCLI := GetOutputStringAsync(Kamel("log", "log-yaml", "-n", ns))
- Eventually(logsCLI).Should(ContainSubstring("Monitoring pod " + podName))
- Eventually(logsCLI).Should(ContainSubstring(firstLine))
-
- logs := strings.Split(IntegrationLogs(ns, "log-yaml")(), "\n")
- lastLine := logs[len(logs)-1]
-
- logsCLI = GetOutputStringAsync(Kamel("log", "log-yaml", "-n", ns, "--tail", "5"))
- Eventually(logsCLI).Should(ContainSubstring("Monitoring pod " + podName))
- Eventually(logsCLI).Should(ContainSubstring(lastLine))
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("check integration log", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", "log-yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "log-yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ // first line of the integration logs
+ firstLine := strings.Split(IntegrationLogs(ns, "log-yaml")(), "\n")[0]
+ podName := IntegrationPod(ns, "log-yaml")().Name
+
+ logsCLI := GetOutputStringAsync(Kamel("log", "log-yaml", "-n", ns))
+ Eventually(logsCLI).Should(ContainSubstring("Monitoring pod " + podName))
+ Eventually(logsCLI).Should(ContainSubstring(firstLine))
+
+ logs := strings.Split(IntegrationLogs(ns, "log-yaml")(), "\n")
+ lastLine := logs[len(logs)-1]
+
+ logsCLI = GetOutputStringAsync(Kamel("log", "log-yaml", "-n", ns, "--tail", "5"))
+ Eventually(logsCLI).Should(ContainSubstring("Monitoring pod " + podName))
+ Eventually(logsCLI).Should(ContainSubstring(lastLine))
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
}
diff --git a/e2e/common/cli/run_test.go b/e2e/common/cli/run_test.go
index 81ccbd330..692b4a20f 100644
--- a/e2e/common/cli/run_test.go
+++ b/e2e/common/cli/run_test.go
@@ -39,183 +39,196 @@ import (
var sampleJar = "https://raw.githubusercontent.com/apache/camel-k/main/e2e/common/traits/files/jvm/sample-1.0.jar"
func TestKamelCLIRun(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Examples from GitHub", func(t *testing.T) {
- t.Run("Java", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns,
- "github:apache/camel-k-examples/generic-examples/languages/Sample.java").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "sample"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "sample", v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "sample"), TestTimeoutShort).Should(ContainSubstring("Hello Camel K!"))
- Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
- })
-
- t.Run("Java (RAW)", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns,
- "https://raw.githubusercontent.com/apache/camel-k-examples/main/generic-examples/languages/Sample.java").Execute()).
- To(Succeed())
- Eventually(IntegrationPodPhase(ns, "sample"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "sample", v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "sample"), TestTimeoutShort).Should(ContainSubstring("Hello Camel K!"))
- Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
- })
-
- t.Run("Java (branch)", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns,
- "github:apache/camel-k-examples/generic-examples/languages/Sample.java?branch=main").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "sample"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "sample", v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "sample"), TestTimeoutShort).Should(ContainSubstring("Hello Camel K!"))
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Examples from GitHub", func(t *testing.T) {
+ t.Run("Java", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns,
+ "github:apache/camel-k-examples/generic-examples/languages/Sample.java").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "sample"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "sample", v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "sample"), TestTimeoutShort).Should(ContainSubstring("Hello Camel K!"))
+ Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ })
+
+ t.Run("Java (RAW)", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns,
+ "https://raw.githubusercontent.com/apache/camel-k-examples/main/generic-examples/languages/Sample.java").Execute()).
+ To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "sample"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "sample", v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "sample"), TestTimeoutShort).Should(ContainSubstring("Hello Camel K!"))
+ Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ })
+
+ t.Run("Java (branch)", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns,
+ "github:apache/camel-k-examples/generic-examples/languages/Sample.java?branch=main").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "sample"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "sample", v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "sample"), TestTimeoutShort).Should(ContainSubstring("Hello Camel K!"))
+ Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ })
+
+ // GIST does not like GITHUB_TOKEN apparently, we must temporarily remove it
+ os.Setenv("GITHUB_TOKEN_TMP", os.Getenv("GITHUB_TOKEN"))
+ os.Unsetenv("GITHUB_TOKEN")
+
+ t.Run("Gist (ID)", func(t *testing.T) {
+ name := RandomizedSuffixName("github-gist-id")
+ Expect(KamelRunWithID(operatorID, ns, "--name", name,
+ "gist:e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!"))
+ Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ })
+
+ t.Run("Gist (URL)", func(t *testing.T) {
+ name := RandomizedSuffixName("github-gist-url")
+ Expect(KamelRunWithID(operatorID, ns, "--name", name,
+ "https://gist.github.com/lburgazzoli/e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!"))
+ Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ })
+
+ // Revert GITHUB TOKEN
+ os.Setenv("GITHUB_TOKEN", os.Getenv("GITHUB_TOKEN_TMP"))
+ os.Unsetenv("GITHUB_TOKEN_TMP")
+
+ // Clean up
Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
})
- // GIST does not like GITHUB_TOKEN apparently, we must temporary remove it
- os.Setenv("GITHUB_TOKEN_TMP", os.Getenv("GITHUB_TOKEN"))
- os.Unsetenv("GITHUB_TOKEN")
-
- t.Run("Gist (ID)", func(t *testing.T) {
- name := RandomizedSuffixName("github-gist-id")
- Expect(KamelRunWithID(operatorID, ns, "--name", name,
- "gist:e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!"))
- Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
- })
-
- t.Run("Gist (URL)", func(t *testing.T) {
- name := RandomizedSuffixName("github-gist-url")
- Expect(KamelRunWithID(operatorID, ns, "--name", name,
- "https://gist.github.com/lburgazzoli/e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
+ t.Run("Run and update", func(t *testing.T) {
+ name := RandomizedSuffixName("run")
+ Expect(KamelRunWithID(operatorID, ns, "files/run.yaml", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!"))
- Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
- })
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magic default"))
- // Revert GITHUB TOKEN
- os.Setenv("GITHUB_TOKEN", os.Getenv("GITHUB_TOKEN_TMP"))
- os.Unsetenv("GITHUB_TOKEN_TMP")
+ // Re-run the Integration with an updated configuration
+ Expect(KamelRunWithID(operatorID, ns, "files/run.yaml", "--name", name, "-p", "property=value").Execute()).
+ To(Succeed())
- // Clean up
- Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
- })
+ // Check the Deployment has progressed successfully
+ Eventually(DeploymentCondition(ns, name, appsv1.DeploymentProgressing), TestTimeoutShort).
+ Should(MatchFields(IgnoreExtras, Fields{
+ "Status": Equal(corev1.ConditionTrue),
+ "Reason": Equal("NewReplicaSetAvailable"),
+ }))
- t.Run("Run and update", func(t *testing.T) {
- name := RandomizedSuffixName("run")
- Expect(KamelRunWithID(operatorID, ns, "files/run.yaml", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magic default"))
-
- // Re-run the Integration with an updated configuration
- Expect(KamelRunWithID(operatorID, ns, "files/run.yaml", "--name", name, "-p", "property=value").Execute()).
- To(Succeed())
-
- // Check the Deployment has progressed successfully
- Eventually(DeploymentCondition(ns, name, appsv1.DeploymentProgressing), TestTimeoutShort).
- Should(MatchFields(IgnoreExtras, Fields{
- "Status": Equal(corev1.ConditionTrue),
- "Reason": Equal("NewReplicaSetAvailable"),
- }))
-
- // Check the new configuration is taken into account
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magic value"))
-
- // Clean up
- Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
- })
-
- t.Run("Run with glob patterns", func(t *testing.T) {
- t.Run("YAML", func(t *testing.T) {
- name := RandomizedSuffixName("run")
- Expect(KamelRunWithID(operatorID, ns, "files/glob/run*", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ // Check the new configuration is taken into account
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello run 1 default"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello run 2 default"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magic value"))
+
+ // Clean up
Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
})
- t.Run("Java", func(t *testing.T) {
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/glob/Java*", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello java 1 default"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello java 2 default"))
+ t.Run("Run with glob patterns", func(t *testing.T) {
+ t.Run("YAML", func(t *testing.T) {
+ name := RandomizedSuffixName("run")
+ Expect(KamelRunWithID(operatorID, ns, "files/glob/run*", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello run 1 default"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello run 2 default"))
+ Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ })
+
+ t.Run("Java", func(t *testing.T) {
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/glob/Java*", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello java 1 default"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello java 2 default"))
+ Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ })
+
+ t.Run("All", func(t *testing.T) {
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/glob/*", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello run 1 default"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello run 2 default"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello java 1 default"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello java 2 default"))
+ Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ })
+
+ // Clean up
Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
})
+ })
- t.Run("All", func(t *testing.T) {
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/glob/*", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello run 1 default"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello run 2 default"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello java 1 default"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Hello java 2 default"))
+ WithNewTestNamespace(t, func(ns string) {
+ /*
+ * TODO
+ * The dependency cannot be read by maven while building. See #3708
+ *
+ * Adding CAMEL_K_TEST_SKIP_PROBLEMATIC env var for the moment.
+ */
+ t.Run("Run with http dependency", func(t *testing.T) {
+ if os.Getenv("CAMEL_K_TEST_SKIP_PROBLEMATIC") == "true" {
+ t.Skip("WARNING: Test marked as problematic ... skipping")
+ }
+ // Requires a local integration platform in order to resolve the insecure registry
+ // Install platform (use the installer to get staging if present)
+ Expect(KamelInstallWithID("local-platform", ns, "--skip-operator-setup").Execute()).To(Succeed())
+
+ Expect(KamelRunWithID(operatorID, ns, "../traits/files/jvm/Classpath.java",
+ "-d", sampleJar,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
})
-
- // Clean up
- Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
})
- /*
- * TODO
- * The dependency cannot be read by maven while building. See #3708
- *
- * Adding CAMEL_K_TEST_SKIP_PROBLEMATIC env var for the moment.
- */
- t.Run("Run with http dependency", func(t *testing.T) {
- if os.Getenv("CAMEL_K_TEST_SKIP_PROBLEMATIC") == "true" {
- t.Skip("WARNING: Test marked as problematic ... skipping")
- }
- Expect(KamelRunWithID(operatorID, ns, "../traits/files/jvm/Classpath.java",
- "-d", sampleJar,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
- Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
- })
+ WithNewTestNamespace(t, func(ns string) {
+ /*
+ * TODO
+ * The dependency cannot be read by maven while building. See #3708
+ *
+ * Adding CAMEL_K_TEST_SKIP_PROBLEMATIC env var for the moment.
+ */
+ t.Run("Run with http dependency using options", func(t *testing.T) {
+ if os.Getenv("CAMEL_K_TEST_SKIP_PROBLEMATIC") == "true" {
+ t.Skip("WARNING: Test marked as problematic ... skipping")
+ }
+ // Requires a local integration platform in order to resolve the insecure registry
+ // Install platform (use the installer to get staging if present)
+ Expect(KamelInstallWithID("local-platform", ns, "--skip-operator-setup").Execute()).To(Succeed())
+
+ Expect(KamelRunWithID(operatorID, ns, "../traits/files/jvm/Classpath.java",
+ "-d", sampleJar,
+ "-d", "https://raw.githubusercontent.com/apache/camel-k-examples/main/generic-examples/languages/Sample.java|targetPath=/tmp/foo",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
+ Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ })
- /*
- * TODO
- * The dependency cannot be read by maven while building. See #3708
- *
- * Adding CAMEL_K_TEST_SKIP_PROBLEMATIC env var for the moment.
- */
- t.Run("Run with http dependency using options", func(t *testing.T) {
- if os.Getenv("CAMEL_K_TEST_SKIP_PROBLEMATIC") == "true" {
- t.Skip("WARNING: Test marked as problematic ... skipping")
- }
- Expect(KamelRunWithID(operatorID, ns, "../traits/files/jvm/Classpath.java",
- "-d", sampleJar,
- "-d", "https://raw.githubusercontent.com/apache/camel-k-examples/main/generic-examples/languages/Sample.java|targetPath=/tmp/foo",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
- Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/config/config_reload_test.go b/e2e/common/config/config_reload_test.go
index 94a18a86b..b8e3dd33b 100644
--- a/e2e/common/config/config_reload_test.go
+++ b/e2e/common/config/config_reload_test.go
@@ -35,86 +35,89 @@ import (
)
func TestConfigmapHotReload(t *testing.T) {
- RegisterTestingT(t)
-
- name := RandomizedSuffixName("config-configmap-route")
-
- var cmData = make(map[string]string)
- cmData["my-configmap-key"] = "my configmap content"
- CreatePlainTextConfigmapWithLabels(ns, "my-hot-cm", cmData, map[string]string{"camel.apache.org/integration": "test"})
-
- Expect(KamelRunWithID(operatorID, ns,
- "./files/config-configmap-route.groovy",
- "--config",
- "configmap:my-hot-cm",
- "-t",
- "mount.hot-reload=true",
- "--name",
- name,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("my configmap content"))
-
- cmData["my-configmap-key"] = "my configmap content updated"
- UpdatePlainTextConfigmapWithLabels(ns, "my-hot-cm", cmData, map[string]string{"camel.apache.org/integration": "test"})
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("my configmap content updated"))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+
+ name := RandomizedSuffixName("config-configmap-route")
+
+ var cmData = make(map[string]string)
+ cmData["my-configmap-key"] = "my configmap content"
+ CreatePlainTextConfigmapWithLabels(ns, "my-hot-cm", cmData, map[string]string{"camel.apache.org/integration": "test"})
+
+ Expect(KamelRunWithID(operatorID, ns,
+ "./files/config-configmap-route.groovy",
+ "--config",
+ "configmap:my-hot-cm",
+ "-t",
+ "mount.hot-reload=true",
+ "--name",
+ name,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("my configmap content"))
+
+ cmData["my-configmap-key"] = "my configmap content updated"
+ UpdatePlainTextConfigmapWithLabels(ns, "my-hot-cm", cmData, map[string]string{"camel.apache.org/integration": "test"})
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("my configmap content updated"))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func TestConfigmapHotReloadDefault(t *testing.T) {
- RegisterTestingT(t)
-
- name := RandomizedSuffixName("config-configmap-route")
-
- var cmData = make(map[string]string)
- cmData["my-configmap-key"] = "my configmap content"
- CreatePlainTextConfigmapWithLabels(ns, "my-hot-cm-2", cmData, map[string]string{"camel.apache.org/integration": "test"})
-
- Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-route.groovy",
- "--config",
- "configmap:my-hot-cm-2",
- "--name",
- name,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("my configmap content"))
-
- cmData["my-configmap-key"] = "my configmap content updated"
- UpdatePlainTextConfigmapWithLabels(ns, "my-hot-cm-2", cmData, map[string]string{"camel.apache.org/integration": "test"})
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(Not(ContainSubstring("my configmap content updated")))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+
+ name := RandomizedSuffixName("config-configmap-route")
+
+ var cmData = make(map[string]string)
+ cmData["my-configmap-key"] = "my configmap content"
+ CreatePlainTextConfigmapWithLabels(ns, "my-hot-cm-2", cmData, map[string]string{"camel.apache.org/integration": "test"})
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-route.groovy",
+ "--config",
+ "configmap:my-hot-cm-2",
+ "--name",
+ name,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("my configmap content"))
+
+ cmData["my-configmap-key"] = "my configmap content updated"
+ UpdatePlainTextConfigmapWithLabels(ns, "my-hot-cm-2", cmData, map[string]string{"camel.apache.org/integration": "test"})
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(Not(ContainSubstring("my configmap content updated")))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func TestSecretHotReload(t *testing.T) {
- RegisterTestingT(t)
-
- name := RandomizedSuffixName("config-secret-route")
-
- var secData = make(map[string]string)
- secData["my-secret-key"] = "very top secret"
- CreatePlainTextSecretWithLabels(ns, "my-hot-sec", secData, map[string]string{"camel.apache.org/integration": "test"})
-
- Expect(KamelRunWithID(operatorID, ns, "./files/config-secret-route.groovy",
- "--config",
- "secret:my-hot-sec",
- "-t",
- "mount.hot-reload=true",
- "--name",
- name,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("very top secret"))
-
- secData["my-secret-key"] = "very top secret updated"
- UpdatePlainTextSecretWithLabels(ns, "my-hot-sec", secData, map[string]string{"camel.apache.org/integration": "test"})
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("very top secret updated"))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+
+ name := RandomizedSuffixName("config-secret-route")
+
+ var secData = make(map[string]string)
+ secData["my-secret-key"] = "very top secret"
+ CreatePlainTextSecretWithLabels(ns, "my-hot-sec", secData, map[string]string{"camel.apache.org/integration": "test"})
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-secret-route.groovy",
+ "--config",
+ "secret:my-hot-sec",
+ "-t",
+ "mount.hot-reload=true",
+ "--name",
+ name,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("very top secret"))
+
+ secData["my-secret-key"] = "very top secret updated"
+ UpdatePlainTextSecretWithLabels(ns, "my-hot-sec", secData, map[string]string{"camel.apache.org/integration": "test"})
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("very top secret updated"))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func TestConfigmapWithOwnerRefHotReloadDefault(t *testing.T) {
@@ -126,31 +129,32 @@ func TestConfigmapWithOwnerRefHotReload(t *testing.T) {
}
func CheckConfigmapWithOwnerRef(t *testing.T, hotreload bool) {
- RegisterTestingT(t)
- name := RandomizedSuffixName("config-configmap-route")
- cmName := RandomizedSuffixName("my-hot-cm-")
- Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-route.groovy",
- "--config",
- "configmap:"+cmName,
- "--name",
- name,
- "-t",
- "mount.hot-reload="+strconv.FormatBool(hotreload),
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
- var cmData = make(map[string]string)
- cmData["my-configmap-key"] = "my configmap content"
- CreatePlainTextConfigmapWithOwnerRefWithLabels(ns, cmName, cmData, name, Integration(ns, name)().UID, map[string]string{"camel.apache.org/integration": "test"})
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name), TestTimeoutLong).Should(ContainSubstring("my configmap content"))
- cmData["my-configmap-key"] = "my configmap content updated"
- UpdatePlainTextConfigmapWithLabels(ns, cmName, cmData, map[string]string{"camel.apache.org/integration": "test"})
- if hotreload {
- Eventually(IntegrationLogs(ns, name), TestTimeoutLong).Should(ContainSubstring("my configmap content updated"))
- } else {
- Eventually(IntegrationLogs(ns, name), TestTimeoutLong).Should(Not(ContainSubstring("my configmap content updated")))
- }
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- DeleteConfigmap(ns, cmName)
+ WithNewTestNamespace(t, func(ns string) {
+
+ name := RandomizedSuffixName("config-configmap-route")
+ cmName := RandomizedSuffixName("my-hot-cm-")
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-route.groovy",
+ "--config",
+ "configmap:"+cmName,
+ "--name",
+ name,
+ "-t",
+ "mount.hot-reload="+strconv.FormatBool(hotreload),
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
+ var cmData = make(map[string]string)
+ cmData["my-configmap-key"] = "my configmap content"
+ CreatePlainTextConfigmapWithOwnerRefWithLabels(ns, cmName, cmData, name, Integration(ns, name)().UID, map[string]string{"camel.apache.org/integration": "test"})
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutLong).Should(ContainSubstring("my configmap content"))
+ cmData["my-configmap-key"] = "my configmap content updated"
+ UpdatePlainTextConfigmapWithLabels(ns, cmName, cmData, map[string]string{"camel.apache.org/integration": "test"})
+ if hotreload {
+ Eventually(IntegrationLogs(ns, name), TestTimeoutLong).Should(ContainSubstring("my configmap content updated"))
+ } else {
+ Eventually(IntegrationLogs(ns, name), TestTimeoutLong).Should(Not(ContainSubstring("my configmap content updated")))
+ }
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/config/config_test.go b/e2e/common/config/config_test.go
index ef178e3c9..a799063e5 100644
--- a/e2e/common/config/config_test.go
+++ b/e2e/common/config/config_test.go
@@ -35,303 +35,291 @@ import (
)
func TestRunConfigExamples(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Simple property", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "my.message=test-property").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("test-property"))
- Expect(Kamel("delete", "property-route", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Property file", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/property-file-route.groovy", "--property", "file:./files/my.properties").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
- Expect(Kamel("delete", "property-file-route", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Property precedence", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/property-file-route.groovy", "-p", "my.key.2=universe", "-p", "file:./files/my.properties").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello universe"))
- Expect(Kamel("delete", "property-file-route", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Property from ConfigMap", func(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Simple property", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "my.message=test-property").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("test-property"))
+ Expect(Kamel("delete", "property-route", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Property file", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-file-route.groovy", "--property", "file:./files/my.properties").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
+ Expect(Kamel("delete", "property-file-route", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Property precedence", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-file-route.groovy", "-p", "my.key.2=universe", "-p", "file:./files/my.properties").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello universe"))
+ Expect(Kamel("delete", "property-file-route", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Property from ConfigMap", func(t *testing.T) {
+ var cmData = make(map[string]string)
+ cmData["my.message"] = "my-configmap-property-value"
+ CreatePlainTextConfigmap(ns, "my-cm-test-property", cmData)
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "configmap:my-cm-test-property").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-configmap-property-value"))
+ Expect(Kamel("delete", "property-route", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Property from ConfigMap as property file", func(t *testing.T) {
+ var cmData = make(map[string]string)
+ cmData["my.properties"] = "my.message=my-configmap-property-entry"
+ CreatePlainTextConfigmap(ns, "my-cm-test-properties", cmData)
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "configmap:my-cm-test-properties").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-configmap-property-entry"))
+ Expect(Kamel("delete", "property-route", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Property from Secret", func(t *testing.T) {
+ var secData = make(map[string]string)
+ secData["my.message"] = "my-secret-property-value"
+ CreatePlainTextSecret(ns, "my-sec-test-property", secData)
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "secret:my-sec-test-property").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-secret-property-value"))
+ Expect(Kamel("delete", "property-route", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Property from Secret as property file", func(t *testing.T) {
+ var secData = make(map[string]string)
+ secData["my.properties"] = "my.message=my-secret-property-entry"
+ CreatePlainTextSecret(ns, "my-sec-test-properties", secData)
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "secret:my-sec-test-properties").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-secret-property-entry"))
+ })
+
+ t.Run("Property from Secret inlined", func(t *testing.T) {
+ var secData = make(map[string]string)
+ secData["my-message"] = "my-secret-external-value"
+ CreatePlainTextSecret(ns, "my-sec-inlined", secData)
+
+ // TODO: remove jvm.options trait as soon as CAMEL-20054 gets fixed
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-secret-route.groovy",
+ "-t", "mount.configs=secret:my-sec-inlined",
+ "-t", "jvm.options=-Dcamel.k.mount-path.secrets=/etc/camel/conf.d/_secrets",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "property-secret-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "property-secret-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "property-secret-route"), TestTimeoutShort).Should(ContainSubstring("my-secret-external-value"))
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, "property-secret-route")).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, "property-secret-route")()
+ mountTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "mount")
+ Expect(mountTrait).ToNot(BeNil())
+ Expect(len(mountTrait)).To(Equal(1))
+ Expect(mountTrait["configs"]).ToNot(BeNil())
+
+ Expect(Kamel("delete", "property-secret-route", "-n", ns).Execute()).To(Succeed())
+
+ })
+
+ // Configmap
+
+ // Store a configmap on the cluster
var cmData = make(map[string]string)
- cmData["my.message"] = "my-configmap-property-value"
- CreatePlainTextConfigmap(ns, "my-cm-test-property", cmData)
-
- Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "configmap:my-cm-test-property").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-configmap-property-value"))
- Expect(Kamel("delete", "property-route", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Property from ConfigMap as property file", func(t *testing.T) {
- var cmData = make(map[string]string)
- cmData["my.properties"] = "my.message=my-configmap-property-entry"
- CreatePlainTextConfigmap(ns, "my-cm-test-properties", cmData)
-
- Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "configmap:my-cm-test-properties").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-configmap-property-entry"))
- Expect(Kamel("delete", "property-route", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Property from Secret", func(t *testing.T) {
+ cmData["my-configmap-key"] = "my-configmap-content"
+ CreatePlainTextConfigmap(ns, "my-cm", cmData)
+
+ // Store a configmap with multiple values
+ var cmDataMulti = make(map[string]string)
+ cmDataMulti["my-configmap-key"] = "should-not-see-it"
+ cmDataMulti["my-configmap-key-2"] = "my-configmap-content-2"
+ CreatePlainTextConfigmap(ns, "my-cm-multi", cmDataMulti)
+
+ t.Run("Config configmap", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-route.groovy", "--config", "configmap:my-cm").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "config-configmap-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "config-configmap-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "config-configmap-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
+ })
+
+ t.Run("Resource configmap", func(t *testing.T) {
+ // We can reuse the configmap created previously
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-configmap-route.groovy", "--resource", "configmap:my-cm").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "resource-configmap-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "resource-configmap-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "resource-configmap-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
+ })
+
+ t.Run("Resource configmap with destination", func(t *testing.T) {
+ // We can reuse the configmap created previously
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-configmap-location-route.groovy", "--resource", "configmap:my-cm@/tmp/app").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "resource-configmap-location-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "resource-configmap-location-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "resource-configmap-location-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
+ })
+
+ t.Run("Resource configmap with filtered key and destination", func(t *testing.T) {
+ // We'll use the configmap contaning 2 values filtering only 1 key
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-configmap-key-location-route.groovy", "--resource", "configmap:my-cm-multi/my-configmap-key-2@/tmp/app/test.txt").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "resource-configmap-key-location-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "resource-configmap-key-location-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "resource-configmap-key-location-route"), TestTimeoutShort).ShouldNot(ContainSubstring(cmDataMulti["my-configmap-key"]))
+ Eventually(IntegrationLogs(ns, "resource-configmap-key-location-route"), TestTimeoutShort).Should(ContainSubstring(cmDataMulti["my-configmap-key-2"]))
+ })
+
+ // Store a configmap as property file
+ var cmDataProps = make(map[string]string)
+ cmDataProps["my.properties"] = "my.key.1=hello\nmy.key.2=world"
+ CreatePlainTextConfigmap(ns, "my-cm-properties", cmDataProps)
+
+ t.Run("Config configmap as property file", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-properties-route.groovy", "--config", "configmap:my-cm-properties").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "config-configmap-properties-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "config-configmap-properties-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "config-configmap-properties-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
+ })
+
+ // Secret
+
+ // Store a secret on the cluster
var secData = make(map[string]string)
- secData["my.message"] = "my-secret-property-value"
- CreatePlainTextSecret(ns, "my-sec-test-property", secData)
-
- Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "secret:my-sec-test-property").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-secret-property-value"))
- Expect(Kamel("delete", "property-route", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Property from Secret as property file", func(t *testing.T) {
- var secData = make(map[string]string)
- secData["my.properties"] = "my.message=my-secret-property-entry"
- CreatePlainTextSecret(ns, "my-sec-test-properties", secData)
-
- Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "secret:my-sec-test-properties").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-secret-property-entry"))
- })
-
- t.Run("Property from Secret inlined", func(t *testing.T) {
- var secData = make(map[string]string)
- secData["my-message"] = "my-secret-external-value"
- CreatePlainTextSecret(ns, "my-sec-inlined", secData)
-
- // TODO: remove jvm.options trait as soon as CAMEL-20054 gets fixed
- Expect(KamelRunWithID(operatorID, ns, "./files/property-secret-route.groovy",
- "-t", "mount.configs=secret:my-sec-inlined",
- "-t", "jvm.options=-Dcamel.k.mount-path.secrets=/etc/camel/conf.d/_secrets",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "property-secret-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "property-secret-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "property-secret-route"), TestTimeoutShort).Should(ContainSubstring("my-secret-external-value"))
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, "property-secret-route")).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, "property-secret-route")()
- mountTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "mount")
- Expect(mountTrait).ToNot(BeNil())
- Expect(len(mountTrait)).To(Equal(1))
- Expect(mountTrait["configs"]).ToNot(BeNil())
-
- Expect(Kamel("delete", "property-secret-route", "-n", ns).Execute()).To(Succeed())
-
- })
-
- // Configmap
-
- // Store a configmap on the cluster
- var cmData = make(map[string]string)
- cmData["my-configmap-key"] = "my-configmap-content"
- CreatePlainTextConfigmap(ns, "my-cm", cmData)
-
- // Store a configmap with multiple values
- var cmDataMulti = make(map[string]string)
- cmDataMulti["my-configmap-key"] = "should-not-see-it"
- cmDataMulti["my-configmap-key-2"] = "my-configmap-content-2"
- CreatePlainTextConfigmap(ns, "my-cm-multi", cmDataMulti)
-
- t.Run("Config configmap", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-route.groovy", "--config", "configmap:my-cm").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "config-configmap-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "config-configmap-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "config-configmap-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
- })
-
- t.Run("Resource configmap", func(t *testing.T) {
- // We can reuse the configmap created previously
-
- Expect(KamelRunWithID(operatorID, ns, "./files/resource-configmap-route.groovy", "--resource", "configmap:my-cm").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "resource-configmap-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "resource-configmap-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "resource-configmap-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
- })
-
- t.Run("Resource configmap with destination", func(t *testing.T) {
- // We can reuse the configmap created previously
-
- Expect(KamelRunWithID(operatorID, ns, "./files/resource-configmap-location-route.groovy", "--resource", "configmap:my-cm@/tmp/app").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "resource-configmap-location-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "resource-configmap-location-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "resource-configmap-location-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
- })
-
- t.Run("Resource configmap with filtered key and destination", func(t *testing.T) {
- // We'll use the configmap contaning 2 values filtering only 1 key
-
- Expect(KamelRunWithID(operatorID, ns, "./files/resource-configmap-key-location-route.groovy", "--resource", "configmap:my-cm-multi/my-configmap-key-2@/tmp/app/test.txt").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "resource-configmap-key-location-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "resource-configmap-key-location-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "resource-configmap-key-location-route"), TestTimeoutShort).ShouldNot(ContainSubstring(cmDataMulti["my-configmap-key"]))
- Eventually(IntegrationLogs(ns, "resource-configmap-key-location-route"), TestTimeoutShort).Should(ContainSubstring(cmDataMulti["my-configmap-key-2"]))
- })
-
- // Store a configmap as property file
- var cmDataProps = make(map[string]string)
- cmDataProps["my.properties"] = "my.key.1=hello\nmy.key.2=world"
- CreatePlainTextConfigmap(ns, "my-cm-properties", cmDataProps)
-
- t.Run("Config configmap as property file", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-properties-route.groovy", "--config", "configmap:my-cm-properties").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "config-configmap-properties-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "config-configmap-properties-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "config-configmap-properties-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
- })
+ secData["my-secret-key"] = "very top secret"
+ CreatePlainTextSecret(ns, "my-sec", secData)
+
+ // Store a secret with multi values
+ var secDataMulti = make(map[string]string)
+ secDataMulti["my-secret-key"] = "very top secret"
+ secDataMulti["my-secret-key-2"] = "even more secret"
+ CreatePlainTextSecret(ns, "my-sec-multi", secDataMulti)
+
+ t.Run("Config secret", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-secret-route.groovy", "--config", "secret:my-sec").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "config-secret-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "config-secret-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "config-secret-route"), TestTimeoutShort).Should(ContainSubstring(secData["my-secret-key"]))
+ })
+
+ t.Run("Resource secret", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-secret-route.groovy", "--resource", "secret:my-sec").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "resource-secret-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "resource-secret-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "resource-secret-route"), TestTimeoutShort).Should(ContainSubstring(secData["my-secret-key"]))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Secret with filtered key", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-secret-key-route.groovy", "--config", "secret:my-sec-multi/my-secret-key-2").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "config-secret-key-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "config-secret-key-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "config-secret-key-route"), TestTimeoutShort).ShouldNot(ContainSubstring(secDataMulti["my-secret-key"]))
+ Eventually(IntegrationLogs(ns, "config-secret-key-route"), TestTimeoutShort).Should(ContainSubstring(secDataMulti["my-secret-key-2"]))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ // Build-Properties
+ t.Run("Build time property", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-route.groovy", "--build-property", "quarkus.application.name=my-super-application").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "build-property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "build-property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "build-property-route"), TestTimeoutShort).Should(ContainSubstring("my-super-application"))
+ // Don't delete - we need it for next test execution
+ })
+
+ // We need to check also that the property (which is available in the IntegrationKit) is correctly replaced and we don't reuse the same kit
+ t.Run("Build time property updated", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-route.groovy", "--name", "build-property-route-updated",
+ "--build-property", "quarkus.application.name=my-super-application-updated").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "build-property-route-updated"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "build-property-route-updated", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "build-property-route-updated"), TestTimeoutShort).Should(ContainSubstring("my-super-application-updated"))
+ // Verify the integration kits are different
+ Eventually(IntegrationKit(ns, "build-property-route-updated")).ShouldNot(Equal(IntegrationKit(ns, "build-property-route")()))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ // Build-Properties file
+ t.Run("Build time property file", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "file:./files/quarkus.properties").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-super-application"))
+ Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Build time property file with precedence", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "quarkus.application.name=my-overridden-application", "--build-property", "file:./files/quarkus.properties").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutMedium).Should(ContainSubstring("my-overridden-application"))
+ Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Build time property from ConfigMap", func(t *testing.T) {
+ var cmData = make(map[string]string)
+ cmData["quarkus.application.name"] = "my-cool-application"
+ CreatePlainTextConfigmap(ns, "my-cm-test-build-property", cmData)
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "configmap:my-cm-test-build-property").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutLong).Should(ContainSubstring("my-cool-application"))
+ Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Build time property from ConfigMap as property file", func(t *testing.T) {
+ var cmData = make(map[string]string)
+ cmData["my.properties"] = "quarkus.application.name=my-super-cool-application"
+ CreatePlainTextConfigmap(ns, "my-cm-test-build-properties", cmData)
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "configmap:my-cm-test-build-properties").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-super-cool-application"))
+ Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
+
+ })
+
+ t.Run("Build time property from Secret", func(t *testing.T) {
+ var secData = make(map[string]string)
+ secData["quarkus.application.name"] = "my-great-application"
+ CreatePlainTextSecret(ns, "my-sec-test-build-property", secData)
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "secret:my-sec-test-build-property").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-great-application"))
+ Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
+
+ })
+
+ t.Run("Build time property from Secret as property file", func(t *testing.T) {
+ var secData = make(map[string]string)
+ secData["my.properties"] = "quarkus.application.name=my-awsome-application"
+ CreatePlainTextSecret(ns, "my-sec-test-build-properties", secData)
+
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "secret:my-sec-test-build-properties").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-awsome-application"))
+ Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
+
+ })
- // Secret
-
- // Store a secret on the cluster
- var secData = make(map[string]string)
- secData["my-secret-key"] = "very top secret"
- CreatePlainTextSecret(ns, "my-sec", secData)
-
- // Store a secret with multi values
- var secDataMulti = make(map[string]string)
- secDataMulti["my-secret-key"] = "very top secret"
- secDataMulti["my-secret-key-2"] = "even more secret"
- CreatePlainTextSecret(ns, "my-sec-multi", secDataMulti)
-
- t.Run("Config secret", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/config-secret-route.groovy", "--config", "secret:my-sec").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "config-secret-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "config-secret-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "config-secret-route"), TestTimeoutShort).Should(ContainSubstring(secData["my-secret-key"]))
- })
-
- t.Run("Resource secret", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/resource-secret-route.groovy", "--resource", "secret:my-sec").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "resource-secret-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "resource-secret-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "resource-secret-route"), TestTimeoutShort).Should(ContainSubstring(secData["my-secret-key"]))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Secret with filtered key", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/config-secret-key-route.groovy", "--config", "secret:my-sec-multi/my-secret-key-2").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "config-secret-key-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "config-secret-key-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "config-secret-key-route"), TestTimeoutShort).ShouldNot(ContainSubstring(secDataMulti["my-secret-key"]))
- Eventually(IntegrationLogs(ns, "config-secret-key-route"), TestTimeoutShort).Should(ContainSubstring(secDataMulti["my-secret-key-2"]))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- // Build-Properties
- t.Run("Build time property", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/build-property-route.groovy", "--build-property", "quarkus.application.name=my-super-application").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "build-property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "build-property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "build-property-route"), TestTimeoutShort).Should(ContainSubstring("my-super-application"))
- // Don't delete - we need it for next test execution
- })
-
- // We need to check also that the property (which is available in the IntegrationKit) is correctly replaced and we don't reuse the same kit
- t.Run("Build time property updated", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/build-property-route.groovy", "--name", "build-property-route-updated",
- "--build-property", "quarkus.application.name=my-super-application-updated").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "build-property-route-updated"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "build-property-route-updated", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "build-property-route-updated"), TestTimeoutShort).Should(ContainSubstring("my-super-application-updated"))
- // Verify the integration kits are different
- Eventually(IntegrationKit(ns, "build-property-route-updated")).ShouldNot(Equal(IntegrationKit(ns, "build-property-route")()))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- // Build-Properties file
- t.Run("Build time property file", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "file:./files/quarkus.properties").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-super-application"))
- Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Build time property file with precedence", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "quarkus.application.name=my-overridden-application", "--build-property", "file:./files/quarkus.properties").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutMedium).Should(ContainSubstring("my-overridden-application"))
- Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Build time property from ConfigMap", func(t *testing.T) {
- var cmData = make(map[string]string)
- cmData["quarkus.application.name"] = "my-cool-application"
- CreatePlainTextConfigmap(ns, "my-cm-test-build-property", cmData)
-
- Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "configmap:my-cm-test-build-property").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutLong).Should(ContainSubstring("my-cool-application"))
- Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Build time property from ConfigMap as property file", func(t *testing.T) {
- var cmData = make(map[string]string)
- cmData["my.properties"] = "quarkus.application.name=my-super-cool-application"
- CreatePlainTextConfigmap(ns, "my-cm-test-build-properties", cmData)
-
- Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "configmap:my-cm-test-build-properties").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-super-cool-application"))
- Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
-
- })
-
- t.Run("Build time property from Secret", func(t *testing.T) {
- var secData = make(map[string]string)
- secData["quarkus.application.name"] = "my-great-application"
- CreatePlainTextSecret(ns, "my-sec-test-build-property", secData)
-
- Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "secret:my-sec-test-build-property").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-great-application"))
- Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
-
- })
-
- t.Run("Build time property from Secret as property file", func(t *testing.T) {
- var secData = make(map[string]string)
- secData["my.properties"] = "quarkus.application.name=my-awsome-application"
- CreatePlainTextSecret(ns, "my-sec-test-build-properties", secData)
-
- Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "secret:my-sec-test-build-properties").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-awsome-application"))
- Expect(Kamel("delete", "build-property-file-route", "-n", ns).Execute()).To(Succeed())
-
- })
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- Expect(DeleteConfigmap(ns, "my-cm")).To(Succeed())
- Expect(DeleteConfigmap(ns, "my-cm-multi")).To(Succeed())
- Expect(DeleteConfigmap(ns, "my-cm-properties")).To(Succeed())
- Expect(DeleteConfigmap(ns, "my-cm-test-build-property")).To(Succeed())
- Expect(DeleteConfigmap(ns, "my-cm-test-build-properties")).To(Succeed())
- Expect(DeleteConfigmap(ns, "my-cm-test-property")).To(Succeed())
- Expect(DeleteConfigmap(ns, "my-cm-test-properties")).To(Succeed())
- Expect(DeleteSecret(ns, "my-sec-test-build-property")).To(Succeed())
- Expect(DeleteSecret(ns, "my-sec-test-build-properties")).To(Succeed())
- Expect(DeleteSecret(ns, "my-sec-test-property")).To(Succeed())
- Expect(DeleteSecret(ns, "my-sec-test-properties")).To(Succeed())
- Expect(DeleteSecret(ns, "my-sec")).To(Succeed())
- Expect(DeleteSecret(ns, "my-sec-multi")).To(Succeed())
}
diff --git a/e2e/common/config/default.go b/e2e/common/config/default.go
index 4a5ced9e0..13e78b4f1 100644
--- a/e2e/common/config/default.go
+++ b/e2e/common/config/default.go
@@ -20,7 +20,10 @@ limitations under the License.
package config
-import "github.com/apache/camel-k/v2/e2e/support"
+import (
+ "github.com/apache/camel-k/v2/e2e/support"
+ "github.com/apache/camel-k/v2/pkg/platform"
+)
-var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.GetCIProcessID())
-var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", support.GetCIProcessID())
+var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.TestDefaultNamespace)
+var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", platform.DefaultPlatformName)
diff --git a/e2e/common/config/kamelet_config_test.go b/e2e/common/config/kamelet_config_test.go
index 0ef8ec99e..931300bdc 100644
--- a/e2e/common/config/kamelet_config_test.go
+++ b/e2e/common/config/kamelet_config_test.go
@@ -35,260 +35,259 @@ import (
//
// without having to change the integration code.
func TestKameletImplicitConfigDefaultUserPropery(t *testing.T) {
- RegisterTestingT(t)
- t.Run("run test default config using properties", func(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("run test default config using properties", func(t *testing.T) {
- Expect(CreateTimerKamelet(ns, "iconfig01-timer-source")()).To(Succeed())
+ Expect(CreateTimerKamelet(ns, "iconfig01-timer-source")()).To(Succeed())
- name := RandomizedSuffixName("iconfig-test-timer-source-int01")
- Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration01.java",
- "-p", "camel.kamelet.iconfig01-timer-source.message='Default message 01'",
- "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("Default message 01"))
+ name := RandomizedSuffixName("iconfig-test-timer-source-int01")
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration01.java",
+ "-p", "camel.kamelet.iconfig01-timer-source.message='Default message 01'",
+ "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("Default message 01"))
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
- Expect(DeleteKamelet(ns, "iconfig01-timer-source")).To(Succeed())
- })
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteKamelet(ns, "iconfig01-timer-source")).To(Succeed())
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func TestKameletImplicitConfigDefaultMountedSecret(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("run test default config using mounted secret", func(t *testing.T) {
+ t.Run("run test default config using mounted secret", func(t *testing.T) {
- Expect(CreateTimerKamelet(ns, "iconfig03-timer-source")()).To(Succeed())
+ Expect(CreateTimerKamelet(ns, "iconfig03-timer-source")()).To(Succeed())
- name := RandomizedSuffixName("iconfig-test-timer-source-int3")
- secretName := "my-iconfig-int3-secret"
+ name := RandomizedSuffixName("iconfig-test-timer-source-int3")
+ secretName := "my-iconfig-int3-secret"
- var secData = make(map[string]string)
- secData["camel.kamelet.iconfig03-timer-source.message"] = "very top mounted secret message"
- Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
- Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(Not(BeNil()))
+ var secData = make(map[string]string)
+ secData["camel.kamelet.iconfig03-timer-source.message"] = "very top mounted secret message"
+ Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
+ Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(Not(BeNil()))
- Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration03.java",
- "-t", "mount.configs=secret:"+secretName,
- "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top mounted secret message"))
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration03.java",
+ "-t", "mount.configs=secret:"+secretName,
+ "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top mounted secret message"))
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
- Expect(DeleteSecret(ns, secretName)).To(Succeed())
- Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(BeNil())
- Expect(DeleteKamelet(ns, "iconfig03-timer-source")).To(Succeed())
- })
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteSecret(ns, secretName)).To(Succeed())
+ Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteKamelet(ns, "iconfig03-timer-source")).To(Succeed())
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func TestKameletImplicitConfigDefaultMountedConfigmap(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("run test default config using mounted configmap", func(t *testing.T) {
+ t.Run("run test default config using mounted configmap", func(t *testing.T) {
- Expect(CreateTimerKamelet(ns, "iconfig04-timer-source")()).To(Succeed())
+ Expect(CreateTimerKamelet(ns, "iconfig04-timer-source")()).To(Succeed())
- name := RandomizedSuffixName("iconfig-test-timer-source-int4")
- cmName := "my-iconfig-int4-configmap"
+ name := RandomizedSuffixName("iconfig-test-timer-source-int4")
+ cmName := "my-iconfig-int4-configmap"
- var cmData = make(map[string]string)
- cmData["camel.kamelet.iconfig04-timer-source.message"] = "very top mounted configmap message"
- Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
+ var cmData = make(map[string]string)
+ cmData["camel.kamelet.iconfig04-timer-source.message"] = "very top mounted configmap message"
+ Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
- Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration04.java",
- "-t", "mount.configs=configmap:"+cmName,
- "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top mounted configmap message"))
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration04.java",
+ "-t", "mount.configs=configmap:"+cmName,
+ "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top mounted configmap message"))
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
- Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
- Expect(DeleteKamelet(ns, "iconfig04-timer-source")).To(Succeed())
- })
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
+ Expect(DeleteKamelet(ns, "iconfig04-timer-source")).To(Succeed())
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func TestKameletImplicitConfigNamedUserPropery(t *testing.T) {
- RegisterTestingT(t)
- t.Run("run test named config using properties", func(t *testing.T) {
-
- Expect(CreateTimerKamelet(ns, "iconfig05-timer-source")()).To(Succeed())
-
- name := RandomizedSuffixName("iconfig-test-timer-source-int5")
- Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration05.java",
- "-p", "camel.kamelet.iconfig05-timer-source.message='Default message 05'",
- "-p", "camel.kamelet.iconfig05-timer-source.mynamedconfig.message='My Named Config message'",
- "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My Named Config message"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
- Expect(DeleteKamelet(ns, "iconfig05-timer-source")).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("run test named config using properties", func(t *testing.T) {
+ Expect(CreateTimerKamelet(ns, "iconfig05-timer-source")()).To(Succeed())
+
+ name := RandomizedSuffixName("iconfig-test-timer-source-int5")
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration05.java",
+ "-p", "camel.kamelet.iconfig05-timer-source.message='Default message 05'",
+ "-p", "camel.kamelet.iconfig05-timer-source.mynamedconfig.message='My Named Config message'",
+ "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My Named Config message"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteKamelet(ns, "iconfig05-timer-source")).To(Succeed())
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
func TestKameletImplicitConfigNamedLabeledSecret(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("run test named config using labeled secret", func(t *testing.T) {
-
- Expect(CreateTimerKamelet(ns, "iconfig06-timer-source")()).To(Succeed())
-
- name := RandomizedSuffixName("iconfig-test-timer-source-int6")
- secretName := "my-iconfig-int6-secret"
-
- var secData = make(map[string]string)
- secData["camel.kamelet.iconfig06-timer-source.mynamedconfig.message"] = "very top named secret message"
- var labels = make(map[string]string)
- labels["camel.apache.org/kamelet"] = "iconfig06-timer-source"
- labels["camel.apache.org/kamelet.configuration"] = "mynamedconfig"
- Expect(CreatePlainTextSecretWithLabels(ns, secretName, secData, labels)).To(Succeed())
- Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(Not(BeNil()))
-
- Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration06.java",
- "-p", "camel.kamelet.iconfig06-timer-source.message='Default message 06'",
- "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top named secret message"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
- Expect(DeleteSecret(ns, secretName)).To(Succeed())
- Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(BeNil())
- Expect(DeleteKamelet(ns, "iconfig06-timer-source")).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("run test named config using labeled secret", func(t *testing.T) {
+ Expect(CreateTimerKamelet(ns, "iconfig06-timer-source")()).To(Succeed())
+
+ name := RandomizedSuffixName("iconfig-test-timer-source-int6")
+ secretName := "my-iconfig-int6-secret"
+
+ var secData = make(map[string]string)
+ secData["camel.kamelet.iconfig06-timer-source.mynamedconfig.message"] = "very top named secret message"
+ var labels = make(map[string]string)
+ labels["camel.apache.org/kamelet"] = "iconfig06-timer-source"
+ labels["camel.apache.org/kamelet.configuration"] = "mynamedconfig"
+ Expect(CreatePlainTextSecretWithLabels(ns, secretName, secData, labels)).To(Succeed())
+ Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(Not(BeNil()))
+
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration06.java",
+ "-p", "camel.kamelet.iconfig06-timer-source.message='Default message 06'",
+ "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top named secret message"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteSecret(ns, secretName)).To(Succeed())
+ Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteKamelet(ns, "iconfig06-timer-source")).To(Succeed())
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
func TestKameletImplicitConfigNamedMountedSecret(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("run test named config using mounted secret", func(t *testing.T) {
-
- Expect(CreateTimerKamelet(ns, "iconfig07-timer-source")()).To(Succeed())
-
- name := RandomizedSuffixName("iconfig-test-timer-source-int7")
- secretName := "my-iconfig-int7-secret"
-
- var secData = make(map[string]string)
- secData["camel.kamelet.iconfig07-timer-source.mynamedconfig.message"] = "very top named mounted secret message"
- Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
- Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(Not(BeNil()))
-
- Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration07.java",
- "-p", "camel.kamelet.iconfig07-timer-source.message='Default message 07'",
- "-t", "mount.configs=secret:"+secretName,
- "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top named mounted secret message"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
- Expect(DeleteSecret(ns, secretName)).To(Succeed())
- Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(BeNil())
- Expect(DeleteKamelet(ns, "iconfig07-timer-source")).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("run test named config using mounted secret", func(t *testing.T) {
+ Expect(CreateTimerKamelet(ns, "iconfig07-timer-source")()).To(Succeed())
+
+ name := RandomizedSuffixName("iconfig-test-timer-source-int7")
+ secretName := "my-iconfig-int7-secret"
+
+ var secData = make(map[string]string)
+ secData["camel.kamelet.iconfig07-timer-source.mynamedconfig.message"] = "very top named mounted secret message"
+ Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
+ Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(Not(BeNil()))
+
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration07.java",
+ "-p", "camel.kamelet.iconfig07-timer-source.message='Default message 07'",
+ "-t", "mount.configs=secret:"+secretName,
+ "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top named mounted secret message"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteSecret(ns, secretName)).To(Succeed())
+ Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteKamelet(ns, "iconfig07-timer-source")).To(Succeed())
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
func TestKameletImplicitConfigNamedMountedConfigmap(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("run test named config using mounted configmap", func(t *testing.T) {
-
- Expect(CreateTimerKamelet(ns, "iconfig08-timer-source")()).To(Succeed())
-
- name := RandomizedSuffixName("iconfig-test-timer-source-int8")
- cmName := "my-iconfig-int8-configmap"
-
- var cmData = make(map[string]string)
- cmData["camel.kamelet.iconfig08-timer-source.mynamedconfig.message"] = "very top named mounted configmap message"
- Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
-
- Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration08.java",
- "-p", "camel.kamelet.iconfig08-timer-source.message='Default message 08'",
- "-t", "mount.configs=configmap:"+cmName,
- "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top named mounted configmap message"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
- Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
- Expect(DeleteKamelet(ns, "iconfig08-timer-source")).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("run test named config using mounted configmap", func(t *testing.T) {
+ Expect(CreateTimerKamelet(ns, "iconfig08-timer-source")()).To(Succeed())
+
+ name := RandomizedSuffixName("iconfig-test-timer-source-int8")
+ cmName := "my-iconfig-int8-configmap"
+
+ var cmData = make(map[string]string)
+ cmData["camel.kamelet.iconfig08-timer-source.mynamedconfig.message"] = "very top named mounted configmap message"
+ Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
+
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration08.java",
+ "-p", "camel.kamelet.iconfig08-timer-source.message='Default message 08'",
+ "-t", "mount.configs=configmap:"+cmName,
+ "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top named mounted configmap message"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
+ Expect(DeleteKamelet(ns, "iconfig08-timer-source")).To(Succeed())
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
func TestKameletImplicitConfigDefaultLabeledSecret(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("run test default config using labeled secret", func(t *testing.T) {
-
- Expect(CreateTimerKamelet(ns, "iconfig09-timer-source")()).To(Succeed())
-
- name := RandomizedSuffixName("iconfig-test-timer-source-int9")
- secretName := "my-iconfig-int9-secret"
-
- var secData = make(map[string]string)
- secData["camel.kamelet.iconfig09-timer-source.message"] = "very top labeled secret message"
- var labels = make(map[string]string)
- labels["camel.apache.org/kamelet"] = "iconfig09-timer-source"
- Expect(CreatePlainTextSecretWithLabels(ns, secretName, secData, labels)).To(Succeed())
- Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(Not(BeNil()))
-
- Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration09.java",
- "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top labeled secret message"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
- Expect(DeleteSecret(ns, secretName)).To(Succeed())
- Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(BeNil())
- Expect(DeleteKamelet(ns, "iconfig09-timer-source")).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("run test default config using labeled secret", func(t *testing.T) {
+ Expect(CreateTimerKamelet(ns, "iconfig09-timer-source")()).To(Succeed())
+
+ name := RandomizedSuffixName("iconfig-test-timer-source-int9")
+ secretName := "my-iconfig-int9-secret"
+
+ var secData = make(map[string]string)
+ secData["camel.kamelet.iconfig09-timer-source.message"] = "very top labeled secret message"
+ var labels = make(map[string]string)
+ labels["camel.apache.org/kamelet"] = "iconfig09-timer-source"
+ Expect(CreatePlainTextSecretWithLabels(ns, secretName, secData, labels)).To(Succeed())
+ Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(Not(BeNil()))
+
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration09.java",
+ "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top labeled secret message"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteSecret(ns, secretName)).To(Succeed())
+ Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteKamelet(ns, "iconfig09-timer-source")).To(Succeed())
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
// Tests on integration with kamelets containing configuration from properties and secrets with parameters inside the integration.
func TestKameletConfigInlinedUserPropery(t *testing.T) {
- RegisterTestingT(t)
- t.Run("run test default config inlined properties", func(t *testing.T) {
-
- Expect(CreateTimerKamelet(ns, "config01-timer-source")()).To(Succeed())
- Expect(CreateLogKamelet(ns, "config01-log-sink")()).To(Succeed())
-
- name := RandomizedSuffixName("config-test-timer-source-int1")
-
- Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-inlined-configuration-01.yaml",
- "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("important message"))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("integrationLogger"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
- Expect(DeleteKamelet(ns, "config01-timer-source")).To(Succeed())
- Expect(DeleteKamelet(ns, "config01-log-sink")).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("run test default config inlined properties", func(t *testing.T) {
+ Expect(CreateTimerKamelet(ns, "config01-timer-source")()).To(Succeed())
+ Expect(CreateLogKamelet(ns, "config01-log-sink")()).To(Succeed())
+
+ name := RandomizedSuffixName("config-test-timer-source-int1")
+
+ Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-inlined-configuration-01.yaml",
+ "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("important message"))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("integrationLogger"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ Expect(DeleteKamelet(ns, "config01-timer-source")).To(Succeed())
+ Expect(DeleteKamelet(ns, "config01-log-sink")).To(Succeed())
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
func TestKameletConfigDefaultParamUserPropery(t *testing.T) {
diff --git a/e2e/common/config/pipe_config_test.go b/e2e/common/config/pipe_config_test.go
index caf93ece9..49ff9b444 100644
--- a/e2e/common/config/pipe_config_test.go
+++ b/e2e/common/config/pipe_config_test.go
@@ -33,201 +33,200 @@ import (
// Tests on pipe with kamelets containing configuration from properties and secrets.
func TestPipeConfig(t *testing.T) {
- RegisterTestingT(t)
- t.Run("test custom source/sink pipe", func(t *testing.T) {
- Expect(CreateTimerKamelet(ns, "my-pipe-timer-source")()).To(Succeed())
- Expect(CreateLogKamelet(ns, "my-pipe-log-sink")()).To(Succeed())
- t.Run("run test default config using properties", func(t *testing.T) {
- name := RandomizedSuffixName("my-pipe-with-properties")
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-pipe-timer-source",
- "my-pipe-log-sink",
- "-p", "source.message=My pipe message",
- "-p", "sink.loggerName=myPipeLogger",
- "--name", name,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe message"))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeLogger"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+ t.Run("test custom source/sink pipe", func(t *testing.T) {
+ Expect(CreateTimerKamelet(ns, "my-pipe-timer-source")()).To(Succeed())
+ Expect(CreateLogKamelet(ns, "my-pipe-log-sink")()).To(Succeed())
+ t.Run("run test default config using properties", func(t *testing.T) {
+ name := RandomizedSuffixName("my-pipe-with-properties")
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-pipe-timer-source",
+ "my-pipe-log-sink",
+ "-p", "source.message=My pipe message",
+ "-p", "sink.loggerName=myPipeLogger",
+ "--name", name,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe message"))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeLogger"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("run test implicit default config using labeled secret", func(t *testing.T) {
+ name := RandomizedSuffixName("my-pipe-with-default-implicit-secret")
+ secretName := "my-pipe-default-implicit-secret"
+
+ var secData = make(map[string]string)
+ secData["camel.kamelet.my-pipe-timer-source.message"] = "My pipe secret message"
+ var labels = make(map[string]string)
+ labels["camel.apache.org/kamelet"] = "my-pipe-timer-source"
+ Expect(CreatePlainTextSecretWithLabels(ns, secretName, secData, labels)).To(Succeed())
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-pipe-timer-source",
+ "my-pipe-log-sink",
+ "-p", "sink.loggerName=myDefaultLogger",
+ "--name", name,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe secret message"))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myDefaultLogger"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Expect(DeleteSecret(ns, secretName)).To(Succeed())
+ })
+
+ t.Run("run test implicit default config using mounted secret", func(t *testing.T) {
+ name := RandomizedSuffixName("my-pipe-with-default-implicit-secret")
+ secretName := "my-pipe-default-implicit-secret"
+
+ var secData = make(map[string]string)
+ secData["camel.kamelet.my-pipe-timer-source.message"] = "My pipe secret message"
+ secData["camel.kamelet.my-pipe-log-sink.loggerName"] = "myPipeSecretLogger"
+ Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-pipe-timer-source",
+ "my-pipe-log-sink",
+ "-t", "mount.configs=secret:"+secretName,
+ "--name", name,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe secret message"))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeSecretLogger"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Expect(DeleteSecret(ns, secretName)).To(Succeed())
+ })
+
+ t.Run("run test implicit default config using mounted configmap", func(t *testing.T) {
+ name := RandomizedSuffixName("my-pipe-with-default-implicit-configmap")
+ cmName := "my-pipe-default-implicit-configmap"
+
+ var cmData = make(map[string]string)
+ cmData["camel.kamelet.my-pipe-timer-source.message"] = "My pipe configmap message"
+ cmData["camel.kamelet.my-pipe-log-sink.loggerName"] = "myPipeConfigmapLogger"
+ Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-pipe-timer-source",
+ "my-pipe-log-sink",
+ "-t", "mount.configs=configmap:"+cmName,
+ "--name", name,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe configmap message"))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeConfigmapLogger"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
+ })
+
+ t.Run("run test implicit named config using mounted secret", func(t *testing.T) {
+ name := RandomizedSuffixName("my-pipe-with-named-implicit-secret")
+ secretName := "my-pipe-named-implicit-secret"
+
+ var secData = make(map[string]string)
+ secData["camel.kamelet.my-pipe-timer-source.mynamedconfig.message"] = "My pipe named secret message"
+ secData["camel.kamelet.my-pipe-log-sink.mynamedconfig.loggerName"] = "myPipeNamedSecretLogger"
+ Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-pipe-timer-source",
+ "my-pipe-log-sink",
+ "-t", "mount.configs=secret:"+secretName,
+ "-p", "source.message={{mynamedconfig.message}}",
+ "-p", "sink.loggerName={{mynamedconfig.loggerName}}",
+ "--name", name,
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe named secret message"))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeNamedSecretLogger"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Expect(DeleteSecret(ns, secretName)).To(Succeed())
+ })
+
+ t.Run("run test implicit named config using mounted configmap", func(t *testing.T) {
+ name := RandomizedSuffixName("my-pipe-with-named-implicit-configmap")
+ cmName := "my-pipe-named-implicit-configmap"
+
+ var cmData = make(map[string]string)
+ cmData["camel.kamelet.my-pipe-timer-source.mynamedconfig.message"] = "My pipe named configmap message"
+ cmData["camel.kamelet.my-pipe-log-sink.mynamedconfig.loggerName"] = "myPipeNamedConfigmapLogger"
+ Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-pipe-timer-source",
+ "my-pipe-log-sink",
+ "-t", "mount.configs=configmap:"+cmName,
+ "-p", "source.message={{mynamedconfig.message}}",
+ "-p", "sink.loggerName={{mynamedconfig.loggerName}}",
+ "--name", name,
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe named configmap message"))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeNamedConfigmapLogger"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
+ })
+ t.Run("run test implicit specific config using mounted secret", func(t *testing.T) {
+ name := RandomizedSuffixName("my-pipe-with-specific-secret")
+ secretName := "my-pipe-specific-secret"
+
+ var secData = make(map[string]string)
+ secData["mynamedconfig.message"] = "My pipe specific secret message"
+ secData["mynamedconfig.loggerName"] = "myPipeSpecificSecretLogger"
+ Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-pipe-timer-source",
+ "my-pipe-log-sink",
+ "-t", "mount.configs=secret:"+secretName,
+ "-p", "source.message={{mynamedconfig.message}}",
+ "-p", "sink.loggerName={{mynamedconfig.loggerName}}",
+ "--name", name,
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe specific secret message"))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeSpecificSecretLogger"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Expect(DeleteSecret(ns, secretName)).To(Succeed())
+ })
+ t.Run("run test implicit specific config using mounted configmap", func(t *testing.T) {
+ name := RandomizedSuffixName("my-pipe-with-specific-configmap")
+ cmName := "my-pipe-specific-configmap"
+
+ var cmData = make(map[string]string)
+ cmData["mynamedconfig.message"] = "My pipe specific configmap message"
+ cmData["mynamedconfig.loggerName"] = "myPipeSpecificConfgmapLogger"
+ Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-pipe-timer-source",
+ "my-pipe-log-sink",
+ "-t", "mount.configs=configmap:"+cmName,
+ "-p", "source.message={{mynamedconfig.message}}",
+ "-p", "sink.loggerName={{mynamedconfig.loggerName}}",
+ "--name", name,
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe specific configmap message"))
+ Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeSpecificConfgmapLogger"))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
+ })
})
- t.Run("run test implicit default config using labeled secret", func(t *testing.T) {
- name := RandomizedSuffixName("my-pipe-with-default-implicit-secret")
- secretName := "my-pipe-default-implicit-secret"
-
- var secData = make(map[string]string)
- secData["camel.kamelet.my-pipe-timer-source.message"] = "My pipe secret message"
- var labels = make(map[string]string)
- labels["camel.apache.org/kamelet"] = "my-pipe-timer-source"
- Expect(CreatePlainTextSecretWithLabels(ns, secretName, secData, labels)).To(Succeed())
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-pipe-timer-source",
- "my-pipe-log-sink",
- "-p", "sink.loggerName=myDefaultLogger",
- "--name", name,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe secret message"))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myDefaultLogger"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Expect(DeleteSecret(ns, secretName)).To(Succeed())
- })
-
- t.Run("run test implicit default config using mounted secret", func(t *testing.T) {
- name := RandomizedSuffixName("my-pipe-with-default-implicit-secret")
- secretName := "my-pipe-default-implicit-secret"
-
- var secData = make(map[string]string)
- secData["camel.kamelet.my-pipe-timer-source.message"] = "My pipe secret message"
- secData["camel.kamelet.my-pipe-log-sink.loggerName"] = "myPipeSecretLogger"
- Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-pipe-timer-source",
- "my-pipe-log-sink",
- "-t", "mount.configs=secret:"+secretName,
- "--name", name,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe secret message"))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeSecretLogger"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Expect(DeleteSecret(ns, secretName)).To(Succeed())
- })
-
- t.Run("run test implicit default config using mounted configmap", func(t *testing.T) {
- name := RandomizedSuffixName("my-pipe-with-default-implicit-configmap")
- cmName := "my-pipe-default-implicit-configmap"
-
- var cmData = make(map[string]string)
- cmData["camel.kamelet.my-pipe-timer-source.message"] = "My pipe configmap message"
- cmData["camel.kamelet.my-pipe-log-sink.loggerName"] = "myPipeConfigmapLogger"
- Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-pipe-timer-source",
- "my-pipe-log-sink",
- "-t", "mount.configs=configmap:"+cmName,
- "--name", name,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe configmap message"))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeConfigmapLogger"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
- })
-
- t.Run("run test implicit named config using mounted secret", func(t *testing.T) {
- name := RandomizedSuffixName("my-pipe-with-named-implicit-secret")
- secretName := "my-pipe-named-implicit-secret"
-
- var secData = make(map[string]string)
- secData["camel.kamelet.my-pipe-timer-source.mynamedconfig.message"] = "My pipe named secret message"
- secData["camel.kamelet.my-pipe-log-sink.mynamedconfig.loggerName"] = "myPipeNamedSecretLogger"
- Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-pipe-timer-source",
- "my-pipe-log-sink",
- "-t", "mount.configs=secret:"+secretName,
- "-p", "source.message={{mynamedconfig.message}}",
- "-p", "sink.loggerName={{mynamedconfig.loggerName}}",
- "--name", name,
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe named secret message"))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeNamedSecretLogger"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Expect(DeleteSecret(ns, secretName)).To(Succeed())
- })
-
- t.Run("run test implicit named config using mounted configmap", func(t *testing.T) {
- name := RandomizedSuffixName("my-pipe-with-named-implicit-configmap")
- cmName := "my-pipe-named-implicit-configmap"
-
- var cmData = make(map[string]string)
- cmData["camel.kamelet.my-pipe-timer-source.mynamedconfig.message"] = "My pipe named configmap message"
- cmData["camel.kamelet.my-pipe-log-sink.mynamedconfig.loggerName"] = "myPipeNamedConfigmapLogger"
- Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-pipe-timer-source",
- "my-pipe-log-sink",
- "-t", "mount.configs=configmap:"+cmName,
- "-p", "source.message={{mynamedconfig.message}}",
- "-p", "sink.loggerName={{mynamedconfig.loggerName}}",
- "--name", name,
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe named configmap message"))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeNamedConfigmapLogger"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
- })
- t.Run("run test implicit specific config using mounted secret", func(t *testing.T) {
- name := RandomizedSuffixName("my-pipe-with-specific-secret")
- secretName := "my-pipe-specific-secret"
-
- var secData = make(map[string]string)
- secData["mynamedconfig.message"] = "My pipe specific secret message"
- secData["mynamedconfig.loggerName"] = "myPipeSpecificSecretLogger"
- Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-pipe-timer-source",
- "my-pipe-log-sink",
- "-t", "mount.configs=secret:"+secretName,
- "-p", "source.message={{mynamedconfig.message}}",
- "-p", "sink.loggerName={{mynamedconfig.loggerName}}",
- "--name", name,
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe specific secret message"))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeSpecificSecretLogger"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Expect(DeleteSecret(ns, secretName)).To(Succeed())
- })
- t.Run("run test implicit specific config using mounted configmap", func(t *testing.T) {
- name := RandomizedSuffixName("my-pipe-with-specific-configmap")
- cmName := "my-pipe-specific-configmap"
-
- var cmData = make(map[string]string)
- cmData["mynamedconfig.message"] = "My pipe specific configmap message"
- cmData["mynamedconfig.loggerName"] = "myPipeSpecificConfgmapLogger"
- Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-pipe-timer-source",
- "my-pipe-log-sink",
- "-t", "mount.configs=configmap:"+cmName,
- "-p", "source.message={{mynamedconfig.message}}",
- "-p", "sink.loggerName={{mynamedconfig.loggerName}}",
- "--name", name,
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My pipe specific configmap message"))
- Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myPipeSpecificConfgmapLogger"))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
- })
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- Expect(DeleteKamelet(ns, "my-pipe-timer-source")).To(Succeed())
- Expect(DeleteKamelet(ns, "my-pipe-log-sink")).To(Succeed())
}
diff --git a/e2e/common/languages/default.go b/e2e/common/languages/default.go
index 433ca1e6f..63569d2b2 100644
--- a/e2e/common/languages/default.go
+++ b/e2e/common/languages/default.go
@@ -20,7 +20,10 @@ limitations under the License.
package languages
-import "github.com/apache/camel-k/v2/e2e/support"
+import (
+ "github.com/apache/camel-k/v2/e2e/support"
+ "github.com/apache/camel-k/v2/pkg/platform"
+)
-var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.GetCIProcessID())
-var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", support.GetCIProcessID())
+var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.TestDefaultNamespace)
+var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", platform.DefaultPlatformName)
diff --git a/e2e/common/languages/groovy_test.go b/e2e/common/languages/groovy_test.go
index 253081bef..a86db06e7 100644
--- a/e2e/common/languages/groovy_test.go
+++ b/e2e/common/languages/groovy_test.go
@@ -34,14 +34,15 @@ import (
)
func TestRunSimpleGroovyExamples(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("run groovy", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/groovy.groovy").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "groovy"), TestTimeoutLong).Should(Equal(v1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "groovy", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "groovy"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- })
+ t.Run("run groovy", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/groovy.groovy").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "groovy"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "groovy", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "groovy"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/languages/java_test.go b/e2e/common/languages/java_test.go
index 903fd083b..c361bc072 100644
--- a/e2e/common/languages/java_test.go
+++ b/e2e/common/languages/java_test.go
@@ -34,14 +34,15 @@ import (
)
func TestRunSimpleJavaExamples(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("run java", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(v1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "java", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- })
+ t.Run("run java", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "java", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/languages/js_test.go b/e2e/common/languages/js_test.go
index 8bf0c4295..9cf92e27f 100644
--- a/e2e/common/languages/js_test.go
+++ b/e2e/common/languages/js_test.go
@@ -34,14 +34,15 @@ import (
)
func TestRunSimpleJavaScriptExamples(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("run js", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/js.js").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "js"), TestTimeoutLong).Should(Equal(v1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "js", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "js"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- })
+ t.Run("run js", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/js.js").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "js"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "js", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "js"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/languages/kotlin_test.go b/e2e/common/languages/kotlin_test.go
index da210afc2..e252fd0f0 100644
--- a/e2e/common/languages/kotlin_test.go
+++ b/e2e/common/languages/kotlin_test.go
@@ -34,14 +34,15 @@ import (
)
func TestRunSimpleKotlinExamples(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("run kotlin", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/kotlin.kts").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "kotlin"), TestTimeoutLong).Should(Equal(v1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "kotlin", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "kotlin"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- })
+ t.Run("run kotlin", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/kotlin.kts").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "kotlin"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "kotlin", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "kotlin"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/languages/polyglot_test.go b/e2e/common/languages/polyglot_test.go
index b441d4102..8009c9fc2 100644
--- a/e2e/common/languages/polyglot_test.go
+++ b/e2e/common/languages/polyglot_test.go
@@ -34,15 +34,16 @@ import (
)
func TestRunPolyglotExamples(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("run polyglot", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "--name", "polyglot", "files/js-polyglot.js", "files/yaml-polyglot.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "polyglot"), TestTimeoutLong).Should(Equal(v1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "polyglot", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-yaml"))
- Eventually(IntegrationLogs(ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-js"))
- })
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("run polyglot", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "--name", "polyglot", "files/js-polyglot.js", "files/yaml-polyglot.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "polyglot"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "polyglot", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-yaml"))
+ Eventually(IntegrationLogs(ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-js"))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/languages/xml_test.go b/e2e/common/languages/xml_test.go
index 1ea6f8dd5..4e5cc3ff7 100644
--- a/e2e/common/languages/xml_test.go
+++ b/e2e/common/languages/xml_test.go
@@ -34,14 +34,15 @@ import (
)
func TestRunSimpleXmlExamples(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("run xml", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/xml.xml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "xml"), TestTimeoutLong).Should(Equal(v1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "xml", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "xml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- })
+ t.Run("run xml", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/xml.xml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "xml"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "xml", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "xml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/languages/yaml_test.go b/e2e/common/languages/yaml_test.go
index 7e3dba1a4..82f150b21 100644
--- a/e2e/common/languages/yaml_test.go
+++ b/e2e/common/languages/yaml_test.go
@@ -34,14 +34,15 @@ import (
)
func TestRunSimpleYamlExamples(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("run yaml", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(v1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "yaml", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- })
+ t.Run("run yaml", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "yaml", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/misc/client_test.go b/e2e/common/misc/client_test.go
index 6c8a94366..5bddeac36 100644
--- a/e2e/common/misc/client_test.go
+++ b/e2e/common/misc/client_test.go
@@ -39,31 +39,32 @@ import (
)
func TestClientFunctionalities(t *testing.T) {
- RegisterTestingT(t)
-
- cfg, err := config.GetConfig()
- require.NoError(t, err)
- camel, err := versioned.NewForConfig(cfg)
- require.NoError(t, err)
-
- lst, err := camel.CamelV1().Integrations(ns).List(TestContext, metav1.ListOptions{})
- require.NoError(t, err)
- assert.Empty(t, lst.Items)
-
- integration, err := camel.CamelV1().Integrations(ns).Create(TestContext, &v1.Integration{
- ObjectMeta: metav1.ObjectMeta{
- Name: "dummy",
- },
- }, metav1.CreateOptions{})
- require.NoError(t, err)
-
- lst, err = camel.CamelV1().Integrations(ns).List(TestContext, metav1.ListOptions{})
- require.NoError(t, err)
- assert.NotEmpty(t, lst.Items)
- assert.Equal(t, lst.Items[0].Name, integration.Name)
-
- err = camel.CamelV1().Integrations(ns).Delete(TestContext, "dummy", metav1.DeleteOptions{})
- require.NoError(t, err)
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+
+ cfg, err := config.GetConfig()
+ require.NoError(t, err)
+ camel, err := versioned.NewForConfig(cfg)
+ require.NoError(t, err)
+
+ lst, err := camel.CamelV1().Integrations(ns).List(TestContext, metav1.ListOptions{})
+ require.NoError(t, err)
+ assert.Empty(t, lst.Items)
+
+ integration, err := camel.CamelV1().Integrations(ns).Create(TestContext, &v1.Integration{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "dummy",
+ },
+ }, metav1.CreateOptions{})
+ require.NoError(t, err)
+
+ lst, err = camel.CamelV1().Integrations(ns).List(TestContext, metav1.ListOptions{})
+ require.NoError(t, err)
+ assert.NotEmpty(t, lst.Items)
+ assert.Equal(t, lst.Items[0].Name, integration.Name)
+
+ err = camel.CamelV1().Integrations(ns).Delete(TestContext, "dummy", metav1.DeleteOptions{})
+ require.NoError(t, err)
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/misc/cron_test.go b/e2e/common/misc/cron_test.go
index 9368108c4..efcd0e948 100644
--- a/e2e/common/misc/cron_test.go
+++ b/e2e/common/misc/cron_test.go
@@ -34,42 +34,43 @@ import (
)
func TestRunCronExample(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("cron", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/cron.yaml").Execute()).To(Succeed())
- Eventually(IntegrationCronJob(ns, "cron"), TestTimeoutMedium).ShouldNot(BeNil())
- Eventually(IntegrationConditionStatus(ns, "cron", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "cron"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
- })
-
- t.Run("cron-yaml", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/cron-yaml.yaml").Execute()).To(Succeed())
- Eventually(IntegrationCronJob(ns, "cron-yaml"), TestTimeoutMedium).ShouldNot(BeNil())
- Eventually(IntegrationConditionStatus(ns, "cron-yaml", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "cron-yaml"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
- })
-
- t.Run("cron-timer", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/cron-timer.yaml").Execute()).To(Succeed())
- Eventually(IntegrationCronJob(ns, "cron-timer"), TestTimeoutMedium).ShouldNot(BeNil())
- Eventually(IntegrationConditionStatus(ns, "cron-timer", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "cron-timer"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("cron", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/cron.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationCronJob(ns, "cron"), TestTimeoutMedium).ShouldNot(BeNil())
+ Eventually(IntegrationConditionStatus(ns, "cron", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "cron"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
+ })
+
+ t.Run("cron-yaml", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/cron-yaml.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationCronJob(ns, "cron-yaml"), TestTimeoutMedium).ShouldNot(BeNil())
+ Eventually(IntegrationConditionStatus(ns, "cron-yaml", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "cron-yaml"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
+ })
+
+ t.Run("cron-timer", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/cron-timer.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationCronJob(ns, "cron-timer"), TestTimeoutMedium).ShouldNot(BeNil())
+ Eventually(IntegrationConditionStatus(ns, "cron-timer", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "cron-timer"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
+ })
+
+ t.Run("cron-fallback", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/cron-fallback.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "cron-fallback"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "cron-fallback", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "cron-fallback"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
+
+ t.Run("cron-quartz", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/cron-quartz.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "cron-quartz"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "cron-quartz", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "cron-quartz"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- t.Run("cron-fallback", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/cron-fallback.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "cron-fallback"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "cron-fallback", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "cron-fallback"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- })
-
- t.Run("cron-quartz", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/cron-quartz.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "cron-quartz"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "cron-quartz", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "cron-quartz"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- })
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/misc/default.go b/e2e/common/misc/default.go
index 76b897333..794d34d8e 100644
--- a/e2e/common/misc/default.go
+++ b/e2e/common/misc/default.go
@@ -20,7 +20,10 @@ limitations under the License.
package misc
-import "github.com/apache/camel-k/v2/e2e/support"
+import (
+ "github.com/apache/camel-k/v2/e2e/support"
+ "github.com/apache/camel-k/v2/pkg/platform"
+)
-var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.GetCIProcessID())
-var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", support.GetCIProcessID())
+var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.TestDefaultNamespace)
+var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", platform.DefaultPlatformName)
diff --git a/e2e/common/misc/integration_fail_test.go b/e2e/common/misc/integration_fail_test.go
index 58d98f6d1..4165358cf 100644
--- a/e2e/common/misc/integration_fail_test.go
+++ b/e2e/common/misc/integration_fail_test.go
@@ -35,151 +35,152 @@ import (
)
func TestBadRouteIntegration(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("run bad java route", func(t *testing.T) {
- name := RandomizedSuffixName("bad-route")
- Expect(KamelRunWithID(operatorID, ns, "files/BadRoute.java", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionFalse))
-
- // Make sure the Integration can be scaled
- Expect(ScaleIntegration(ns, name, 2)).To(Succeed())
- // Check the scale cascades into the Deployment scale
- Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(2))
- // Check it also cascades into the Integration scale subresource Status field
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 2)))
- // Check the Integration stays in error phase
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
-
- // Kit valid
- kitName := IntegrationKit(ns, name)()
- integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- Eventually(KitPhase(integrationKitNamespace, kitName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("run bad java route", func(t *testing.T) {
+ name := RandomizedSuffixName("bad-route")
+ Expect(KamelRunWithID(operatorID, ns, "files/BadRoute.java", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionFalse))
+
+ // Make sure the Integration can be scaled
+ Expect(ScaleIntegration(ns, name, 2)).To(Succeed())
+ // Check the scale cascades into the Deployment scale
+ Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(2))
+ // Check it also cascades into the Integration scale subresource Status field
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 2)))
+ // Check the Integration stays in error phase
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+
+ // Kit valid
+ kitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ Eventually(KitPhase(integrationKitNamespace, kitName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+ })
+
+ t.Run("run missing dependency java route", func(t *testing.T) {
+ name := RandomizedSuffixName("java-route")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
+ "-d", "mvn:com.example:nonexistent:1.0").Execute()).To(Succeed())
+ // Integration in error
+ Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionKitAvailable), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionKitAvailable), TestTimeoutShort).Should(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionKitAvailableReason)))
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionKitAvailable), TestTimeoutShort).Should(
+ WithTransform(IntegrationConditionMessage, ContainSubstring("is in state \"Error\"")))
+ // Kit in error
+ kitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ Eventually(KitPhase(integrationKitNamespace, kitName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseError))
+ //Build in error with 5 attempts
+ build := Build(integrationKitNamespace, kitName)()
+ Eventually(build.Status.Phase, TestTimeoutShort).Should(Equal(v1.BuildPhaseError))
+ Eventually(build.Status.Failure.Recovery.Attempt, TestTimeoutShort).Should(Equal(5))
+
+ // Fixing the route should reconcile the Integration
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseRunning))
+ // New Kit success
+ kitRecoveryName := IntegrationKit(ns, name)()
+ integrationKitRecoveryNamespace := IntegrationKitNamespace(ns, name)()
+ Eventually(KitPhase(integrationKitRecoveryNamespace, kitRecoveryName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+ Expect(kitRecoveryName).NotTo(Equal(kitName))
+ // New Build success
+ buildRecovery := Build(integrationKitRecoveryNamespace, kitRecoveryName)()
+ Eventually(buildRecovery.Status.Phase, TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
+
+ })
+
+ t.Run("run invalid dependency java route", func(t *testing.T) {
+ name := RandomizedSuffixName("invalid-dependency")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
+ "-d", "camel:non-existent").Execute()).To(Succeed())
+ // Integration in error with Initialization Failed condition
+ Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionInitializationFailedReason)),
+ WithTransform(IntegrationConditionMessage, HavePrefix("error during trait customization")),
+ ))
+ // Kit shouldn't be created
+ Consistently(IntegrationKit(ns, name), 10*time.Second).Should(BeEmpty())
+
+ // Fixing the route should reconcile the Integration in Initialization Failed condition to Running
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ // New Kit success
+ kitRecoveryName := IntegrationKit(ns, name)()
+ integrationKitRecoveryNamespace := IntegrationKitNamespace(ns, name)()
+ Eventually(KitPhase(integrationKitRecoveryNamespace, kitRecoveryName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+ // New Build success
+ buildRecovery := Build(integrationKitRecoveryNamespace, kitRecoveryName)()
+ Eventually(buildRecovery.Status.Phase, TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
+ })
+
+ t.Run("run unresolvable component java route", func(t *testing.T) {
+ name := RandomizedSuffixName("unresolvable-route")
+ Expect(KamelRunWithID(operatorID, ns, "files/Unresolvable.java", "--name", name).Execute()).To(Succeed())
+ // Integration in error with Initialization Failed condition
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionInitializationFailedReason)),
+ WithTransform(IntegrationConditionMessage, HavePrefix("error during trait customization")),
+ ))
+ // Kit shouldn't be created
+ Consistently(IntegrationKit(ns, name), 10*time.Second).Should(BeEmpty())
+
+ // Fixing the route should reconcile the Integration in Initialization Failed condition to Running
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ // New Kit success
+ kitRecoveryName := IntegrationKit(ns, name)()
+ integrationKitRecoveryNamespace := IntegrationKitNamespace(ns, name)()
+ Eventually(KitPhase(integrationKitRecoveryNamespace, kitRecoveryName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+ // New Build success
+ buildRecovery := Build(integrationKitRecoveryNamespace, kitRecoveryName)()
+ Eventually(buildRecovery.Status.Phase, TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
+ })
+
+ t.Run("run invalid java route", func(t *testing.T) {
+ name := RandomizedSuffixName("invalid-java-route")
+ Expect(KamelRunWithID(operatorID, ns, "files/InvalidJava.java", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Compilation error"))
+
+ // Kit valid
+ kitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ Eventually(KitPhase(integrationKitNamespace, kitName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+
+ // Fixing the route should reconcile the Integration in Initialization Failed condition to Running
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ // Kit should not have changed
+ kitRecoveryName := IntegrationKit(ns, name)()
+ Expect(kitRecoveryName).To(Equal(kitName))
+
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- t.Run("run missing dependency java route", func(t *testing.T) {
- name := RandomizedSuffixName("java-route")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
- "-d", "mvn:com.example:nonexistent:1.0").Execute()).To(Succeed())
- // Integration in error
- Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionKitAvailable), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionKitAvailable), TestTimeoutShort).Should(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionKitAvailableReason)))
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionKitAvailable), TestTimeoutShort).Should(
- WithTransform(IntegrationConditionMessage, ContainSubstring("is in state \"Error\"")))
- // Kit in error
- kitName := IntegrationKit(ns, name)()
- integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- Eventually(KitPhase(integrationKitNamespace, kitName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseError))
- //Build in error with 5 attempts
- build := Build(integrationKitNamespace, kitName)()
- Eventually(build.Status.Phase, TestTimeoutShort).Should(Equal(v1.BuildPhaseError))
- Eventually(build.Status.Failure.Recovery.Attempt, TestTimeoutShort).Should(Equal(5))
-
- // Fixing the route should reconcile the Integration
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseRunning))
- // New Kit success
- kitRecoveryName := IntegrationKit(ns, name)()
- integrationKitRecoveryNamespace := IntegrationKitNamespace(ns, name)()
- Eventually(KitPhase(integrationKitRecoveryNamespace, kitRecoveryName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
- Expect(kitRecoveryName).NotTo(Equal(kitName))
- // New Build success
- buildRecovery := Build(integrationKitRecoveryNamespace, kitRecoveryName)()
- Eventually(buildRecovery.Status.Phase, TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
-
- })
-
- t.Run("run invalid dependency java route", func(t *testing.T) {
- name := RandomizedSuffixName("invalid-dependency")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
- "-d", "camel:non-existent").Execute()).To(Succeed())
- // Integration in error with Initialization Failed condition
- Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionFalse))
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionInitializationFailedReason)),
- WithTransform(IntegrationConditionMessage, HavePrefix("error during trait customization")),
- ))
- // Kit shouldn't be created
- Consistently(IntegrationKit(ns, name), 10*time.Second).Should(BeEmpty())
-
- // Fixing the route should reconcile the Integration in Initialization Failed condition to Running
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- // New Kit success
- kitRecoveryName := IntegrationKit(ns, name)()
- integrationKitRecoveryNamespace := IntegrationKitNamespace(ns, name)()
- Eventually(KitPhase(integrationKitRecoveryNamespace, kitRecoveryName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
- // New Build success
- buildRecovery := Build(integrationKitRecoveryNamespace, kitRecoveryName)()
- Eventually(buildRecovery.Status.Phase, TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
- })
-
- t.Run("run unresolvable component java route", func(t *testing.T) {
- name := RandomizedSuffixName("unresolvable-route")
- Expect(KamelRunWithID(operatorID, ns, "files/Unresolvable.java", "--name", name).Execute()).To(Succeed())
- // Integration in error with Initialization Failed condition
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionFalse))
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionInitializationFailedReason)),
- WithTransform(IntegrationConditionMessage, HavePrefix("error during trait customization")),
- ))
- // Kit shouldn't be created
- Consistently(IntegrationKit(ns, name), 10*time.Second).Should(BeEmpty())
-
- // Fixing the route should reconcile the Integration in Initialization Failed condition to Running
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- // New Kit success
- kitRecoveryName := IntegrationKit(ns, name)()
- integrationKitRecoveryNamespace := IntegrationKitNamespace(ns, name)()
- Eventually(KitPhase(integrationKitRecoveryNamespace, kitRecoveryName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
- // New Build success
- buildRecovery := Build(integrationKitRecoveryNamespace, kitRecoveryName)()
- Eventually(buildRecovery.Status.Phase, TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
- })
-
- t.Run("run invalid java route", func(t *testing.T) {
- name := RandomizedSuffixName("invalid-java-route")
- Expect(KamelRunWithID(operatorID, ns, "files/InvalidJava.java", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionFalse))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Compilation error"))
-
- // Kit valid
- kitName := IntegrationKit(ns, name)()
- integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- Eventually(KitPhase(integrationKitNamespace, kitName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
-
- // Fixing the route should reconcile the Integration in Initialization Failed condition to Running
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- // Kit should not have changed
- kitRecoveryName := IntegrationKit(ns, name)()
- Expect(kitRecoveryName).To(Equal(kitName))
-
- })
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/misc/integration_trait_update_test.go b/e2e/common/misc/integration_trait_update_test.go
index 132d62862..681a2a70d 100644
--- a/e2e/common/misc/integration_trait_update_test.go
+++ b/e2e/common/misc/integration_trait_update_test.go
@@ -34,20 +34,21 @@ import (
)
func TestTraitUpdates(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("run and update trait", func(t *testing.T) {
- name := RandomizedSuffixName("yaml-route")
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- var numberOfPods = func(pods *int32) bool {
- return *pods >= 1 && *pods <= 2
- }
- // Adding a property will change the camel trait
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name, "-p", "hello=world").Execute()).To(Succeed())
- Consistently(IntegrationPodsNumbers(ns, name), TestTimeoutShort, 1*time.Second).Should(Satisfy(numberOfPods))
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("run and update trait", func(t *testing.T) {
+ name := RandomizedSuffixName("yaml-route")
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ var numberOfPods = func(pods *int32) bool {
+ return *pods >= 1 && *pods <= 2
+ }
+ // Adding a property will change the camel trait
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name, "-p", "hello=world").Execute()).To(Succeed())
+ Consistently(IntegrationPodsNumbers(ns, name), TestTimeoutShort, 1*time.Second).Should(Satisfy(numberOfPods))
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/misc/kamelet_test.go b/e2e/common/misc/kamelet_test.go
index 66c8c3839..ee6559396 100644
--- a/e2e/common/misc/kamelet_test.go
+++ b/e2e/common/misc/kamelet_test.go
@@ -33,11 +33,11 @@ import (
)
func TestKameletClasspathLoading(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- // Store a configmap on the cluster
- var cmData = make(map[string]string)
- cmData["my-timer-source.kamelet.yaml"] = `
+ // Store a configmap on the cluster
+ var cmData = make(map[string]string)
+ cmData["my-timer-source.kamelet.yaml"] = `
# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -108,27 +108,28 @@ spec:
constant: "{{contentType}}"
- to: kamelet:sink
`
- CreatePlainTextConfigmap(ns, "my-kamelet-cm", cmData)
+ CreatePlainTextConfigmap(ns, "my-kamelet-cm", cmData)
- // Basic
- t.Run("test basic case", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegration.java", "-t", "kamelets.enabled=false",
- "--resource", "configmap:my-kamelet-cm@/kamelets",
- "-p camel.component.kamelet.location=file:/kamelets",
- "-d", "camel:yaml-dsl",
- // kamelet dependencies
- "-d", "camel:timer").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "timer-kamelet-integration"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, "timer-kamelet-integration")).Should(ContainSubstring("important message"))
+ // Basic
+ t.Run("test basic case", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegration.java", "-t", "kamelets.enabled=false",
+ "--resource", "configmap:my-kamelet-cm@/kamelets",
+ "-p camel.component.kamelet.location=file:/kamelets",
+ "-d", "camel:yaml-dsl",
+ // kamelet dependencies
+ "-d", "camel:timer").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "timer-kamelet-integration"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, "timer-kamelet-integration")).Should(ContainSubstring("important message"))
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, "timer-kamelet-integration")).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, "timer-kamelet-integration")()
- kameletsTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "kamelets")
- Expect(kameletsTrait).ToNot(BeNil())
- Expect(len(kameletsTrait)).To(Equal(1))
- Expect(kameletsTrait["enabled"]).To(Equal(false))
- })
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, "timer-kamelet-integration")).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, "timer-kamelet-integration")()
+ kameletsTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "kamelets")
+ Expect(kameletsTrait).ToNot(BeNil())
+ Expect(len(kameletsTrait)).To(Equal(1))
+ Expect(kameletsTrait["enabled"]).To(Equal(false))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/misc/kamelet_update_test.go b/e2e/common/misc/kamelet_update_test.go
index e0f1228c9..70202e1ce 100644
--- a/e2e/common/misc/kamelet_update_test.go
+++ b/e2e/common/misc/kamelet_update_test.go
@@ -35,17 +35,18 @@ import (
const customLabel = "custom-label"
func TestBundleKameletUpdate(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- Expect(createBundleKamelet(ns, "my-http-sink")()).To(Succeed()) // Going to be replaced
- Expect(createUserKamelet(ns, "user-sink")()).To(Succeed()) // Left intact by the operator
+ Expect(createBundleKamelet(ns, "my-http-sink")()).To(Succeed()) // Going to be replaced
+ Expect(createUserKamelet(ns, "user-sink")()).To(Succeed()) // Left intact by the operator
- Eventually(Kamelet("my-http-sink", ns)).
- Should(WithTransform(KameletLabels, HaveKeyWithValue(customLabel, "true")))
- Consistently(Kamelet("user-sink", ns), 5*time.Second, 1*time.Second).
- Should(WithTransform(KameletLabels, HaveKeyWithValue(customLabel, "true")))
+ Eventually(Kamelet("my-http-sink", ns)).
+ Should(WithTransform(KameletLabels, HaveKeyWithValue(customLabel, "true")))
+ Consistently(Kamelet("user-sink", ns), 5*time.Second, 1*time.Second).
+ Should(WithTransform(KameletLabels, HaveKeyWithValue(customLabel, "true")))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func createBundleKamelet(ns string, name string) func() error {
diff --git a/e2e/common/misc/maven_repository_test.go b/e2e/common/misc/maven_repository_test.go
index 066a1d1ee..0d8d47438 100644
--- a/e2e/common/misc/maven_repository_test.go
+++ b/e2e/common/misc/maven_repository_test.go
@@ -34,21 +34,22 @@ import (
)
func TestRunExtraRepository(t *testing.T) {
- RegisterTestingT(t)
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--maven-repository", "https://maven.repository.redhat.com/ga@id=redhat",
- "--dependency", "mvn:org.jolokia:jolokia-core:1.7.1.redhat-00001",
- "--name", name,
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Eventually(Integration(ns, name)).Should(WithTransform(IntegrationSpec, And(
- HaveExistingField("Repositories"),
- HaveField("Repositories", ContainElements("https://maven.repository.redhat.com/ga@id=redhat")),
- )))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--maven-repository", "https://maven.repository.redhat.com/ga@id=redhat",
+ "--dependency", "mvn:org.jolokia:jolokia-core:1.7.1.redhat-00001",
+ "--name", name,
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ Eventually(Integration(ns, name)).Should(WithTransform(IntegrationSpec, And(
+ HaveExistingField("Repositories"),
+ HaveField("Repositories", ContainElements("https://maven.repository.redhat.com/ga@id=redhat")),
+ )))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/misc/pipe_test.go b/e2e/common/misc/pipe_test.go
index 2dcb5e3e8..4692e500c 100644
--- a/e2e/common/misc/pipe_test.go
+++ b/e2e/common/misc/pipe_test.go
@@ -35,88 +35,89 @@ import (
)
func TestPipe(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
+
+ // Error Handler testing
+ t.Run("test error handler", func(t *testing.T) {
+ Expect(createErrorProducerKamelet(ns, "my-own-error-producer-source")()).To(Succeed())
+ Expect(CreateLogKamelet(ns, "my-own-log-sink")()).To(Succeed())
+
+ t.Run("throw error test", func(t *testing.T) {
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-own-error-producer-source",
+ "my-own-log-sink",
+ "--error-handler", "sink:my-own-log-sink",
+ "-p", "source.message=throw Error",
+ "-p", "sink.loggerName=integrationLogger",
+ "-p", "error-handler.loggerName=kameletErrorHandler",
+ // Needed in the test to make sure to do the right string comparison later
+ "-t", "logging.color=false",
+ "--name", "throw-error-binding",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, "throw-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, "throw-error-binding"), TestTimeoutShort).Should(ContainSubstring("[kameletErrorHandler] (Camel (camel-1) thread #1 - timer://tick)"))
+ Eventually(IntegrationLogs(ns, "throw-error-binding"), TestTimeoutShort).ShouldNot(ContainSubstring("[integrationLogger] (Camel (camel-1) thread #1 - timer://tick)"))
+
+ })
+
+ t.Run("don't throw error test", func(t *testing.T) {
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-own-error-producer-source",
+ "my-own-log-sink",
+ "--error-handler", "sink:my-own-log-sink",
+ "-p", "source.message=true",
+ "-p", "sink.loggerName=integrationLogger",
+ "-p", "error-handler.loggerName=kameletErrorHandler",
+ // Needed in the test to make sure to do the right string comparison later
+ "-t", "logging.color=false",
+ "--name", "no-error-binding",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, "no-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, "no-error-binding"), TestTimeoutShort).ShouldNot(ContainSubstring("[kameletErrorHandler] (Camel (camel-1) thread #1 - timer://tick)"))
+ Eventually(IntegrationLogs(ns, "no-error-binding"), TestTimeoutShort).Should(ContainSubstring("[integrationLogger] (Camel (camel-1) thread #1 - timer://tick)"))
+
+ })
+ })
- // Error Handler testing
- t.Run("test error handler", func(t *testing.T) {
- Expect(createErrorProducerKamelet(ns, "my-own-error-producer-source")()).To(Succeed())
- Expect(CreateLogKamelet(ns, "my-own-log-sink")()).To(Succeed())
+ //Pipe with traits testing
+ t.Run("test Pipe with trait", func(t *testing.T) {
+ Expect(CreateTimerKamelet(ns, "my-own-timer-source")()).To(Succeed())
+ // Log sink kamelet exists from previous test
- t.Run("throw error test", func(t *testing.T) {
Expect(KamelBindWithID(operatorID, ns,
- "my-own-error-producer-source",
+ "my-own-timer-source",
"my-own-log-sink",
- "--error-handler", "sink:my-own-log-sink",
- "-p", "source.message=throw Error",
+ "-p", "source.message=hello from test",
"-p", "sink.loggerName=integrationLogger",
- "-p", "error-handler.loggerName=kameletErrorHandler",
- // Needed in the test to make sure to do the right string comparison later
- "-t", "logging.color=false",
- "--name", "throw-error-binding",
+ "--annotation", "trait.camel.apache.org/camel.properties=[\"camel.prop1=a\",\"camel.prop2=b\"]",
+ "--name", "kb-with-traits",
).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "throw-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, "throw-error-binding"), TestTimeoutShort).Should(ContainSubstring("[kameletErrorHandler] (Camel (camel-1) thread #1 - timer://tick)"))
- Eventually(IntegrationLogs(ns, "throw-error-binding"), TestTimeoutShort).ShouldNot(ContainSubstring("[integrationLogger] (Camel (camel-1) thread #1 - timer://tick)"))
-
+ Eventually(IntegrationPodPhase(ns, "kb-with-traits"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, "kb-with-traits"), TestTimeoutShort).Should(ContainSubstring("hello from test"))
+ Eventually(IntegrationLogs(ns, "kb-with-traits"), TestTimeoutShort).Should(ContainSubstring("integrationLogger"))
})
- t.Run("don't throw error test", func(t *testing.T) {
- Expect(KamelBindWithID(operatorID, ns,
- "my-own-error-producer-source",
- "my-own-log-sink",
- "--error-handler", "sink:my-own-log-sink",
- "-p", "source.message=true",
- "-p", "sink.loggerName=integrationLogger",
- "-p", "error-handler.loggerName=kameletErrorHandler",
- // Needed in the test to make sure to do the right string comparison later
- "-t", "logging.color=false",
- "--name", "no-error-binding",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, "no-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, "no-error-binding"), TestTimeoutShort).ShouldNot(ContainSubstring("[kameletErrorHandler] (Camel (camel-1) thread #1 - timer://tick)"))
- Eventually(IntegrationLogs(ns, "no-error-binding"), TestTimeoutShort).Should(ContainSubstring("[integrationLogger] (Camel (camel-1) thread #1 - timer://tick)"))
-
+ // Pipe with wrong spec
+ t.Run("test Pipe with wrong spec", func(t *testing.T) {
+ name := RandomizedSuffixName("bad-klb")
+ kb := v1.NewPipe(ns, name)
+ kb.Spec = v1.PipeSpec{}
+ _, err := kubernetes.ReplaceResource(TestContext, TestClient(), &kb)
+ Eventually(err).Should(BeNil())
+ Eventually(PipePhase(ns, name), TestTimeoutShort).Should(Equal(v1.PipePhaseError))
+ Eventually(PipeConditionStatus(ns, name, v1.PipeConditionReady), TestTimeoutShort).ShouldNot(Equal(corev1.ConditionTrue))
+ Eventually(PipeCondition(ns, name, v1.PipeIntegrationConditionError), TestTimeoutShort).Should(
+ WithTransform(PipeConditionMessage, And(
+ ContainSubstring("could not determine source URI"),
+ ContainSubstring("no ref or URI specified in endpoint"),
+ )))
})
- })
- //Pipe with traits testing
- t.Run("test Pipe with trait", func(t *testing.T) {
- Expect(CreateTimerKamelet(ns, "my-own-timer-source")()).To(Succeed())
- // Log sink kamelet exists from previous test
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-own-timer-source",
- "my-own-log-sink",
- "-p", "source.message=hello from test",
- "-p", "sink.loggerName=integrationLogger",
- "--annotation", "trait.camel.apache.org/camel.properties=[\"camel.prop1=a\",\"camel.prop2=b\"]",
- "--name", "kb-with-traits",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, "kb-with-traits"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, "kb-with-traits"), TestTimeoutShort).Should(ContainSubstring("hello from test"))
- Eventually(IntegrationLogs(ns, "kb-with-traits"), TestTimeoutShort).Should(ContainSubstring("integrationLogger"))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- // Pipe with wrong spec
- t.Run("test Pipe with wrong spec", func(t *testing.T) {
- name := RandomizedSuffixName("bad-klb")
- kb := v1.NewPipe(ns, name)
- kb.Spec = v1.PipeSpec{}
- _, err := kubernetes.ReplaceResource(TestContext, TestClient(), &kb)
- Eventually(err).Should(BeNil())
- Eventually(PipePhase(ns, name), TestTimeoutShort).Should(Equal(v1.PipePhaseError))
- Eventually(PipeConditionStatus(ns, name, v1.PipeConditionReady), TestTimeoutShort).ShouldNot(Equal(corev1.ConditionTrue))
- Eventually(PipeCondition(ns, name, v1.PipeIntegrationConditionError), TestTimeoutShort).Should(
- WithTransform(PipeConditionMessage, And(
- ContainSubstring("could not determine source URI"),
- ContainSubstring("no ref or URI specified in endpoint"),
- )))
- })
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
func createErrorProducerKamelet(ns string, name string) func() error {
diff --git a/e2e/common/misc/pipe_with_image_test.go b/e2e/common/misc/pipe_with_image_test.go
index d34e67d39..6c9de10aa 100644
--- a/e2e/common/misc/pipe_with_image_test.go
+++ b/e2e/common/misc/pipe_with_image_test.go
@@ -34,64 +34,65 @@ import (
)
func TestPipeWithImage(t *testing.T) {
- RegisterTestingT(t)
-
- bindingID := "with-image-binding"
-
- t.Run("run with initial image", func(t *testing.T) {
- expectedImage := "docker.io/jmalloc/echo-server:0.3.2"
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-own-timer-source",
- "my-own-log-sink",
- "--annotation", "trait.camel.apache.org/container.image="+expectedImage,
- "--annotation", "trait.camel.apache.org/jvm.enabled=false",
- "--annotation", "trait.camel.apache.org/kamelets.enabled=false",
- "--annotation", "trait.camel.apache.org/dependencies.enabled=false",
- "--annotation", "test=1",
- "--name", bindingID,
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationGeneration(ns, bindingID)).
- Should(gstruct.PointTo(BeNumerically("==", 1)))
- Eventually(Integration(ns, bindingID)).Should(WithTransform(Annotations, And(
- HaveKeyWithValue("test", "1"),
- HaveKeyWithValue("trait.camel.apache.org/container.image", expectedImage),
- )))
- Eventually(IntegrationStatusImage(ns, bindingID)).
- Should(Equal(expectedImage))
- Eventually(IntegrationPodPhase(ns, bindingID), TestTimeoutLong).
- Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPodImage(ns, bindingID)).
- Should(Equal(expectedImage))
+ WithNewTestNamespace(t, func(ns string) {
+
+ bindingID := "with-image-binding"
+
+ t.Run("run with initial image", func(t *testing.T) {
+ expectedImage := "docker.io/jmalloc/echo-server:0.3.2"
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-own-timer-source",
+ "my-own-log-sink",
+ "--annotation", "trait.camel.apache.org/container.image="+expectedImage,
+ "--annotation", "trait.camel.apache.org/jvm.enabled=false",
+ "--annotation", "trait.camel.apache.org/kamelets.enabled=false",
+ "--annotation", "trait.camel.apache.org/dependencies.enabled=false",
+ "--annotation", "test=1",
+ "--name", bindingID,
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationGeneration(ns, bindingID)).
+ Should(gstruct.PointTo(BeNumerically("==", 1)))
+ Eventually(Integration(ns, bindingID)).Should(WithTransform(Annotations, And(
+ HaveKeyWithValue("test", "1"),
+ HaveKeyWithValue("trait.camel.apache.org/container.image", expectedImage),
+ )))
+ Eventually(IntegrationStatusImage(ns, bindingID)).
+ Should(Equal(expectedImage))
+ Eventually(IntegrationPodPhase(ns, bindingID), TestTimeoutLong).
+ Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPodImage(ns, bindingID)).
+ Should(Equal(expectedImage))
+ })
+
+ t.Run("run with new image", func(t *testing.T) {
+ expectedImage := "docker.io/jmalloc/echo-server:0.3.3"
+
+ Expect(KamelBindWithID(operatorID, ns,
+ "my-own-timer-source",
+ "my-own-log-sink",
+ "--annotation", "trait.camel.apache.org/container.image="+expectedImage,
+ "--annotation", "trait.camel.apache.org/jvm.enabled=false",
+ "--annotation", "trait.camel.apache.org/kamelets.enabled=false",
+ "--annotation", "trait.camel.apache.org/dependencies.enabled=false",
+ "--annotation", "test=2",
+ "--name", bindingID,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationGeneration(ns, bindingID)).
+ Should(gstruct.PointTo(BeNumerically("==", 1)))
+ Eventually(Integration(ns, bindingID)).Should(WithTransform(Annotations, And(
+ HaveKeyWithValue("test", "2"),
+ HaveKeyWithValue("trait.camel.apache.org/container.image", expectedImage),
+ )))
+ Eventually(IntegrationStatusImage(ns, bindingID)).
+ Should(Equal(expectedImage))
+ Eventually(IntegrationPodPhase(ns, bindingID), TestTimeoutLong).
+ Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPodImage(ns, bindingID)).
+ Should(Equal(expectedImage))
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- t.Run("run with new image", func(t *testing.T) {
- expectedImage := "docker.io/jmalloc/echo-server:0.3.3"
-
- Expect(KamelBindWithID(operatorID, ns,
- "my-own-timer-source",
- "my-own-log-sink",
- "--annotation", "trait.camel.apache.org/container.image="+expectedImage,
- "--annotation", "trait.camel.apache.org/jvm.enabled=false",
- "--annotation", "trait.camel.apache.org/kamelets.enabled=false",
- "--annotation", "trait.camel.apache.org/dependencies.enabled=false",
- "--annotation", "test=2",
- "--name", bindingID,
- ).Execute()).To(Succeed())
- Eventually(IntegrationGeneration(ns, bindingID)).
- Should(gstruct.PointTo(BeNumerically("==", 1)))
- Eventually(Integration(ns, bindingID)).Should(WithTransform(Annotations, And(
- HaveKeyWithValue("test", "2"),
- HaveKeyWithValue("trait.camel.apache.org/container.image", expectedImage),
- )))
- Eventually(IntegrationStatusImage(ns, bindingID)).
- Should(Equal(expectedImage))
- Eventually(IntegrationPodPhase(ns, bindingID), TestTimeoutLong).
- Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPodImage(ns, bindingID)).
- Should(Equal(expectedImage))
- })
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/misc/registry_maven_wagon_test.go b/e2e/common/misc/registry_maven_wagon_test.go
index 5a0cb74bc..9b4003536 100644
--- a/e2e/common/misc/registry_maven_wagon_test.go
+++ b/e2e/common/misc/registry_maven_wagon_test.go
@@ -38,7 +38,6 @@ import (
)
func TestImageRegistryIsAMavenRepository(t *testing.T) {
- RegisterTestingT(t)
ocp, err := openshift.IsOpenShift(TestClient())
require.NoError(t, err)
if ocp {
@@ -124,6 +123,7 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("foobar"))
})
+
t.Run("dependency can be used at build time", func(t *testing.T) {
// Create integration that should run an Xslt transformation whose template needs to be present at build time
name := RandomizedSuffixName("xslt")
diff --git a/e2e/common/misc/rest_test.go b/e2e/common/misc/rest_test.go
index 2719f2180..8c1a7b9c8 100644
--- a/e2e/common/misc/rest_test.go
+++ b/e2e/common/misc/rest_test.go
@@ -38,37 +38,38 @@ import (
)
func TestRunRest(t *testing.T) {
- RegisterTestingT(t)
-
- ocp, err := openshift.IsOpenShift(TestClient())
- require.NoError(t, err)
-
- Expect(KamelRunWithID(operatorID, ns, "files/rest-consumer.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "rest-consumer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- t.Run("Service works", func(t *testing.T) {
- name := RandomizedSuffixName("John")
- service := Service(ns, "rest-consumer")
- Eventually(service, TestTimeoutShort).ShouldNot(BeNil())
- Expect(KamelRunWithID(operatorID, ns, "files/rest-producer.yaml", "-p", "serviceName=rest-consumer", "-p", "name="+name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "rest-producer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, "rest-consumer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
- Eventually(IntegrationLogs(ns, "rest-producer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("%s Doe", name)))
- })
-
- if ocp {
- t.Run("Route works", func(t *testing.T) {
- name := RandomizedSuffixName("Peter")
- route := Route(ns, "rest-consumer")
- Eventually(route, TestTimeoutShort).ShouldNot(BeNil())
- Eventually(RouteStatus(ns, "rest-consumer"), TestTimeoutMedium).Should(Equal("True"))
- url := fmt.Sprintf("http://%s/customers/%s", route().Spec.Host, name)
- Eventually(httpRequest(url), TestTimeoutMedium).Should(Equal(fmt.Sprintf("%s Doe", name)))
- Eventually(IntegrationLogs(ns, "rest-consumer"), TestTimeoutShort).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
+ WithNewTestNamespace(t, func(ns string) {
+
+ ocp, err := openshift.IsOpenShift(TestClient())
+ require.NoError(t, err)
+
+ Expect(KamelRunWithID(operatorID, ns, "files/rest-consumer.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "rest-consumer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+ t.Run("Service works", func(t *testing.T) {
+ name := RandomizedSuffixName("John")
+ service := Service(ns, "rest-consumer")
+ Eventually(service, TestTimeoutShort).ShouldNot(BeNil())
+ Expect(KamelRunWithID(operatorID, ns, "files/rest-producer.yaml", "-p", "serviceName=rest-consumer", "-p", "name="+name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "rest-producer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, "rest-consumer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
+ Eventually(IntegrationLogs(ns, "rest-producer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("%s Doe", name)))
})
- }
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ if ocp {
+ t.Run("Route works", func(t *testing.T) {
+ name := RandomizedSuffixName("Peter")
+ route := Route(ns, "rest-consumer")
+ Eventually(route, TestTimeoutShort).ShouldNot(BeNil())
+ Eventually(RouteStatus(ns, "rest-consumer"), TestTimeoutMedium).Should(Equal("True"))
+ url := fmt.Sprintf("http://%s/customers/%s", route().Spec.Host, name)
+ Eventually(httpRequest(url), TestTimeoutMedium).Should(Equal(fmt.Sprintf("%s Doe", name)))
+ Eventually(IntegrationLogs(ns, "rest-consumer"), TestTimeoutShort).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
+ })
+ }
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func httpRequest(url string) func() (string, error) {
diff --git a/e2e/common/misc/scale_binding_test.go b/e2e/common/misc/scale_binding_test.go
index 36ab04c15..b4501767d 100644
--- a/e2e/common/misc/scale_binding_test.go
+++ b/e2e/common/misc/scale_binding_test.go
@@ -40,93 +40,94 @@ import (
)
func TestPipeScale(t *testing.T) {
- RegisterTestingT(t)
-
- ocp, err := openshift.IsOpenShift(TestClient())
- require.NoError(t, err)
- if ocp {
- t.Skip("TODO: Temporarily disabled as this test is flaky on OpenShift 3")
- return
- }
-
- name := RandomizedSuffixName("timer2log")
- Expect(KamelBindWithID(operatorID, ns, "timer-source?message=HelloPipe", "log-sink", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(PipeConditionStatus(ns, name, v1.PipeConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("HelloPipe"))
-
- t.Run("Update Pipe scale spec", func(t *testing.T) {
- Expect(ScalePipe(ns, name, 3)).To(Succeed())
- // Check the scale cascades into the Deployment scale
- Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(3))
- // Check it also cascades into the Integration scale subresource Status field
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 3)))
- // Check it also cascades into the Pipe scale subresource Status field
- Eventually(PipeStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 3)))
- // Check the readiness condition becomes truthy back
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
- // Finally check the readiness condition becomes truthy back onPipe
- Eventually(PipeConditionStatus(ns, name, v1.PipeConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ WithNewTestNamespace(t, func(ns string) {
+
+ ocp, err := openshift.IsOpenShift(TestClient())
+ require.NoError(t, err)
+ if ocp {
+ t.Skip("TODO: Temporarily disabled as this test is flaky on OpenShift 3")
+ return
+ }
+
+ name := RandomizedSuffixName("timer2log")
+ Expect(KamelBindWithID(operatorID, ns, "timer-source?message=HelloPipe", "log-sink", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(PipeConditionStatus(ns, name, v1.PipeConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("HelloPipe"))
+
+ t.Run("Update Pipe scale spec", func(t *testing.T) {
+ Expect(ScalePipe(ns, name, 3)).To(Succeed())
+ // Check the scale cascades into the Deployment scale
+ Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(3))
+ // Check it also cascades into the Integration scale subresource Status field
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 3)))
+ // Check it also cascades into the Pipe scale subresource Status field
+ Eventually(PipeStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 3)))
+ // Check the readiness condition becomes truthy back
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ // Finally check the readiness condition becomes truthy back onPipe
+ Eventually(PipeConditionStatus(ns, name, v1.PipeConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ })
+
+ t.Run("ScalePipe with polymorphic client", func(t *testing.T) {
+ scaleClient, err := TestClient().ScalesClient()
+ Expect(err).To(BeNil())
+
+ // Patch the integration scale subresource
+ patch := "{\"spec\":{\"replicas\":2}}"
+ _, err = scaleClient.Scales(ns).Patch(TestContext, v1.SchemeGroupVersion.WithResource("Pipes"), name, types.MergePatchType, []byte(patch), metav1.PatchOptions{})
+ Expect(err).To(BeNil())
+
+ // Check the readiness condition is still truthy as down-scaling
+ Expect(PipeConditionStatus(ns, name, v1.PipeConditionReady)()).To(Equal(corev1.ConditionTrue))
+ // Check the Integration scale subresource Spec field
+ Eventually(IntegrationSpecReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 2)))
+ // Then check it cascades into the Deployment scale
+ Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(2))
+ // Check it cascades into the Integration scale subresource Status field
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 2)))
+ // Finally check it cascades into the Pipe scale subresource Status field
+ Eventually(PipeStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 2)))
+ })
+
+ t.Run("ScalePipe with Camel K client", func(t *testing.T) {
+ camel, err := versioned.NewForConfig(TestClient().GetConfig())
+ Expect(err).To(BeNil())
+
+ // Getter
+ PipeScale, err := camel.CamelV1().Pipes(ns).GetScale(TestContext, name, metav1.GetOptions{})
+ Expect(err).To(BeNil())
+ Expect(PipeScale.Spec.Replicas).To(BeNumerically("==", 2))
+ Expect(PipeScale.Status.Replicas).To(BeNumerically("==", 2))
+
+ // Setter
+ PipeScale.Spec.Replicas = 1
+ _, err = camel.CamelV1().Pipes(ns).UpdateScale(TestContext, name, PipeScale, metav1.UpdateOptions{})
+ Expect(err).To(BeNil())
+
+ // Check the readiness condition is still truthy as down-scaling inPipe
+ Expect(PipeConditionStatus(ns, name, v1.PipeConditionReady)()).To(Equal(corev1.ConditionTrue))
+ // Check the Pipe scale subresource Spec field
+ Eventually(PipeSpecReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 1)))
+ // Check the readiness condition is still truthy as down-scaling
+ Expect(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady)()).To(Equal(corev1.ConditionTrue))
+ // Check the Integration scale subresource Spec field
+ Eventually(IntegrationSpecReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 1)))
+ // Then check it cascades into the Deployment scale
+ Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(1))
+ // Finally check it cascades into the Integration scale subresource Status field
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 1)))
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- t.Run("ScalePipe with polymorphic client", func(t *testing.T) {
- scaleClient, err := TestClient().ScalesClient()
- Expect(err).To(BeNil())
-
- // Patch the integration scale subresource
- patch := "{\"spec\":{\"replicas\":2}}"
- _, err = scaleClient.Scales(ns).Patch(TestContext, v1.SchemeGroupVersion.WithResource("Pipes"), name, types.MergePatchType, []byte(patch), metav1.PatchOptions{})
- Expect(err).To(BeNil())
-
- // Check the readiness condition is still truthy as down-scaling
- Expect(PipeConditionStatus(ns, name, v1.PipeConditionReady)()).To(Equal(corev1.ConditionTrue))
- // Check the Integration scale subresource Spec field
- Eventually(IntegrationSpecReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 2)))
- // Then check it cascades into the Deployment scale
- Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(2))
- // Check it cascades into the Integration scale subresource Status field
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 2)))
- // Finally check it cascades into the Pipe scale subresource Status field
- Eventually(PipeStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 2)))
- })
-
- t.Run("ScalePipe with Camel K client", func(t *testing.T) {
- camel, err := versioned.NewForConfig(TestClient().GetConfig())
- Expect(err).To(BeNil())
-
- // Getter
- PipeScale, err := camel.CamelV1().Pipes(ns).GetScale(TestContext, name, metav1.GetOptions{})
- Expect(err).To(BeNil())
- Expect(PipeScale.Spec.Replicas).To(BeNumerically("==", 2))
- Expect(PipeScale.Status.Replicas).To(BeNumerically("==", 2))
-
- // Setter
- PipeScale.Spec.Replicas = 1
- _, err = camel.CamelV1().Pipes(ns).UpdateScale(TestContext, name, PipeScale, metav1.UpdateOptions{})
- Expect(err).To(BeNil())
-
- // Check the readiness condition is still truthy as down-scaling inPipe
- Expect(PipeConditionStatus(ns, name, v1.PipeConditionReady)()).To(Equal(corev1.ConditionTrue))
- // Check the Pipe scale subresource Spec field
- Eventually(PipeSpecReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 1)))
- // Check the readiness condition is still truthy as down-scaling
- Expect(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady)()).To(Equal(corev1.ConditionTrue))
- // Check the Integration scale subresource Spec field
- Eventually(IntegrationSpecReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 1)))
- // Then check it cascades into the Deployment scale
- Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(1))
- // Finally check it cascades into the Integration scale subresource Status field
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 1)))
- })
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/misc/scale_integration_test.go b/e2e/common/misc/scale_integration_test.go
index 422adfa59..0b38946ed 100644
--- a/e2e/common/misc/scale_integration_test.go
+++ b/e2e/common/misc/scale_integration_test.go
@@ -39,93 +39,94 @@ import (
)
func TestIntegrationScale(t *testing.T) {
- RegisterTestingT(t)
-
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- t.Run("Update integration scale spec", func(t *testing.T) {
- RegisterTestingT(t)
- Expect(ScaleIntegration(ns, name, 3)).To(Succeed())
- // Check the readiness condition becomes falsy
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
- // Check the scale cascades into the Deployment scale
- Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(3))
- // Check it also cascades into the Integration scale subresource Status field
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 3)))
- // Finally check the readiness condition becomes truthy back
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ WithNewTestNamespace(t, func(ns string) {
+
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ t.Run("Update integration scale spec", func(t *testing.T) {
+ RegisterTestingT(t)
+ Expect(ScaleIntegration(ns, name, 3)).To(Succeed())
+ // Check the readiness condition becomes falsy
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
+ // Check the scale cascades into the Deployment scale
+ Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(3))
+ // Check it also cascades into the Integration scale subresource Status field
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 3)))
+ // Finally check the readiness condition becomes truthy back
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ })
+
+ t.Run("Scale integration with polymorphic client", func(t *testing.T) {
+ scaleClient, err := TestClient().ScalesClient()
+ Expect(err).To(BeNil())
+
+ // Patch the integration scale subresource
+ patch := "{\"spec\":{\"replicas\":2}}"
+ _, err = scaleClient.Scales(ns).Patch(TestContext, v1.SchemeGroupVersion.WithResource("integrations"), name, types.MergePatchType, []byte(patch), metav1.PatchOptions{})
+ Expect(err).To(BeNil())
+
+ // Check the readiness condition is still truthy as down-scaling
+ Expect(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady)()).To(Equal(corev1.ConditionTrue))
+ // Check the Integration scale subresource Spec field
+ Eventually(IntegrationSpecReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 2)))
+ // Then check it cascades into the Deployment scale
+ Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(2))
+ // Finally check it cascades into the Integration scale subresource Status field
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 2)))
+ })
+
+ t.Run("Scale integration with Camel K client", func(t *testing.T) {
+ camel, err := versioned.NewForConfig(TestClient().GetConfig())
+ Expect(err).To(BeNil())
+
+ // Getter
+ integrationScale, err := camel.CamelV1().Integrations(ns).GetScale(TestContext, name, metav1.GetOptions{})
+ Expect(err).To(BeNil())
+ Expect(integrationScale.Spec.Replicas).To(BeNumerically("==", 2))
+ Expect(integrationScale.Status.Replicas).To(BeNumerically("==", 2))
+
+ // Setter
+ integrationScale.Spec.Replicas = 1
+ integrationScale, err = camel.CamelV1().Integrations(ns).UpdateScale(TestContext, name, integrationScale, metav1.UpdateOptions{})
+ Expect(err).To(BeNil())
+
+ // Check the readiness condition is still truthy as down-scaling
+ Expect(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady)()).To(Equal(corev1.ConditionTrue))
+ // Check the Integration scale subresource Spec field
+ Eventually(IntegrationSpecReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 1)))
+ // Then check it cascades into the Deployment scale
+ Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(1))
+ // Finally check it cascades into the Integration scale subresource Status field
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 1)))
+ })
+
+ t.Run("Scale integration with external image", func(t *testing.T) {
+ image := IntegrationPodImage(ns, name)()
+ Expect(image).NotTo(BeEmpty())
+ // Save resources by deleting the integration
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", "pre-built", "-t", fmt.Sprintf("container.image=%s", image)).Execute()).To(Succeed())
+ Eventually(IntegrationPhase(ns, "pre-built"), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
+ Eventually(IntegrationPodPhase(ns, "pre-built"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Expect(ScaleIntegration(ns, "pre-built", 0)).To(Succeed())
+ Eventually(IntegrationPod(ns, "pre-built"), TestTimeoutMedium).Should(BeNil())
+ Expect(ScaleIntegration(ns, "pre-built", 1)).To(Succeed())
+ Eventually(IntegrationPhase(ns, "pre-built"), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
+ Eventually(IntegrationPodPhase(ns, "pre-built"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+ Expect(Kamel("delete", "pre-built", "-n", ns).Execute()).To(Succeed())
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- t.Run("Scale integration with polymorphic client", func(t *testing.T) {
- scaleClient, err := TestClient().ScalesClient()
- Expect(err).To(BeNil())
-
- // Patch the integration scale subresource
- patch := "{\"spec\":{\"replicas\":2}}"
- _, err = scaleClient.Scales(ns).Patch(TestContext, v1.SchemeGroupVersion.WithResource("integrations"), name, types.MergePatchType, []byte(patch), metav1.PatchOptions{})
- Expect(err).To(BeNil())
-
- // Check the readiness condition is still truthy as down-scaling
- Expect(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady)()).To(Equal(corev1.ConditionTrue))
- // Check the Integration scale subresource Spec field
- Eventually(IntegrationSpecReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 2)))
- // Then check it cascades into the Deployment scale
- Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(2))
- // Finally check it cascades into the Integration scale subresource Status field
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 2)))
- })
-
- t.Run("Scale integration with Camel K client", func(t *testing.T) {
- camel, err := versioned.NewForConfig(TestClient().GetConfig())
- Expect(err).To(BeNil())
-
- // Getter
- integrationScale, err := camel.CamelV1().Integrations(ns).GetScale(TestContext, name, metav1.GetOptions{})
- Expect(err).To(BeNil())
- Expect(integrationScale.Spec.Replicas).To(BeNumerically("==", 2))
- Expect(integrationScale.Status.Replicas).To(BeNumerically("==", 2))
-
- // Setter
- integrationScale.Spec.Replicas = 1
- integrationScale, err = camel.CamelV1().Integrations(ns).UpdateScale(TestContext, name, integrationScale, metav1.UpdateOptions{})
- Expect(err).To(BeNil())
-
- // Check the readiness condition is still truthy as down-scaling
- Expect(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady)()).To(Equal(corev1.ConditionTrue))
- // Check the Integration scale subresource Spec field
- Eventually(IntegrationSpecReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 1)))
- // Then check it cascades into the Deployment scale
- Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(1))
- // Finally check it cascades into the Integration scale subresource Status field
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 1)))
- })
-
- t.Run("Scale integration with external image", func(t *testing.T) {
- image := IntegrationPodImage(ns, name)()
- Expect(image).NotTo(BeEmpty())
- // Save resources by deleting the integration
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
-
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", "pre-built", "-t", fmt.Sprintf("container.image=%s", image)).Execute()).To(Succeed())
- Eventually(IntegrationPhase(ns, "pre-built"), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
- Eventually(IntegrationPodPhase(ns, "pre-built"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Expect(ScaleIntegration(ns, "pre-built", 0)).To(Succeed())
- Eventually(IntegrationPod(ns, "pre-built"), TestTimeoutMedium).Should(BeNil())
- Expect(ScaleIntegration(ns, "pre-built", 1)).To(Succeed())
- Eventually(IntegrationPhase(ns, "pre-built"), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
- Eventually(IntegrationPodPhase(ns, "pre-built"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- Expect(Kamel("delete", "pre-built", "-n", ns).Execute()).To(Succeed())
- })
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/misc/structured_logs_test.go b/e2e/common/misc/structured_logs_test.go
index a78561618..e011a1ae5 100644
--- a/e2e/common/misc/structured_logs_test.go
+++ b/e2e/common/misc/structured_logs_test.go
@@ -35,31 +35,33 @@ import (
)
func TestStructuredLogs(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "logging.format=json").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "logging.format=json").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- pod := OperatorPod(ns)()
- Expect(pod).NotTo(BeNil())
+ opns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)
+ pod := OperatorPod(opns)()
+ Expect(pod).NotTo(BeNil())
- // pod.Namespace could be different from ns if using global operator
- fmt.Printf("Fetching logs for operator pod %s in namespace %s", pod.Name, pod.Namespace)
- logOptions := &corev1.PodLogOptions{
- Container: "camel-k-operator",
- }
- logs, err := StructuredLogs(pod.Namespace, pod.Name, logOptions, false)
- Expect(err).To(BeNil())
- Expect(logs).NotTo(BeEmpty())
+ // pod.Namespace could be different from ns if using global operator
+ fmt.Printf("Fetching logs for operator pod %s in namespace %s", pod.Name, pod.Namespace)
+ logOptions := &corev1.PodLogOptions{
+ Container: "camel-k-operator",
+ }
+ logs, err := StructuredLogs(pod.Namespace, pod.Name, logOptions, false)
+ Expect(err).To(BeNil())
+ Expect(logs).NotTo(BeEmpty())
- it := Integration(ns, name)()
- Expect(it).NotTo(BeNil())
- build := Build(IntegrationKitNamespace(ns, name)(), IntegrationKit(ns, name)())()
- Expect(build).NotTo(BeNil())
+ it := Integration(ns, name)()
+ Expect(it).NotTo(BeNil())
+ build := Build(IntegrationKitNamespace(ns, name)(), IntegrationKit(ns, name)())()
+ Expect(build).NotTo(BeNil())
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/runtimes/default.go b/e2e/common/runtimes/default.go
index 1cc41c3f9..dec3b52c7 100644
--- a/e2e/common/runtimes/default.go
+++ b/e2e/common/runtimes/default.go
@@ -20,7 +20,10 @@ limitations under the License.
package runtimes
-import "github.com/apache/camel-k/v2/e2e/support"
+import (
+ "github.com/apache/camel-k/v2/e2e/support"
+ "github.com/apache/camel-k/v2/pkg/platform"
+)
-var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.GetCIProcessID())
-var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", support.GetCIProcessID())
+var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.TestDefaultNamespace)
+var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", platform.DefaultPlatformName)
diff --git a/e2e/common/runtimes/runtimes_test.go b/e2e/common/runtimes/runtimes_test.go
index 87f6394e1..0e53eb022 100644
--- a/e2e/common/runtimes/runtimes_test.go
+++ b/e2e/common/runtimes/runtimes_test.go
@@ -34,40 +34,41 @@ import (
)
func TestSourceLessIntegrations(t *testing.T) {
- RegisterTestingT(t)
- var cmData = make(map[string]string)
- cmData["my-file.txt"] = "Hello World!"
- CreatePlainTextConfigmap(ns, "my-cm-sourceless", cmData)
+ WithNewTestNamespace(t, func(ns string) {
+ var cmData = make(map[string]string)
+ cmData["my-file.txt"] = "Hello World!"
+ CreatePlainTextConfigmap(ns, "my-cm-sourceless", cmData)
- t.Run("Camel Main", func(t *testing.T) {
- itName := "my-camel-main-v1"
- Expect(KamelRunWithID(operatorID, ns, "--image", "docker.io/squakez/my-camel-main:1.0.0", "--resource", "configmap:my-cm-sourceless@/tmp/app/data").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, itName), TestTimeoutShort).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, itName, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationCondition(ns, itName, v1.IntegrationConditionTraitInfo)().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
- Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring(cmData["my-file.txt"]))
- Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring("Apache Camel (Main)"))
- })
+ t.Run("Camel Main", func(t *testing.T) {
+ itName := "my-camel-main-v1"
+ Expect(KamelRunWithID(operatorID, ns, "--image", "docker.io/squakez/my-camel-main:1.0.0", "--resource", "configmap:my-cm-sourceless@/tmp/app/data").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, itName), TestTimeoutShort).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, itName, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationCondition(ns, itName, v1.IntegrationConditionTraitInfo)().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
+ Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring(cmData["my-file.txt"]))
+ Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring("Apache Camel (Main)"))
+ })
- t.Run("Camel Spring Boot", func(t *testing.T) {
- itName := "my-camel-sb-v1"
- Expect(KamelRunWithID(operatorID, ns, "--image", "docker.io/squakez/my-camel-sb:1.0.0", "--resource", "configmap:my-cm-sourceless@/tmp/app/data").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, itName), TestTimeoutShort).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, itName, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationCondition(ns, itName, v1.IntegrationConditionTraitInfo)().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
- Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring(cmData["my-file.txt"]))
- Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring("Spring Boot"))
- })
+ t.Run("Camel Spring Boot", func(t *testing.T) {
+ itName := "my-camel-sb-v1"
+ Expect(KamelRunWithID(operatorID, ns, "--image", "docker.io/squakez/my-camel-sb:1.0.0", "--resource", "configmap:my-cm-sourceless@/tmp/app/data").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, itName), TestTimeoutShort).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, itName, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationCondition(ns, itName, v1.IntegrationConditionTraitInfo)().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
+ Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring(cmData["my-file.txt"]))
+ Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring("Spring Boot"))
+ })
- t.Run("Camel Quarkus", func(t *testing.T) {
- itName := "my-camel-quarkus-v1"
- Expect(KamelRunWithID(operatorID, ns, "--image", "docker.io/squakez/my-camel-quarkus:1.0.0", "--resource", "configmap:my-cm-sourceless@/tmp/app/data").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, itName), TestTimeoutShort).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, itName, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationCondition(ns, itName, v1.IntegrationConditionTraitInfo)().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
- Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring(cmData["my-file.txt"]))
- Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring("powered by Quarkus"))
- })
+ t.Run("Camel Quarkus", func(t *testing.T) {
+ itName := "my-camel-quarkus-v1"
+ Expect(KamelRunWithID(operatorID, ns, "--image", "docker.io/squakez/my-camel-quarkus:1.0.0", "--resource", "configmap:my-cm-sourceless@/tmp/app/data").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, itName), TestTimeoutShort).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, itName, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationCondition(ns, itName, v1.IntegrationConditionTraitInfo)().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
+ Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring(cmData["my-file.txt"]))
+ Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring("powered by Quarkus"))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/setup/main_test.go b/e2e/common/setup/main_test.go
new file mode 100644
index 000000000..ed301d2cd
--- /dev/null
+++ b/e2e/common/setup/main_test.go
@@ -0,0 +1,63 @@
+//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 setup
+
+import (
+ "fmt"
+ "os"
+ "testing"
+
+ . "github.com/onsi/gomega"
+
+ . "github.com/apache/camel-k/v2/e2e/support"
+ v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/v2/pkg/platform"
+
+ corev1 "k8s.io/api/core/v1"
+)
+
+func TestMain(m *testing.M) {
+ fastSetup := GetEnvOrDefault("CAMEL_K_E2E_FAST_SETUP", "false")
+ if fastSetup != "true" {
+ os.Exit(m.Run())
+ }
+
+ operatorID := platform.DefaultPlatformName
+ ns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)
+
+ g := NewGomega(func(message string, callerSkip ...int) {
+ fmt.Printf("Test fast setup failed! - %s\n", message)
+ })
+
+ g.Expect(KamelRunWithID(operatorID, ns, "testdata/Java.java").Execute()).To(Succeed())
+ g.Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ g.Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ g.Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ g.Expect(KamelRunWithID(operatorID, ns, "testdata/yaml.yaml").Execute()).To(Succeed())
+ g.Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ g.Eventually(IntegrationConditionStatus(ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ g.Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ os.Exit(m.Run())
+}
diff --git a/e2e/common/setup/testdata/Java.java b/e2e/common/setup/testdata/Java.java
new file mode 100644
index 000000000..66fef5fe8
--- /dev/null
+++ b/e2e/common/setup/testdata/Java.java
@@ -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.
+ */
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class Java extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("timer:tick")
+ .setHeader("m").constant("string!")
+ .setBody().simple("Magic${header.m}")
+ .log("${body}");
+ }
+}
diff --git a/e2e/common/setup/testdata/yaml.yaml b/e2e/common/setup/testdata/yaml.yaml
new file mode 100644
index 000000000..8877c8557
--- /dev/null
+++ b/e2e/common/setup/testdata/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:
+ - setHeader:
+ name: "m"
+ constant: "string!"
+ - setBody:
+ simple: "Magic${header.m}"
+ - to: "log:info"
diff --git a/e2e/common/support/startup_test.go b/e2e/common/support/startup_test.go
deleted file mode 100644
index 27ed31f49..000000000
--- a/e2e/common/support/startup_test.go
+++ /dev/null
@@ -1,51 +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 support
-
-import (
- "testing"
-
- . "github.com/onsi/gomega"
- corev1 "k8s.io/api/core/v1"
-
- . "github.com/apache/camel-k/v2/e2e/support"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-)
-
-func TestCommonCamelKInstallStartup(t *testing.T) {
- RegisterTestingT(t)
-
- ns := NewTestNamespace(false)
- Expect(ns).ShouldNot(BeNil())
- // the namespace is dynamic if there is some collision
- // we store this value as it will be used for cleaning in the teardown process
- SaveCIProcessID(ns.GetName())
- // fail fast if something did not work writing the resource
- Expect(GetCIProcessID()).ShouldNot(Equal(""))
-
- Expect(KamelInstallWithIDAndKameletCatalog(ns.GetName(), ns.GetName()).Execute()).To(Succeed())
- Eventually(OperatorPod(ns.GetName())).ShouldNot(BeNil())
- Eventually(Platform(ns.GetName())).ShouldNot(BeNil())
- Eventually(PlatformConditionStatus(ns.GetName(), v1.IntegrationPlatformConditionTypeCreated), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
-}
diff --git a/e2e/common/support/teardown_test.go b/e2e/common/support/teardown_test.go
deleted file mode 100644
index 78546c7f7..000000000
--- a/e2e/common/support/teardown_test.go
+++ /dev/null
@@ -1,40 +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 support
-
-import (
- "testing"
-
- . "github.com/onsi/gomega"
-
- . "github.com/apache/camel-k/v2/e2e/support"
-)
-
-func TestCommonCamelKInstallTeardown(t *testing.T) {
- RegisterTestingT(t)
-
- ns := GetCIProcessID()
- Expect(ns).ShouldNot(Equal(""))
- Expect(DeleteNamespace(t, ns)).To(Succeed())
- DeleteCIProcessID()
-}
diff --git a/e2e/common/traits/affinity_test.go b/e2e/common/traits/affinity_test.go
index 7ce8a20eb..1c3cadff6 100644
--- a/e2e/common/traits/affinity_test.go
+++ b/e2e/common/traits/affinity_test.go
@@ -37,85 +37,86 @@ import (
)
func TestAffinityTrait(t *testing.T) {
- RegisterTestingT(t)
-
- var hostname string
- if node, err := selectSchedulableNode(); err == nil {
- hostname = node.Labels["kubernetes.io/hostname"]
- } else {
- // if 'get nodes' is not allowed, just skip tests for node affinity
- hostname = ""
- }
+ WithNewTestNamespace(t, func(ns string) {
+
+ var hostname string
+ if node, err := selectSchedulableNode(); err == nil {
+ hostname = node.Labels["kubernetes.io/hostname"]
+ } else {
+ // if 'get nodes' is not allowed, just skip tests for node affinity
+ hostname = ""
+ }
- if hostname != "" {
- t.Run("Run Java with node affinity", func(t *testing.T) {
- name1 := RandomizedSuffixName("java1")
+ if hostname != "" {
+ t.Run("Run Java with node affinity", func(t *testing.T) {
+ name1 := RandomizedSuffixName("java1")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name1,
+ "-t", "affinity.enabled=true",
+ "-t", fmt.Sprintf("affinity.node-affinity-labels=kubernetes.io/hostname in(%s)", hostname)).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name1), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name1, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name1), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ pod := IntegrationPod(ns, name1)()
+ Expect(pod.Spec.Affinity).NotTo(BeNil())
+ Expect(pod.Spec.Affinity.NodeAffinity).To(Equal(&corev1.NodeAffinity{
+ RequiredDuringSchedulingIgnoredDuringExecution: nodeSelector("kubernetes.io/hostname", corev1.NodeSelectorOpIn, hostname),
+ }))
+ Expect(pod.Spec.NodeName).To(Equal(hostname))
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, name1)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, name1)()
+ affinityTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "affinity")
+ Expect(affinityTrait).NotTo(BeNil())
+ Expect(len(affinityTrait)).To(Equal(2))
+ Expect(affinityTrait["enabled"]).To(Equal(true))
+ Expect(affinityTrait["nodeAffinityLabels"]).NotTo(BeNil())
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+ }
+
+ t.Run("Run Java with pod affinity", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name1,
+ "--name", "java2",
"-t", "affinity.enabled=true",
- "-t", fmt.Sprintf("affinity.node-affinity-labels=kubernetes.io/hostname in(%s)", hostname)).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name1), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name1, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name1), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ "-t", "affinity.pod-affinity-labels=camel.apache.org/integration").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "java2"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "java2", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "java2"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- pod := IntegrationPod(ns, name1)()
+ pod := IntegrationPod(ns, "java2")()
Expect(pod.Spec.Affinity).NotTo(BeNil())
- Expect(pod.Spec.Affinity.NodeAffinity).To(Equal(&corev1.NodeAffinity{
- RequiredDuringSchedulingIgnoredDuringExecution: nodeSelector("kubernetes.io/hostname", corev1.NodeSelectorOpIn, hostname),
+ Expect(pod.Spec.Affinity.PodAffinity).To(Equal(&corev1.PodAffinity{
+ RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
+ podAffinityTerm("camel.apache.org/integration", metav1.LabelSelectorOpExists, "kubernetes.io/hostname"),
+ },
}))
- Expect(pod.Spec.NodeName).To(Equal(hostname))
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, name1)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, name1)()
- affinityTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "affinity")
- Expect(affinityTrait).NotTo(BeNil())
- Expect(len(affinityTrait)).To(Equal(2))
- Expect(affinityTrait["enabled"]).To(Equal(true))
- Expect(affinityTrait["nodeAffinityLabels"]).NotTo(BeNil())
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
- }
-
- t.Run("Run Java with pod affinity", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", "java2",
- "-t", "affinity.enabled=true",
- "-t", "affinity.pod-affinity-labels=camel.apache.org/integration").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "java2"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "java2", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "java2"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- pod := IntegrationPod(ns, "java2")()
- Expect(pod.Spec.Affinity).NotTo(BeNil())
- Expect(pod.Spec.Affinity.PodAffinity).To(Equal(&corev1.PodAffinity{
- RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
- podAffinityTerm("camel.apache.org/integration", metav1.LabelSelectorOpExists, "kubernetes.io/hostname"),
- },
- }))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
+ t.Run("Run Java with pod anti affinity", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", "java3",
+ "-t", "affinity.enabled=true",
+ "-t", "affinity.pod-anti-affinity-labels=camel.apache.org/integration").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "java3"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "java3", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "java3"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- t.Run("Run Java with pod anti affinity", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", "java3",
- "-t", "affinity.enabled=true",
- "-t", "affinity.pod-anti-affinity-labels=camel.apache.org/integration").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "java3"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "java3", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "java3"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- pod := IntegrationPod(ns, "java3")()
- Expect(pod.Spec.Affinity).NotTo(BeNil())
- Expect(pod.Spec.Affinity.PodAntiAffinity).To(Equal(&corev1.PodAntiAffinity{
- RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
- podAffinityTerm("camel.apache.org/integration", metav1.LabelSelectorOpExists, "kubernetes.io/hostname"),
- },
- }))
+ pod := IntegrationPod(ns, "java3")()
+ Expect(pod.Spec.Affinity).NotTo(BeNil())
+ Expect(pod.Spec.Affinity.PodAntiAffinity).To(Equal(&corev1.PodAntiAffinity{
+ RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
+ podAffinityTerm("camel.apache.org/integration", metav1.LabelSelectorOpExists, "kubernetes.io/hostname"),
+ },
+ }))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
})
}
diff --git a/e2e/common/traits/builder_test.go b/e2e/common/traits/builder_test.go
index dea284e83..2fb24bcaf 100644
--- a/e2e/common/traits/builder_test.go
+++ b/e2e/common/traits/builder_test.go
@@ -37,249 +37,249 @@ import (
)
func TestBuilderTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Run build strategy routine", func(t *testing.T) {
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "builder.strategy=routine").Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- integrationKitName := IntegrationKit(ns, name)()
- integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().Strategy, TestTimeoutShort).Should(Equal(v1.BuildStrategyRoutine))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().OrderStrategy, TestTimeoutShort).Should(Equal(v1.BuildOrderStrategySequential))
- // Default resource CPU Check
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestCPU, TestTimeoutShort).Should(Equal(""))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitCPU, TestTimeoutShort).Should(Equal(""))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestMemory, TestTimeoutShort).Should(Equal(""))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitMemory, TestTimeoutShort).Should(Equal(""))
-
- Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).Should(BeNil())
-
- // We need to remove the kit as well
- Expect(Kamel("reset", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Run build order strategy dependencies", func(t *testing.T) {
- name := RandomizedSuffixName("java-dependencies-strategy")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "builder.order-strategy=dependencies").Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- integrationKitName := IntegrationKit(ns, name)()
- integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().Strategy, TestTimeoutShort).Should(Equal(v1.BuildStrategyRoutine))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().OrderStrategy, TestTimeoutShort).Should(Equal(v1.BuildOrderStrategyDependencies))
- // Default resource CPU Check
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestCPU, TestTimeoutShort).Should(Equal(""))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitCPU, TestTimeoutShort).Should(Equal(""))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestMemory, TestTimeoutShort).Should(Equal(""))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitMemory, TestTimeoutShort).Should(Equal(""))
-
- Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).Should(BeNil())
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, name)()
- builderTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "builder")
- Expect(builderTrait).NotTo(BeNil())
- Expect(len(builderTrait)).To(Equal(1))
- Expect(builderTrait["orderStrategy"]).To(Equal("dependencies"))
-
- // We need to remove the kit as well
- Expect(Kamel("reset", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Run build order strategy fifo", func(t *testing.T) {
- name := RandomizedSuffixName("java-fifo-strategy")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "builder.order-strategy=fifo").Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- integrationKitName := IntegrationKit(ns, name)()
- integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().Strategy, TestTimeoutShort).Should(Equal(v1.BuildStrategyRoutine))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().OrderStrategy, TestTimeoutShort).Should(Equal(v1.BuildOrderStrategyFIFO))
- // Default resource CPU Check
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestCPU, TestTimeoutShort).Should(Equal(""))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitCPU, TestTimeoutShort).Should(Equal(""))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestMemory, TestTimeoutShort).Should(Equal(""))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitMemory, TestTimeoutShort).Should(Equal(""))
-
- Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).Should(BeNil())
-
- // We need to remove the kit as well
- Expect(Kamel("reset", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Run build resources configuration", func(t *testing.T) {
- name := RandomizedSuffixName("java-resource-config")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "builder.tasks-request-cpu=builder:500m",
- "-t", "builder.tasks-limit-cpu=builder:1000m",
- "-t", "builder.tasks-request-memory=builder:2Gi",
- "-t", "builder.tasks-limit-memory=builder:3Gi",
- "-t", "builder.strategy=pod",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- integrationKitName := IntegrationKit(ns, name)()
- integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
-
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().Strategy, TestTimeoutShort).Should(Equal(v1.BuildStrategyPod))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().OrderStrategy, TestTimeoutShort).Should(Equal(v1.BuildOrderStrategySequential))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestCPU, TestTimeoutShort).Should(Equal("500m"))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitCPU, TestTimeoutShort).Should(Equal("1000m"))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestMemory, TestTimeoutShort).Should(Equal("2Gi"))
- Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitMemory, TestTimeoutShort).Should(Equal("3Gi"))
-
- Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).ShouldNot(BeNil())
- // Let's assert we set the resources on the builder container
- Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Name, TestTimeoutShort).Should(Equal("builder"))
- Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Resources.Requests.Cpu().String(), TestTimeoutShort).Should(Equal("500m"))
- Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Resources.Limits.Cpu().String(), TestTimeoutShort).Should(Equal("1"))
- Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Resources.Requests.Memory().String(), TestTimeoutShort).Should(Equal("2Gi"))
- Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Resources.Limits.Memory().String(), TestTimeoutShort).Should(Equal("3Gi"))
-
- Expect(Kamel("reset", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Run custom pipeline task", func(t *testing.T) {
- name := RandomizedSuffixName("java-pipeline")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "builder.tasks=custom1;alpine;tree",
- "-t", "builder.tasks=custom2;alpine;cat maven/pom.xml",
- "-t", "builder.strategy=pod",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- integrationKitName := IntegrationKit(ns, name)()
- integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
- Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).ShouldNot(BeNil())
- Eventually(len(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers), TestTimeoutShort).Should(Equal(4))
- Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Name, TestTimeoutShort).Should(Equal("builder"))
- Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[1].Name, TestTimeoutShort).Should(Equal("custom1"))
- Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[2].Name, TestTimeoutShort).Should(Equal("custom2"))
-
- // Check containers conditions
- Eventually(Build(integrationKitNamespace, integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
- Eventually(
- Build(
- integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Status,
- TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(
- Build(integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Message,
- TestTimeoutShort).Should(ContainSubstring("generated-bytecode.jar"))
- Eventually(Build(integrationKitNamespace, integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
- Eventually(
- Build(integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom2 succeeded")).Status,
- TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(
- Build(integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom2 succeeded")).Message,
- TestTimeoutShort).Should(ContainSubstring("</project>"))
-
- // Check logs
- Eventually(Logs(integrationKitNamespace, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`generated-bytecode.jar`))
- Eventually(Logs(integrationKitNamespace, builderKitName, corev1.PodLogOptions{Container: "custom2"})).Should(ContainSubstring(`<artifactId>camel-k-runtime-bom</artifactId>`))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Run custom pipeline task error", func(t *testing.T) {
- name := RandomizedSuffixName("java-error")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "builder.tasks=custom1;alpine;cat missingfile.txt",
- "-t", "builder.strategy=pod",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPhase(ns, name)).Should(Equal(v1.IntegrationPhaseBuildingKit))
- integrationKitName := IntegrationKit(ns, name)()
- integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- // Check containers conditions
- Eventually(Build(integrationKitNamespace, integrationKitName), TestTimeoutLong).ShouldNot(BeNil())
- Eventually(BuildConditions(integrationKitNamespace, integrationKitName), TestTimeoutLong).ShouldNot(BeNil())
- Eventually(BuildCondition(integrationKitNamespace, integrationKitName, v1.BuildConditionType("Container custom1 succeeded")), TestTimeoutMedium).ShouldNot(BeNil())
- Eventually(
- BuildCondition(integrationKitNamespace, integrationKitName, v1.BuildConditionType("Container custom1 succeeded"))().Status,
- TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
- Eventually(
- BuildCondition(integrationKitNamespace, integrationKitName, v1.BuildConditionType("Container custom1 succeeded"))().Message,
- TestTimeoutShort).Should(ContainSubstring("No such file or directory"))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Run maven profile", func(t *testing.T) {
- name := RandomizedSuffixName("java-maven-profile")
-
- mavenProfile1Cm := newMavenProfileConfigMap(ns, "maven-profile-owasp", "owasp-profile")
- Expect(TestClient().Create(TestContext, mavenProfile1Cm)).To(Succeed())
- mavenProfile2Cm := newMavenProfileConfigMap(ns, "maven-profile-dependency", "dependency-profile")
- Expect(TestClient().Create(TestContext, mavenProfile2Cm)).To(Succeed())
-
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "builder.maven-profiles=configmap:maven-profile-owasp/owasp-profile",
- "-t", "builder.maven-profiles=configmap:maven-profile-dependency/dependency-profile",
- "-t", "builder.tasks=custom1;alpine;cat maven/pom.xml",
- "-t", "builder.strategy=pod",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- integrationKitName := IntegrationKit(ns, name)()
- builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
- Eventually(BuilderPod(ns, builderKitName), TestTimeoutShort).ShouldNot(BeNil())
- Eventually(len(BuilderPod(ns, builderKitName)().Spec.InitContainers), TestTimeoutShort).Should(Equal(3))
- Eventually(BuilderPod(ns, builderKitName)().Spec.InitContainers[0].Name, TestTimeoutShort).Should(Equal("builder"))
- Eventually(BuilderPod(ns, builderKitName)().Spec.InitContainers[1].Name, TestTimeoutShort).Should(Equal("custom1"))
- Eventually(BuilderPod(ns, builderKitName)().Spec.InitContainers[2].Name, TestTimeoutShort).Should(Equal("package"))
-
- // Check containers conditions
- Eventually(Build(ns, integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
- Eventually(
- Build(ns, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Status,
- TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(
- Build(ns, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Message,
- TestTimeoutShort).Should(ContainSubstring("</project>"))
-
- // Check logs
- Eventually(Logs(ns, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`<id>owasp-profile</id>`))
- Eventually(Logs(ns, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`<id>dependency-profile</id>`))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- Expect(TestClient().Delete(TestContext, mavenProfile1Cm)).To(Succeed())
- Expect(TestClient().Delete(TestContext, mavenProfile2Cm)).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Run build strategy routine", func(t *testing.T) {
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "builder.strategy=routine").Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ integrationKitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().Strategy, TestTimeoutShort).Should(Equal(v1.BuildStrategyRoutine))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().OrderStrategy, TestTimeoutShort).Should(Equal(v1.BuildOrderStrategySequential))
+ // Default resource CPU Check
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestCPU, TestTimeoutShort).Should(Equal(""))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitCPU, TestTimeoutShort).Should(Equal(""))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestMemory, TestTimeoutShort).Should(Equal(""))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitMemory, TestTimeoutShort).Should(Equal(""))
+
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).Should(BeNil())
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Run build order strategy dependencies", func(t *testing.T) {
+ name := RandomizedSuffixName("java-dependencies-strategy")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "builder.order-strategy=dependencies").Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ integrationKitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().Strategy, TestTimeoutShort).Should(Equal(v1.BuildStrategyRoutine))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().OrderStrategy, TestTimeoutShort).Should(Equal(v1.BuildOrderStrategyDependencies))
+ // Default resource CPU Check
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestCPU, TestTimeoutShort).Should(Equal(""))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitCPU, TestTimeoutShort).Should(Equal(""))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestMemory, TestTimeoutShort).Should(Equal(""))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitMemory, TestTimeoutShort).Should(Equal(""))
+
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).Should(BeNil())
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, name)()
+ builderTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "builder")
+ Expect(builderTrait).NotTo(BeNil())
+ Expect(len(builderTrait)).To(Equal(1))
+ Expect(builderTrait["orderStrategy"]).To(Equal("dependencies"))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Run build order strategy fifo", func(t *testing.T) {
+ name := RandomizedSuffixName("java-fifo-strategy")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "builder.order-strategy=fifo").Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ integrationKitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().Strategy, TestTimeoutShort).Should(Equal(v1.BuildStrategyRoutine))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().OrderStrategy, TestTimeoutShort).Should(Equal(v1.BuildOrderStrategyFIFO))
+ // Default resource CPU Check
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestCPU, TestTimeoutShort).Should(Equal(""))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitCPU, TestTimeoutShort).Should(Equal(""))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestMemory, TestTimeoutShort).Should(Equal(""))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitMemory, TestTimeoutShort).Should(Equal(""))
+
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).Should(BeNil())
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Run build resources configuration", func(t *testing.T) {
+ name := RandomizedSuffixName("java-resource-config")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "builder.tasks-request-cpu=builder:500m",
+ "-t", "builder.tasks-limit-cpu=builder:1000m",
+ "-t", "builder.tasks-request-memory=builder:2Gi",
+ "-t", "builder.tasks-limit-memory=builder:3Gi",
+ "-t", "builder.strategy=pod",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ integrationKitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
+
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().Strategy, TestTimeoutShort).Should(Equal(v1.BuildStrategyPod))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().OrderStrategy, TestTimeoutShort).Should(Equal(v1.BuildOrderStrategySequential))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestCPU, TestTimeoutShort).Should(Equal("500m"))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitCPU, TestTimeoutShort).Should(Equal("1000m"))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().RequestMemory, TestTimeoutShort).Should(Equal("2Gi"))
+ Eventually(BuildConfig(integrationKitNamespace, integrationKitName)().LimitMemory, TestTimeoutShort).Should(Equal("3Gi"))
+
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).ShouldNot(BeNil())
+ // Let's assert we set the resources on the builder container
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Name, TestTimeoutShort).Should(Equal("builder"))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Resources.Requests.Cpu().String(), TestTimeoutShort).Should(Equal("500m"))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Resources.Limits.Cpu().String(), TestTimeoutShort).Should(Equal("1"))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Resources.Requests.Memory().String(), TestTimeoutShort).Should(Equal("2Gi"))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Resources.Limits.Memory().String(), TestTimeoutShort).Should(Equal("3Gi"))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Run custom pipeline task", func(t *testing.T) {
+ name := RandomizedSuffixName("java-pipeline")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "builder.tasks=custom1;alpine;tree",
+ "-t", "builder.tasks=custom2;alpine;cat maven/pom.xml",
+ "-t", "builder.strategy=pod",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ integrationKitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).ShouldNot(BeNil())
+ Eventually(len(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers), TestTimeoutShort).Should(Equal(4))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Name, TestTimeoutShort).Should(Equal("builder"))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[1].Name, TestTimeoutShort).Should(Equal("custom1"))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[2].Name, TestTimeoutShort).Should(Equal("custom2"))
+
+ // Check containers conditions
+ Eventually(Build(integrationKitNamespace, integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
+ Eventually(
+ Build(
+ integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Status,
+ TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(
+ Build(integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Message,
+ TestTimeoutShort).Should(ContainSubstring("generated-bytecode.jar"))
+ Eventually(Build(integrationKitNamespace, integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
+ Eventually(
+ Build(integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom2 succeeded")).Status,
+ TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(
+ Build(integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom2 succeeded")).Message,
+ TestTimeoutShort).Should(ContainSubstring("</project>"))
+
+ // Check logs
+ Eventually(Logs(integrationKitNamespace, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`generated-bytecode.jar`))
+ Eventually(Logs(integrationKitNamespace, builderKitName, corev1.PodLogOptions{Container: "custom2"})).Should(ContainSubstring(`<artifactId>camel-k-runtime-bom</artifactId>`))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Run custom pipeline task error", func(t *testing.T) {
+ name := RandomizedSuffixName("java-error")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "builder.tasks=custom1;alpine;cat missingfile.txt",
+ "-t", "builder.strategy=pod",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPhase(ns, name)).Should(Equal(v1.IntegrationPhaseBuildingKit))
+ integrationKitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ // Check containers conditions
+ Eventually(Build(integrationKitNamespace, integrationKitName), TestTimeoutLong).ShouldNot(BeNil())
+ Eventually(BuildConditions(integrationKitNamespace, integrationKitName), TestTimeoutLong).ShouldNot(BeNil())
+ Eventually(BuildCondition(integrationKitNamespace, integrationKitName, v1.BuildConditionType("Container custom1 succeeded")), TestTimeoutMedium).ShouldNot(BeNil())
+ Eventually(
+ BuildCondition(integrationKitNamespace, integrationKitName, v1.BuildConditionType("Container custom1 succeeded"))().Status,
+ TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
+ Eventually(
+ BuildCondition(integrationKitNamespace, integrationKitName, v1.BuildConditionType("Container custom1 succeeded"))().Message,
+ TestTimeoutShort).Should(ContainSubstring("No such file or directory"))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Run maven profile", func(t *testing.T) {
+ name := RandomizedSuffixName("java-maven-profile")
+
+ opns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)
+ mavenProfile1Cm := newMavenProfileConfigMap(opns, "maven-profile-owasp", "owasp-profile")
+ Expect(TestClient().Create(TestContext, mavenProfile1Cm)).To(Succeed())
+ mavenProfile2Cm := newMavenProfileConfigMap(opns, "maven-profile-dependency", "dependency-profile")
+ Expect(TestClient().Create(TestContext, mavenProfile2Cm)).To(Succeed())
+
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "builder.maven-profiles=configmap:maven-profile-owasp/owasp-profile",
+ "-t", "builder.maven-profiles=configmap:maven-profile-dependency/dependency-profile",
+ "-t", "builder.tasks=custom1;alpine;cat maven/pom.xml",
+ "-t", "builder.strategy=pod",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ integrationKitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ builderKitName := fmt.Sprintf("camel-k-%s-builder", integrationKitName)
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName), TestTimeoutShort).ShouldNot(BeNil())
+ Eventually(len(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers), TestTimeoutShort).Should(Equal(3))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Name, TestTimeoutShort).Should(Equal("builder"))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[1].Name, TestTimeoutShort).Should(Equal("custom1"))
+ Eventually(BuilderPod(integrationKitNamespace, builderKitName)().Spec.InitContainers[2].Name, TestTimeoutShort).Should(Equal("package"))
+
+ // Check containers conditions
+ Eventually(Build(integrationKitNamespace, integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
+ Eventually(
+ Build(integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Status,
+ TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(
+ Build(integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Message,
+ TestTimeoutShort).Should(ContainSubstring("</project>"))
+
+ // Check logs
+ Eventually(Logs(integrationKitNamespace, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`<id>owasp-profile</id>`))
+ Eventually(Logs(integrationKitNamespace, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`<id>dependency-profile</id>`))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(TestClient().Delete(TestContext, mavenProfile1Cm)).To(Succeed())
+ Expect(TestClient().Delete(TestContext, mavenProfile2Cm)).To(Succeed())
+ })
})
}
diff --git a/e2e/common/traits/camel_test.go b/e2e/common/traits/camel_test.go
index f431b5b58..1cce0aa5b 100644
--- a/e2e/common/traits/camel_test.go
+++ b/e2e/common/traits/camel_test.go
@@ -34,36 +34,37 @@ import (
)
func TestCamelTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("properties changes should not rebuild", func(t *testing.T) {
-
- Expect(Kamel("reset", "-n", ns).Execute()).To(Succeed())
-
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- ).Execute()).To(Succeed())
-
- // checking the integration status
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- integrationKit := IntegrationKit(ns, name)()
-
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-p", "a=1",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Eventually(IntegrationKit(ns, name)).Should(Equal(integrationKit))
-
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("properties changes should not rebuild", func(t *testing.T) {
+
+ Expect(Kamel("reset", "-n", ns).Execute()).To(Succeed())
+
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ ).Execute()).To(Succeed())
+
+ // checking the integration status
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ integrationKit := IntegrationKit(ns, name)()
+
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-p", "a=1",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ Eventually(IntegrationKit(ns, name)).Should(Equal(integrationKit))
+
+ Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+ Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil())
+ })
+
+ // Clean-up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- // Clean-up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/traits/container_test.go b/e2e/common/traits/container_test.go
index 6bd6ba4ec..8fa216fe8 100644
--- a/e2e/common/traits/container_test.go
+++ b/e2e/common/traits/container_test.go
@@ -35,75 +35,76 @@ import (
)
func TestContainerTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Container image pull policy and resources configuration", func(t *testing.T) {
- name := RandomizedSuffixName("java1")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "-t", "container.image-pull-policy=Always",
- "-t", "container.request-cpu=0.005",
- "-t", "container.request-memory=100Mi",
- "-t", "container.limit-cpu=200m",
- "-t", "container.limit-memory=500Mi",
- "--name", name,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
- if len(pod.Spec.Containers) != 1 {
- return false
- }
- imagePullPolicy := pod.Spec.Containers[0].ImagePullPolicy
- return imagePullPolicy == "Always"
- }), TestTimeoutShort).Should(BeTrue())
- Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
- if len(pod.Spec.Containers) != 1 {
- return false
- }
- limitsCpu := pod.Spec.Containers[0].Resources.Limits.Cpu()
- requestsCpu := pod.Spec.Containers[0].Resources.Requests.Cpu()
- return limitsCpu != nil && limitsCpu.String() == "200m" && requestsCpu != nil && requestsCpu.String() == "5m"
- }), TestTimeoutShort).Should(BeTrue())
- Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
- if len(pod.Spec.Containers) != 1 {
- return false
- }
- limitsMemory := pod.Spec.Containers[0].Resources.Limits.Memory()
- requestsMemory := pod.Spec.Containers[0].Resources.Requests.Memory()
- return limitsMemory != nil && limitsMemory.String() == "500Mi" && requestsMemory != nil && requestsMemory.String() == "100Mi"
- }), TestTimeoutShort).Should(BeTrue())
-
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Container image pull policy and resources configuration", func(t *testing.T) {
+ name := RandomizedSuffixName("java1")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "-t", "container.image-pull-policy=Always",
+ "-t", "container.request-cpu=0.005",
+ "-t", "container.request-memory=100Mi",
+ "-t", "container.limit-cpu=200m",
+ "-t", "container.limit-memory=500Mi",
+ "--name", name,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
+ if len(pod.Spec.Containers) != 1 {
+ return false
+ }
+ imagePullPolicy := pod.Spec.Containers[0].ImagePullPolicy
+ return imagePullPolicy == "Always"
+ }), TestTimeoutShort).Should(BeTrue())
+ Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
+ if len(pod.Spec.Containers) != 1 {
+ return false
+ }
+ limitsCpu := pod.Spec.Containers[0].Resources.Limits.Cpu()
+ requestsCpu := pod.Spec.Containers[0].Resources.Requests.Cpu()
+ return limitsCpu != nil && limitsCpu.String() == "200m" && requestsCpu != nil && requestsCpu.String() == "5m"
+ }), TestTimeoutShort).Should(BeTrue())
+ Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
+ if len(pod.Spec.Containers) != 1 {
+ return false
+ }
+ limitsMemory := pod.Spec.Containers[0].Resources.Limits.Memory()
+ requestsMemory := pod.Spec.Containers[0].Resources.Requests.Memory()
+ return limitsMemory != nil && limitsMemory.String() == "500Mi" && requestsMemory != nil && requestsMemory.String() == "100Mi"
+ }), TestTimeoutShort).Should(BeTrue())
+
+ })
+
+ t.Run("Container name", func(t *testing.T) {
+ name := RandomizedSuffixName("java2")
+ containerName := "my-container-name"
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "-t", "container.name="+containerName,
+ "--name", name,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
+ if len(pod.Spec.Containers) != 1 {
+ return false
+ }
+ podContainerName := pod.Spec.Containers[0].Name
+ return podContainerName == containerName
+ }), TestTimeoutShort).Should(BeTrue())
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, name)()
+ containerTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "container")
+ Expect(containerTrait).ToNot(BeNil())
+ Expect(len(containerTrait)).To(Equal(1))
+ Expect(containerTrait["name"]).To(Equal(containerName))
+
+ })
+
+ // Clean-up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- t.Run("Container name", func(t *testing.T) {
- name := RandomizedSuffixName("java2")
- containerName := "my-container-name"
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "-t", "container.name="+containerName,
- "--name", name,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
- if len(pod.Spec.Containers) != 1 {
- return false
- }
- podContainerName := pod.Spec.Containers[0].Name
- return podContainerName == containerName
- }), TestTimeoutShort).Should(BeTrue())
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, name)()
- containerTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "container")
- Expect(containerTrait).ToNot(BeNil())
- Expect(len(containerTrait)).To(Equal(1))
- Expect(containerTrait["name"]).To(Equal(containerName))
-
- })
-
- // Clean-up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/traits/default.go b/e2e/common/traits/default.go
index 59a520c86..bc4034843 100644
--- a/e2e/common/traits/default.go
+++ b/e2e/common/traits/default.go
@@ -20,7 +20,10 @@ limitations under the License.
package traits
-import "github.com/apache/camel-k/v2/e2e/support"
+import (
+ "github.com/apache/camel-k/v2/e2e/support"
+ "github.com/apache/camel-k/v2/pkg/platform"
+)
-var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.GetCIProcessID())
-var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", support.GetCIProcessID())
+var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.TestDefaultNamespace)
+var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", platform.DefaultPlatformName)
diff --git a/e2e/common/traits/deployment_test.go b/e2e/common/traits/deployment_test.go
index 08a589e5e..9a5e24117 100644
--- a/e2e/common/traits/deployment_test.go
+++ b/e2e/common/traits/deployment_test.go
@@ -38,68 +38,70 @@ import (
)
func TestRecreateDeploymentStrategyTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Run with Recreate Deployment Strategy", func(t *testing.T) {
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "deployment.strategy="+string(appsv1.RecreateDeploymentStrategyType)).
- Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- Eventually(Deployment(ns, name), TestTimeoutMedium).Should(PointTo(MatchFields(IgnoreExtras,
- Fields{
- "Spec": MatchFields(IgnoreExtras,
- Fields{
- "Strategy": MatchFields(IgnoreExtras,
- Fields{
- "Type": Equal(appsv1.RecreateDeploymentStrategyType),
- }),
- }),
- }),
- ))
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, name)()
- deploymentTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "deployment")
- Expect(deploymentTrait).ToNot(BeNil())
- Expect(len(deploymentTrait)).To(Equal(1))
- Expect(deploymentTrait["strategy"]).To(Equal(string(appsv1.RecreateDeploymentStrategyType)))
-
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Run with Recreate Deployment Strategy", func(t *testing.T) {
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "deployment.strategy="+string(appsv1.RecreateDeploymentStrategyType)).
+ Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ Eventually(Deployment(ns, name), TestTimeoutMedium).Should(PointTo(MatchFields(IgnoreExtras,
+ Fields{
+ "Spec": MatchFields(IgnoreExtras,
+ Fields{
+ "Strategy": MatchFields(IgnoreExtras,
+ Fields{
+ "Type": Equal(appsv1.RecreateDeploymentStrategyType),
+ }),
+ }),
+ }),
+ ))
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, name)()
+ deploymentTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "deployment")
+ Expect(deploymentTrait).ToNot(BeNil())
+ Expect(len(deploymentTrait)).To(Equal(1))
+ Expect(deploymentTrait["strategy"]).To(Equal(string(appsv1.RecreateDeploymentStrategyType)))
+
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
func TestRollingUpdateDeploymentStrategyTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Run with RollingUpdate Deployment Strategy", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "-t", "deployment.strategy="+string(appsv1.RollingUpdateDeploymentStrategyType)).
- Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- Eventually(Deployment(ns, "java"), TestTimeoutMedium).Should(PointTo(MatchFields(IgnoreExtras,
- Fields{
- "Spec": MatchFields(IgnoreExtras,
- Fields{
- "Strategy": MatchFields(IgnoreExtras,
- Fields{
- "Type": Equal(appsv1.RollingUpdateDeploymentStrategyType),
- }),
- }),
- }),
- ))
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Run with RollingUpdate Deployment Strategy", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "-t", "deployment.strategy="+string(appsv1.RollingUpdateDeploymentStrategyType)).
+ Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ Eventually(Deployment(ns, "java"), TestTimeoutMedium).Should(PointTo(MatchFields(IgnoreExtras,
+ Fields{
+ "Spec": MatchFields(IgnoreExtras,
+ Fields{
+ "Strategy": MatchFields(IgnoreExtras,
+ Fields{
+ "Type": Equal(appsv1.RollingUpdateDeploymentStrategyType),
+ }),
+ }),
+ }),
+ ))
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/traits/error_handler_test.go b/e2e/common/traits/error_handler_test.go
index 081a9f542..68f0c0cb0 100644
--- a/e2e/common/traits/error_handler_test.go
+++ b/e2e/common/traits/error_handler_test.go
@@ -34,20 +34,21 @@ import (
)
func TestErrorHandlerTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Run errored integration with error handler", func(t *testing.T) {
- name := RandomizedSuffixName("error-handler")
- Expect(KamelRunWithID(operatorID, ns, "files/ErroredRoute.java",
- "--name", name,
- "-t", "error-handler.enabled=true",
- "-t", "error-handler.ref=defaultErrorHandler",
- "-p", "camel.beans.defaultErrorHandler=#class:org.apache.camel.builder.DeadLetterChannelBuilder",
- "-p", "camel.beans.defaultErrorHandler.deadLetterUri=log:my-special-error-handler-in-place?level=ERROR&showCaughtException=false&showBody=false&showBodyType=false&showExchangePattern=false",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).ShouldNot(ContainSubstring("InvalidPayloadException"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("my-special-error-handler-in-place"))
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Run errored integration with error handler", func(t *testing.T) {
+ name := RandomizedSuffixName("error-handler")
+ Expect(KamelRunWithID(operatorID, ns, "files/ErroredRoute.java",
+ "--name", name,
+ "-t", "error-handler.enabled=true",
+ "-t", "error-handler.ref=defaultErrorHandler",
+ "-p", "camel.beans.defaultErrorHandler=#class:org.apache.camel.builder.DeadLetterChannelBuilder",
+ "-p", "camel.beans.defaultErrorHandler.deadLetterUri=log:my-special-error-handler-in-place?level=ERROR&showCaughtException=false&showBody=false&showBodyType=false&showExchangePattern=false",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).ShouldNot(ContainSubstring("InvalidPayloadException"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("my-special-error-handler-in-place"))
+ })
})
}
diff --git a/e2e/common/traits/errored_trait_test.go b/e2e/common/traits/errored_trait_test.go
index 80cb6a4de..3a01aace1 100644
--- a/e2e/common/traits/errored_trait_test.go
+++ b/e2e/common/traits/errored_trait_test.go
@@ -34,45 +34,46 @@ import (
)
func TestErroredTrait(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("Integration trait should fail", func(t *testing.T) {
- name := RandomizedSuffixName("it-errored")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "kamelets.list=missing",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionInitializationFailedReason)),
- WithTransform(IntegrationConditionMessage, HavePrefix("error during trait customization")),
- ))
- })
+ t.Run("Integration trait should fail", func(t *testing.T) {
+ name := RandomizedSuffixName("it-errored")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "kamelets.list=missing",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionInitializationFailedReason)),
+ WithTransform(IntegrationConditionMessage, HavePrefix("error during trait customization")),
+ ))
+ })
- t.Run("Pipe trait should fail", func(t *testing.T) {
- name := RandomizedSuffixName("kb-errored")
- Expect(KamelBindWithID(operatorID, ns, "timer:foo", "log:bar",
- "--name", name,
- "-t", "kamelets.list=missing",
- ).Execute()).To(Succeed())
- // Pipe
- Eventually(PipePhase(ns, name), TestTimeoutShort).Should(Equal(v1.PipePhaseError))
- Eventually(PipeConditionStatus(ns, name, v1.PipeConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
- Eventually(PipeCondition(ns, name, v1.PipeConditionReady), TestTimeoutShort).Should(
- WithTransform(PipeConditionMessage, And(
- ContainSubstring("error during trait customization"),
- ContainSubstring("[missing] not found"),
- )))
- // Integration related
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionInitializationFailedReason)),
- WithTransform(IntegrationConditionMessage, HavePrefix("error during trait customization")),
- ))
- })
+ t.Run("Pipe trait should fail", func(t *testing.T) {
+ name := RandomizedSuffixName("kb-errored")
+ Expect(KamelBindWithID(operatorID, ns, "timer:foo", "log:bar",
+ "--name", name,
+ "-t", "kamelets.list=missing",
+ ).Execute()).To(Succeed())
+ // Pipe
+ Eventually(PipePhase(ns, name), TestTimeoutShort).Should(Equal(v1.PipePhaseError))
+ Eventually(PipeConditionStatus(ns, name, v1.PipeConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
+ Eventually(PipeCondition(ns, name, v1.PipeConditionReady), TestTimeoutShort).Should(
+ WithTransform(PipeConditionMessage, And(
+ ContainSubstring("error during trait customization"),
+ ContainSubstring("[missing] not found"),
+ )))
+ // Integration related
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionInitializationFailedReason)),
+ WithTransform(IntegrationConditionMessage, HavePrefix("error during trait customization")),
+ ))
+ })
- // Clean up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ // Clean up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/traits/health_test.go b/e2e/common/traits/health_test.go
index 6cbdefb36..69a61c73f 100644
--- a/e2e/common/traits/health_test.go
+++ b/e2e/common/traits/health_test.go
@@ -43,47 +43,133 @@ import (
)
func TestHealthTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Readiness condition with stopped route scaled", func(t *testing.T) {
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "-t", "health.enabled=true",
- // Enable Jolokia for the test to stop the Camel route
- "-t", "jolokia.enabled=true",
- "-t", "jolokia.use-ssl-client-authentication=false",
- "-t", "jolokia.protocol=http",
- "--name", name,
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- Expect(ScaleIntegration(ns, name, 3)).To(Succeed())
- // Check the readiness condition becomes falsy
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
- // Check the scale cascades into the Deployment scale
- Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(3))
- // Check it also cascades into the Integration scale subresource Status field
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(gstruct.PointTo(BeNumerically("==", 3)))
- // Finally check the readiness condition becomes truthy back
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, name)()
- healthTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "health")
- Expect(healthTrait).ToNot(BeNil())
- Expect(len(healthTrait)).To(Equal(1))
- Expect(healthTrait["enabled"]).To(Equal(true))
-
- pods := IntegrationPods(ns, name)()
-
- for i, pod := range pods {
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Readiness condition with stopped route scaled", func(t *testing.T) {
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "-t", "health.enabled=true",
+ // Enable Jolokia for the test to stop the Camel route
+ "-t", "jolokia.enabled=true",
+ "-t", "jolokia.use-ssl-client-authentication=false",
+ "-t", "jolokia.protocol=http",
+ "--name", name,
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ Expect(ScaleIntegration(ns, name, 3)).To(Succeed())
+ // Check the readiness condition becomes falsy
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
+ // Check the scale cascades into the Deployment scale
+ Eventually(IntegrationPods(ns, name), TestTimeoutShort).Should(HaveLen(3))
+ // Check it also cascades into the Integration scale subresource Status field
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(gstruct.PointTo(BeNumerically("==", 3)))
+ // Finally check the readiness condition becomes truthy back
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, name)()
+ healthTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "health")
+ Expect(healthTrait).ToNot(BeNil())
+ Expect(len(healthTrait)).To(Equal(1))
+ Expect(healthTrait["enabled"]).To(Equal(true))
+
+ pods := IntegrationPods(ns, name)()
+
+ for i, pod := range pods {
+ // Stop the Camel route
+ request := map[string]string{
+ "type": "exec",
+ "mbean": "org.apache.camel:context=camel-1,name=\"route1\",type=routes",
+ "operation": "stop()",
+ }
+ body, err := json.Marshal(request)
+ Expect(err).To(BeNil())
+
+ response, err := TestClient().CoreV1().RESTClient().Post().
+ AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/jolokia/", ns, pod.Name)).
+ Body(body).
+ DoRaw(TestContext)
+ Expect(err).To(BeNil())
+ Expect(response).To(ContainSubstring(`"status":200`))
+
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionFalse))
+
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
+ WithTransform(IntegrationConditionMessage, Equal(fmt.Sprintf("%d/3 pods are not ready", i+1)))))
+ }
+
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
+ Satisfy(func(c *v1.IntegrationCondition) bool {
+ if c.Status != corev1.ConditionFalse {
+ return false
+ }
+ if len(c.Pods) != 3 {
+ return false
+ }
+
+ var r *v1.HealthCheckResponse
+
+ for _, pod := range c.Pods {
+ for h := range pod.Health {
+ if pod.Health[h].Name == "camel-routes" {
+ r = &pod.Health[h]
+ }
+ }
+
+ if r == nil {
+ return false
+ }
+
+ if r.Data == nil {
+ return false
+ }
+
+ var data map[string]interface{}
+ if err := json.Unmarshal(r.Data, &data); err != nil {
+ return false
+ }
+ if data["check.kind"].(string) != "READINESS" || data["route.status"].(string) != "Stopped" {
+ return false
+ }
+ }
+ return true
+ }))
+
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+
+ // Clean-up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Readiness condition with stopped route", func(t *testing.T) {
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "-t", "health.enabled=true",
+ // Enable Jolokia for the test to stop the Camel route
+ "-t", "jolokia.enabled=true",
+ "-t", "jolokia.use-ssl-client-authentication=false",
+ "-t", "jolokia.protocol=http",
+ "--name", name,
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ pod := IntegrationPod(ns, name)()
+
// Stop the Camel route
request := map[string]string{
"type": "exec",
@@ -100,29 +186,40 @@ func TestHealthTrait(t *testing.T) {
Expect(err).To(BeNil())
Expect(response).To(ContainSubstring(`"status":200`))
+ // Check the ready condition has turned false
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionFalse))
-
+ // And it contains details about the runtime state
+
+ //
+ // TODO
+ // Integration has different runtime state reporting on OCP4
+ //
+ // lastProbeTime: null
+ // lastTransitionTime: "2021-12-08T20:12:14Z"
+ // message: 'containers with unready status: [integration]'
+ // reason: ContainersNotReady
+ // status: "False"
+ // type: Ready
+ //
Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
- WithTransform(IntegrationConditionMessage, Equal(fmt.Sprintf("%d/3 pods are not ready", i+1)))))
- }
+ WithTransform(IntegrationConditionMessage, Equal("1/1 pods are not ready"))))
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
- Satisfy(func(c *v1.IntegrationCondition) bool {
- if c.Status != corev1.ConditionFalse {
- return false
- }
- if len(c.Pods) != 3 {
- return false
- }
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
+ Satisfy(func(c *v1.IntegrationCondition) bool {
+ if c.Status != corev1.ConditionFalse {
+ return false
+ }
+ if len(c.Pods) != 1 {
+ return false
+ }
- var r *v1.HealthCheckResponse
+ var r *v1.HealthCheckResponse
- for _, pod := range c.Pods {
- for h := range pod.Health {
- if pod.Health[h].Name == "camel-routes" {
- r = &pod.Health[h]
+ for h := range c.Pods[0].Health {
+ if c.Pods[0].Health[h].Name == "camel-routes" {
+ r = &c.Pods[0].Health[h]
}
}
@@ -138,378 +235,282 @@ func TestHealthTrait(t *testing.T) {
if err := json.Unmarshal(r.Data, &data); err != nil {
return false
}
- if data["check.kind"].(string) != "READINESS" || data["route.status"].(string) != "Stopped" {
- return false
- }
- }
- return true
- }))
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+ return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped"
+ }))
- // Clean-up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
- t.Run("Readiness condition with stopped route", func(t *testing.T) {
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "-t", "health.enabled=true",
- // Enable Jolokia for the test to stop the Camel route
- "-t", "jolokia.enabled=true",
- "-t", "jolokia.use-ssl-client-authentication=false",
- "-t", "jolokia.protocol=http",
- "--name", name,
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- pod := IntegrationPod(ns, name)()
-
- // Stop the Camel route
- request := map[string]string{
- "type": "exec",
- "mbean": "org.apache.camel:context=camel-1,name=\"route1\",type=routes",
- "operation": "stop()",
- }
- body, err := json.Marshal(request)
- Expect(err).To(BeNil())
-
- response, err := TestClient().CoreV1().RESTClient().Post().
- AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/jolokia/", ns, pod.Name)).
- Body(body).
- DoRaw(TestContext)
- Expect(err).To(BeNil())
- Expect(response).To(ContainSubstring(`"status":200`))
-
- // Check the ready condition has turned false
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionFalse))
- // And it contains details about the runtime state
-
- //
- // TODO
- // Integration has different runtime state reporting on OCP4
- //
- // lastProbeTime: null
- // lastTransitionTime: "2021-12-08T20:12:14Z"
- // message: 'containers with unready status: [integration]'
- // reason: ContainersNotReady
- // status: "False"
- // type: Ready
- //
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
- WithTransform(IntegrationConditionMessage, Equal("1/1 pods are not ready"))))
-
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
- Satisfy(func(c *v1.IntegrationCondition) bool {
- if c.Status != corev1.ConditionFalse {
- return false
- }
- if len(c.Pods) != 1 {
- return false
- }
+ // Clean-up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
- var r *v1.HealthCheckResponse
+ t.Run("Readiness condition with stopped binding", func(t *testing.T) {
+ name := RandomizedSuffixName("stopped-binding")
+ source := RandomizedSuffixName("my-health-timer-source")
+ sink := RandomizedSuffixName("my-health-log-sink")
+
+ Expect(CreateTimerKamelet(ns, source)()).To(Succeed())
+ Expect(CreateLogKamelet(ns, sink)()).To(Succeed())
+
+ Expect(KamelBindWithID(operatorID, ns,
+ source,
+ sink,
+ "-p", "source.message=Magicstring!",
+ "-p", "sink.loggerName=binding",
+ "--annotation", "trait.camel.apache.org/health.enabled=true",
+ "--annotation", "trait.camel.apache.org/jolokia.enabled=true",
+ "--annotation", "trait.camel.apache.org/jolokia.use-ssl-client-authentication=false",
+ "--annotation", "trait.camel.apache.org/jolokia.protocol=http",
+ "--name", name,
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ pod := IntegrationPod(ns, name)()
- for h := range c.Pods[0].Health {
- if c.Pods[0].Health[h].Name == "camel-routes" {
- r = &c.Pods[0].Health[h]
- }
- }
+ // Stop the Camel route
+ request := map[string]string{
+ "type": "exec",
+ "mbean": "org.apache.camel:context=camel-1,name=\"binding\",type=routes",
+ "operation": "stop()",
+ }
+ body, err := json.Marshal(request)
+ Expect(err).To(BeNil())
- if r == nil {
- return false
- }
+ response, err := TestClient().CoreV1().RESTClient().Post().
+ AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/jolokia/", ns, pod.Name)).
+ Body(body).
+ DoRaw(TestContext)
- if r.Data == nil {
- return false
- }
+ Expect(err).To(BeNil())
+ Expect(response).To(ContainSubstring(`"status":200`))
- var data map[string]interface{}
- if err := json.Unmarshal(r.Data, &data); err != nil {
- return false
- }
+ // Check the ready condition has turned false
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionFalse))
+ // And it contains details about the runtime state
- return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped"
- }))
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
+ WithTransform(IntegrationConditionMessage, Equal("1/1 pods are not ready"))))
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
+ Satisfy(func(c *v1.IntegrationCondition) bool {
+ if c.Status != corev1.ConditionFalse {
+ return false
+ }
+ if len(c.Pods) != 1 {
+ return false
+ }
- // Clean-up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
+ var r *v1.HealthCheckResponse
- t.Run("Readiness condition with stopped binding", func(t *testing.T) {
- name := RandomizedSuffixName("stopped-binding")
- source := RandomizedSuffixName("my-health-timer-source")
- sink := RandomizedSuffixName("my-health-log-sink")
-
- Expect(CreateTimerKamelet(ns, source)()).To(Succeed())
- Expect(CreateLogKamelet(ns, sink)()).To(Succeed())
-
- Expect(KamelBindWithID(operatorID, ns,
- source,
- sink,
- "-p", "source.message=Magicstring!",
- "-p", "sink.loggerName=binding",
- "--annotation", "trait.camel.apache.org/health.enabled=true",
- "--annotation", "trait.camel.apache.org/jolokia.enabled=true",
- "--annotation", "trait.camel.apache.org/jolokia.use-ssl-client-authentication=false",
- "--annotation", "trait.camel.apache.org/jolokia.protocol=http",
- "--name", name,
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- pod := IntegrationPod(ns, name)()
-
- // Stop the Camel route
- request := map[string]string{
- "type": "exec",
- "mbean": "org.apache.camel:context=camel-1,name=\"binding\",type=routes",
- "operation": "stop()",
- }
- body, err := json.Marshal(request)
- Expect(err).To(BeNil())
-
- response, err := TestClient().CoreV1().RESTClient().Post().
- AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/jolokia/", ns, pod.Name)).
- Body(body).
- DoRaw(TestContext)
-
- Expect(err).To(BeNil())
- Expect(response).To(ContainSubstring(`"status":200`))
-
- // Check the ready condition has turned false
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionFalse))
- // And it contains details about the runtime state
-
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
- WithTransform(IntegrationConditionMessage, Equal("1/1 pods are not ready"))))
-
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
- Satisfy(func(c *v1.IntegrationCondition) bool {
- if c.Status != corev1.ConditionFalse {
- return false
- }
- if len(c.Pods) != 1 {
- return false
- }
+ for h := range c.Pods[0].Health {
+ if c.Pods[0].Health[h].Name == "camel-routes" {
+ r = &c.Pods[0].Health[h]
+ }
+ }
- var r *v1.HealthCheckResponse
+ if r == nil {
+ return false
+ }
- for h := range c.Pods[0].Health {
- if c.Pods[0].Health[h].Name == "camel-routes" {
- r = &c.Pods[0].Health[h]
+ if r.Data == nil {
+ return false
}
- }
- if r == nil {
- return false
- }
+ var data map[string]interface{}
+ if err := json.Unmarshal(r.Data, &data); err != nil {
+ return false
+ }
- if r.Data == nil {
- return false
- }
+ return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped" && data["route.id"].(string) == "binding"
+ }))
- var data map[string]interface{}
- if err := json.Unmarshal(r.Data, &data); err != nil {
- return false
- }
+ Eventually(PipeCondition(ns, name, camelv1.PipeConditionReady), TestTimeoutLong).Should(
+ Satisfy(func(c *camelv1.PipeCondition) bool {
+ if c.Status != corev1.ConditionFalse {
+ return false
+ }
+ if len(c.Pods) != 1 {
+ return false
+ }
- return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped" && data["route.id"].(string) == "binding"
- }))
+ var r *v1.HealthCheckResponse
- Eventually(PipeCondition(ns, name, camelv1.PipeConditionReady), TestTimeoutLong).Should(
- Satisfy(func(c *camelv1.PipeCondition) bool {
- if c.Status != corev1.ConditionFalse {
- return false
- }
- if len(c.Pods) != 1 {
- return false
- }
+ for h := range c.Pods[0].Health {
+ if c.Pods[0].Health[h].Name == "camel-routes" {
+ r = &c.Pods[0].Health[h]
+ }
+ }
- var r *v1.HealthCheckResponse
+ if r == nil {
+ return false
+ }
- for h := range c.Pods[0].Health {
- if c.Pods[0].Health[h].Name == "camel-routes" {
- r = &c.Pods[0].Health[h]
+ if r.Data == nil {
+ return false
}
- }
- if r == nil {
- return false
- }
+ var data map[string]interface{}
+ if err := json.Unmarshal(r.Data, &data); err != nil {
+ return false
+ }
- if r.Data == nil {
- return false
- }
+ return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped" && data["route.id"].(string) == "binding"
+ }))
- var data map[string]interface{}
- if err := json.Unmarshal(r.Data, &data); err != nil {
- return false
- }
+ // Clean-up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(DeleteKamelet(ns, source)).To(Succeed())
+ Expect(DeleteKamelet(ns, sink)).To(Succeed())
+ })
- return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped" && data["route.id"].(string) == "binding"
- }))
+ t.Run("Readiness condition with never ready route", func(t *testing.T) {
+ name := RandomizedSuffixName("never-ready")
- // Clean-up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- Expect(DeleteKamelet(ns, source)).To(Succeed())
- Expect(DeleteKamelet(ns, sink)).To(Succeed())
- })
+ Expect(KamelRunWithID(operatorID, ns, "files/NeverReady.java",
+ "--name", name,
+ "-t", "health.enabled=true",
+ ).Execute()).To(Succeed())
- t.Run("Readiness condition with never ready route", func(t *testing.T) {
- name := RandomizedSuffixName("never-ready")
-
- Expect(KamelRunWithID(operatorID, ns, "files/NeverReady.java",
- "--name", name,
- "-t", "health.enabled=true",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
- Consistently(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), 1*time.Minute).
- Should(Equal(corev1.ConditionFalse))
- Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
-
- // Check that the error message is propagated from health checks even if deployment never becomes ready
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
- WithTransform(IntegrationConditionMessage, Equal("1/1 pods are not ready"))))
-
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
- Satisfy(func(c *v1.IntegrationCondition) bool {
- if c.Status != corev1.ConditionFalse {
- return false
- }
- if len(c.Pods) != 1 {
- return false
- }
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
+ Consistently(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), 1*time.Minute).
+ Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
- var r *v1.HealthCheckResponse
+ // Check that the error message is propagated from health checks even if deployment never becomes ready
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
+ WithTransform(IntegrationConditionMessage, Equal("1/1 pods are not ready"))))
- for h := range c.Pods[0].Health {
- if c.Pods[0].Health[h].Name == "camel-routes" {
- r = &c.Pods[0].Health[h]
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
+ Satisfy(func(c *v1.IntegrationCondition) bool {
+ if c.Status != corev1.ConditionFalse {
+ return false
+ }
+ if len(c.Pods) != 1 {
+ return false
}
- }
- if r == nil {
- return false
- }
+ var r *v1.HealthCheckResponse
- if r.Data == nil {
- return false
- }
+ for h := range c.Pods[0].Health {
+ if c.Pods[0].Health[h].Name == "camel-routes" {
+ r = &c.Pods[0].Health[h]
+ }
+ }
- var data map[string]interface{}
- if err := json.Unmarshal(r.Data, &data); err != nil {
- return false
- }
+ if r == nil {
+ return false
+ }
- return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped" && data["route.id"].(string) == "never-ready"
- }))
- })
+ if r.Data == nil {
+ return false
+ }
- t.Run("Startup condition with never ready route", func(t *testing.T) {
- name := RandomizedSuffixName("startup-probe-never-ready-route")
-
- Expect(KamelRunWithID(operatorID, ns, "files/NeverReady.java",
- "--name", name,
- "-t", "health.enabled=true",
- "-t", "health.startup-probe-enabled=true",
- "-t", "health.startup-timeout=60",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPhase(ns, name), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning))
- Consistently(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), 1*time.Minute).Should(Equal(corev1.ConditionFalse))
- Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
-
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
- WithTransform(IntegrationConditionMessage, Equal("1/1 pods are not ready"))))
-
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
- Satisfy(func(c *v1.IntegrationCondition) bool {
- if c.Status != corev1.ConditionFalse {
- return false
- }
- if len(c.Pods) != 1 {
- return false
- }
+ var data map[string]interface{}
+ if err := json.Unmarshal(r.Data, &data); err != nil {
+ return false
+ }
- var r *v1.HealthCheckResponse
+ return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped" && data["route.id"].(string) == "never-ready"
+ }))
+ })
+
+ t.Run("Startup condition with never ready route", func(t *testing.T) {
+ name := RandomizedSuffixName("startup-probe-never-ready-route")
+
+ Expect(KamelRunWithID(operatorID, ns, "files/NeverReady.java",
+ "--name", name,
+ "-t", "health.enabled=true",
+ "-t", "health.startup-probe-enabled=true",
+ "-t", "health.startup-timeout=60",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning))
+ Consistently(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), 1*time.Minute).Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
+
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
+ WithTransform(IntegrationConditionMessage, Equal("1/1 pods are not ready"))))
- for h := range c.Pods[0].Health {
- if c.Pods[0].Health[h].Name == "camel-routes" && c.Pods[0].Health[h].Status == "DOWN" {
- r = &c.Pods[0].Health[h]
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(
+ Satisfy(func(c *v1.IntegrationCondition) bool {
+ if c.Status != corev1.ConditionFalse {
+ return false
+ }
+ if len(c.Pods) != 1 {
+ return false
}
- }
- if r == nil {
- return false
- }
+ var r *v1.HealthCheckResponse
- if r.Data == nil {
- return false
- }
+ for h := range c.Pods[0].Health {
+ if c.Pods[0].Health[h].Name == "camel-routes" && c.Pods[0].Health[h].Status == "DOWN" {
+ r = &c.Pods[0].Health[h]
+ }
+ }
- var data map[string]interface{}
- if err := json.Unmarshal(r.Data, &data); err != nil {
- return false
- }
+ if r == nil {
+ return false
+ }
- return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped" && data["route.id"].(string) == "never-ready"
- }))
+ if r.Data == nil {
+ return false
+ }
- Satisfy(func(events *corev1.EventList) bool {
- for e := range events.Items {
- if events.Items[e].Type == "Warning" && events.Items[e].Reason == "Unhealthy" && strings.Contains(events.Items[e].Message, "Startup probe failed") {
- return true
+ var data map[string]interface{}
+ if err := json.Unmarshal(r.Data, &data); err != nil {
+ return false
+ }
+
+ return data["check.kind"].(string) == "READINESS" && data["route.status"].(string) == "Stopped" && data["route.id"].(string) == "never-ready"
+ }))
+
+ Satisfy(func(events *corev1.EventList) bool {
+ for e := range events.Items {
+ if events.Items[e].Type == "Warning" && events.Items[e].Reason == "Unhealthy" && strings.Contains(events.Items[e].Message, "Startup probe failed") {
+ return true
+ }
}
- }
- return false
+ return false
+ })
})
- })
- t.Run("Startup condition with ready route", func(t *testing.T) {
- name := RandomizedSuffixName("startup-probe-ready-route")
+ t.Run("Startup condition with ready route", func(t *testing.T) {
+ name := RandomizedSuffixName("startup-probe-ready-route")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "health.enabled=true",
- "-t", "health.startup-probe-enabled=true",
- "-t", "health.startup-timeout=60",
- ).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "health.enabled=true",
+ "-t", "health.startup-probe-enabled=true",
+ "-t", "health.startup-timeout=60",
+ ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPhase(ns, name), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning))
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPhase(ns, name), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning))
- Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).Should(And(
- WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionDeploymentReadyReason)),
- WithTransform(IntegrationConditionMessage, Equal("1/1 ready replicas"))))
+ Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).Should(And(
+ WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionDeploymentReadyReason)),
+ WithTransform(IntegrationConditionMessage, Equal("1/1 ready replicas"))))
+
+ Satisfy(func(is *v1.IntegrationSpec) bool {
+ if *is.Traits.Health.Enabled == true && *is.Traits.Health.StartupProbeEnabled == true && is.Traits.Health.StartupTimeout == 60 {
+ return true
+ }
+ return false
+ })
- Satisfy(func(is *v1.IntegrationSpec) bool {
- if *is.Traits.Health.Enabled == true && *is.Traits.Health.StartupProbeEnabled == true && is.Traits.Health.StartupTimeout == 60 {
- return true
- }
- return false
})
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
diff --git a/e2e/common/traits/istio_test.go b/e2e/common/traits/istio_test.go
index 5d507c823..5a0d7567a 100644
--- a/e2e/common/traits/istio_test.go
+++ b/e2e/common/traits/istio_test.go
@@ -35,32 +35,33 @@ import (
)
func TestIstioTrait(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("Run Java with Istio", func(t *testing.T) {
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "istio.enabled=true").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ t.Run("Run Java with Istio", func(t *testing.T) {
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "istio.enabled=true").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- pod := IntegrationPod(ns, name)()
- Expect(pod.ObjectMeta.Annotations).NotTo(BeNil())
- annotations := pod.ObjectMeta.Annotations
- Expect(annotations["sidecar.istio.io/inject"]).To(Equal("true"))
- Expect(annotations["traffic.sidecar.istio.io/includeOutboundIPRanges"]).To(Equal("10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"))
+ pod := IntegrationPod(ns, name)()
+ Expect(pod.ObjectMeta.Annotations).NotTo(BeNil())
+ annotations := pod.ObjectMeta.Annotations
+ Expect(annotations["sidecar.istio.io/inject"]).To(Equal("true"))
+ Expect(annotations["traffic.sidecar.istio.io/includeOutboundIPRanges"]).To(Equal("10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"))
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, name)()
- istioTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "istio")
- Expect(istioTrait).ToNot(BeNil())
- Expect(len(istioTrait)).To(Equal(1))
- Expect(istioTrait["enabled"]).To(Equal(true))
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, name)()
+ istioTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "istio")
+ Expect(istioTrait).ToNot(BeNil())
+ Expect(len(istioTrait)).To(Equal(1))
+ Expect(istioTrait["enabled"]).To(Equal(true))
- })
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/traits/jolokia_test.go b/e2e/common/traits/jolokia_test.go
index c06e8d53a..bf9b332d6 100644
--- a/e2e/common/traits/jolokia_test.go
+++ b/e2e/common/traits/jolokia_test.go
@@ -36,39 +36,39 @@ import (
)
func TestJolokiaTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Run Java with Jolokia", func(t *testing.T) {
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "jolokia.enabled=true",
- "-t", "jolokia.use-ssl-client-authentication=false",
- "-t", "jolokia.protocol=http",
- "-t", "jolokia.extended-client-check=false").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- pod := IntegrationPod(ns, name)
- response, err := TestClient().CoreV1().RESTClient().Get().
- AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/jolokia/", ns, pod().Name)).DoRaw(TestContext)
- Expect(err).To(BeNil())
- Expect(response).To(ContainSubstring(`"status":200`))
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, name)()
- jolokiaTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "jolokia")
- Expect(jolokiaTrait).ToNot(BeNil())
- Expect(len(jolokiaTrait)).To(Equal(4))
- Expect(jolokiaTrait["enabled"]).To(Equal(true))
- Expect(jolokiaTrait["useSSLClientAuthentication"]).To(Equal(false))
- Expect(jolokiaTrait["protocol"]).To(Equal("http"))
- Expect(jolokiaTrait["extendedClientCheck"]).To(Equal(false))
-
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Run Java with Jolokia", func(t *testing.T) {
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "jolokia.enabled=true",
+ "-t", "jolokia.use-ssl-client-authentication=false",
+ "-t", "jolokia.protocol=http",
+ "-t", "jolokia.extended-client-check=false").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ pod := IntegrationPod(ns, name)
+ response, err := TestClient().CoreV1().RESTClient().Get().
+ AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/jolokia/", ns, pod().Name)).DoRaw(TestContext)
+ Expect(err).To(BeNil())
+ Expect(response).To(ContainSubstring(`"status":200`))
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, name)()
+ jolokiaTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "jolokia")
+ Expect(jolokiaTrait).ToNot(BeNil())
+ Expect(len(jolokiaTrait)).To(Equal(4))
+ Expect(jolokiaTrait["enabled"]).To(Equal(true))
+ Expect(jolokiaTrait["useSSLClientAuthentication"]).To(Equal(false))
+ Expect(jolokiaTrait["protocol"]).To(Equal("http"))
+ Expect(jolokiaTrait["extendedClientCheck"]).To(Equal(false))
+
+ })
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
-
}
diff --git a/e2e/common/traits/jvm_test.go b/e2e/common/traits/jvm_test.go
index 6372516f7..bf2b6638a 100644
--- a/e2e/common/traits/jvm_test.go
+++ b/e2e/common/traits/jvm_test.go
@@ -37,33 +37,34 @@ import (
)
func TestJVMTrait(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- // Store a configmap holding a jar
- var cmData = make(map[string][]byte)
- // We calculate the expected content
- source, err := os.ReadFile("./files/jvm/sample-1.0.jar")
- require.NoError(t, err)
- cmData["sample-1.0.jar"] = source
- err = CreateBinaryConfigmap(ns, "my-deps", cmData)
- require.NoError(t, err)
+ // Store a configmap holding a jar
+ var cmData = make(map[string][]byte)
+ // We calculate the expected content
+ source, err := os.ReadFile("./files/jvm/sample-1.0.jar")
+ require.NoError(t, err)
+ cmData["sample-1.0.jar"] = source
+ err = CreateBinaryConfigmap(ns, "my-deps", cmData)
+ require.NoError(t, err)
- t.Run("JVM trait classpath", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "./files/jvm/Classpath.java",
- "--resource", "configmap:my-deps",
- "-t", "jvm.classpath=/etc/camel/resources/my-deps/sample-1.0.jar",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
+ t.Run("JVM trait classpath", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "./files/jvm/Classpath.java",
+ "--resource", "configmap:my-deps",
+ "-t", "jvm.classpath=/etc/camel/resources/my-deps/sample-1.0.jar",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, "classpath")).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, "classpath")()
- jvmTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "jvm")
- Expect(jvmTrait).ToNot(BeNil())
- Expect(len(jvmTrait)).To(Equal(1))
- Expect(jvmTrait["classpath"]).To(Equal("/etc/camel/resources/my-deps/sample-1.0.jar"))
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, "classpath")).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, "classpath")()
+ jvmTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "jvm")
+ Expect(jvmTrait).ToNot(BeNil())
+ Expect(len(jvmTrait)).To(Equal(1))
+ Expect(jvmTrait["classpath"]).To(Equal("/etc/camel/resources/my-deps/sample-1.0.jar"))
+ })
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
diff --git a/e2e/common/traits/kamelet_test.go b/e2e/common/traits/kamelet_test.go
index 201caee70..a23789408 100644
--- a/e2e/common/traits/kamelet_test.go
+++ b/e2e/common/traits/kamelet_test.go
@@ -34,34 +34,35 @@ import (
)
func TestKameletTrait(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("discover kamelet capabilities", func(t *testing.T) {
- template := map[string]interface{}{
- "from": map[string]interface{}{
- "uri": "platform-http:///webhook",
- "steps": []map[string]interface{}{
- {
- "to": "kamelet:sink",
+ t.Run("discover kamelet capabilities", func(t *testing.T) {
+ template := map[string]interface{}{
+ "from": map[string]interface{}{
+ "uri": "platform-http:///webhook",
+ "steps": []map[string]interface{}{
+ {
+ "to": "kamelet:sink",
+ },
},
},
- },
- }
- Expect(CreateKamelet(ns, "capabilities-webhook-source", template, nil, nil)()).To(Succeed())
+ }
+ Expect(CreateKamelet(ns, "capabilities-webhook-source", template, nil, nil)()).To(Succeed())
- name := RandomizedSuffixName("webhook")
- Expect(KamelRunWithID(operatorID, ns, "files/webhook.yaml", "--name", name).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Started capabilities-webhook-source-1 (platform-http:///webhook)"))
- // Verify Integration capabilities
- Eventually(IntegrationStatusCapabilities(ns, name), TestTimeoutShort).Should(ContainElements("platform-http"))
- // Verify expected resources from Kamelet (Service in this case)
- service := Service(ns, name)
- Eventually(service, TestTimeoutShort).ShouldNot(BeNil())
- })
+ name := RandomizedSuffixName("webhook")
+ Expect(KamelRunWithID(operatorID, ns, "files/webhook.yaml", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Started capabilities-webhook-source-1 (platform-http:///webhook)"))
+ // Verify Integration capabilities
+ Eventually(IntegrationStatusCapabilities(ns, name), TestTimeoutShort).Should(ContainElements("platform-http"))
+ // Verify expected resources from Kamelet (Service in this case)
+ service := Service(ns, name)
+ Eventually(service, TestTimeoutShort).ShouldNot(BeNil())
+ })
- // Clean-up
- Expect(DeleteKamelet(ns, "capabilities-webhook-source")).To(Succeed())
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ // Clean-up
+ Expect(DeleteKamelet(ns, "capabilities-webhook-source")).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/traits/master_test.go b/e2e/common/traits/master_test.go
index 111760b02..06c6cf5cd 100644
--- a/e2e/common/traits/master_test.go
+++ b/e2e/common/traits/master_test.go
@@ -35,47 +35,48 @@ import (
)
func TestMasterTrait(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("master works", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/Master.java").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "master"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, "master"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
+ t.Run("master works", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/Master.java").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "master"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, "master"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
- t.Run("only one integration with master runs", func(t *testing.T) {
- nameFirst := RandomizedSuffixName("first")
- Expect(KamelRunWithID(operatorID, ns, "files/Master.java",
- "--name", nameFirst,
- "--label", "leader-group=same",
- "-t", "master.label-key=leader-group",
- "-t", "master.label-value=same",
- "-t", "owner.target-labels=leader-group").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, nameFirst), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, nameFirst), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- // Start a second integration with the same lock (it should not start the route)
- nameSecond := RandomizedSuffixName("second")
- Expect(KamelRunWithID(operatorID, ns, "files/Master.java",
- "--name", nameSecond,
- "--label", "leader-group=same",
- "-t", "master.label-key=leader-group",
- "-t", "master.label-value=same",
- "-t", "master.resource-name=first-lock",
- "-t", "owner.target-labels=leader-group").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, nameSecond), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, nameSecond), TestTimeoutShort).Should(ContainSubstring("started in"))
- Eventually(IntegrationLogs(ns, nameSecond), 30*time.Second).ShouldNot(ContainSubstring("Magicstring!"))
+ t.Run("only one integration with master runs", func(t *testing.T) {
+ nameFirst := RandomizedSuffixName("first")
+ Expect(KamelRunWithID(operatorID, ns, "files/Master.java",
+ "--name", nameFirst,
+ "--label", "leader-group=same",
+ "-t", "master.label-key=leader-group",
+ "-t", "master.label-value=same",
+ "-t", "owner.target-labels=leader-group").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, nameFirst), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, nameFirst), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ // Start a second integration with the same lock (it should not start the route)
+ nameSecond := RandomizedSuffixName("second")
+ Expect(KamelRunWithID(operatorID, ns, "files/Master.java",
+ "--name", nameSecond,
+ "--label", "leader-group=same",
+ "-t", "master.label-key=leader-group",
+ "-t", "master.label-value=same",
+ "-t", "master.resource-name=first-lock",
+ "-t", "owner.target-labels=leader-group").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, nameSecond), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, nameSecond), TestTimeoutShort).Should(ContainSubstring("started in"))
+ Eventually(IntegrationLogs(ns, nameSecond), 30*time.Second).ShouldNot(ContainSubstring("Magicstring!"))
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, nameFirst)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, nameFirst)()
- builderTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "addons", "master")
- Expect(builderTrait).ToNot(BeNil())
- Expect(len(builderTrait)).To(Equal(2))
- Expect(builderTrait["labelKey"]).To(Equal("leader-group"))
- Expect(builderTrait["labelValue"]).To(Equal("same"))
- })
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, nameFirst)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, nameFirst)()
+ builderTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "addons", "master")
+ Expect(builderTrait).ToNot(BeNil())
+ Expect(len(builderTrait)).To(Equal(2))
+ Expect(builderTrait["labelKey"]).To(Equal("leader-group"))
+ Expect(builderTrait["labelValue"]).To(Equal("same"))
+ })
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/traits/openapi_test.go b/e2e/common/traits/openapi_test.go
index 072f3b9a9..10f321e88 100644
--- a/e2e/common/traits/openapi_test.go
+++ b/e2e/common/traits/openapi_test.go
@@ -35,31 +35,32 @@ import (
)
func TestOpenAPI(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- openapiContent, err := ioutil.ReadFile("./files/openapi/petstore-api.yaml")
- require.NoError(t, err)
- var cmDataProps = make(map[string]string)
- cmDataProps["petstore-api.yaml"] = string(openapiContent)
- CreatePlainTextConfigmap(ns, "my-openapi", cmDataProps)
+ openapiContent, err := ioutil.ReadFile("./files/openapi/petstore-api.yaml")
+ require.NoError(t, err)
+ var cmDataProps = make(map[string]string)
+ cmDataProps["petstore-api.yaml"] = string(openapiContent)
+ CreatePlainTextConfigmap(ns, "my-openapi", cmDataProps)
- Expect(KamelRunWithID(operatorID, ns,
- "--name", "petstore",
- "--open-api", "configmap:my-openapi",
- "files/openapi/petstore.groovy",
- ).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns,
+ "--name", "petstore",
+ "--open-api", "configmap:my-openapi",
+ "files/openapi/petstore.groovy",
+ ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "petstore"), TestTimeoutLong).
- Should(Equal(corev1.PodRunning))
- Eventually(DeploymentWithIntegrationLabel(ns, "petstore"), TestTimeoutLong).
- Should(Not(BeNil()))
+ Eventually(IntegrationPodPhase(ns, "petstore"), TestTimeoutLong).
+ Should(Equal(corev1.PodRunning))
+ Eventually(DeploymentWithIntegrationLabel(ns, "petstore"), TestTimeoutLong).
+ Should(Not(BeNil()))
- Eventually(IntegrationLogs(ns, "petstore"), TestTimeoutMedium).
- Should(ContainSubstring("Started listPets (rest://get:/v1:/pets)"))
- Eventually(IntegrationLogs(ns, "petstore"), TestTimeoutMedium).
- Should(ContainSubstring("Started createPets (rest://post:/v1:/pets)"))
- Eventually(IntegrationLogs(ns, "petstore"), TestTimeoutMedium).
- Should(ContainSubstring("Started showPetById (rest://get:/v1:/pets/%7BpetId%7D)"))
+ Eventually(IntegrationLogs(ns, "petstore"), TestTimeoutMedium).
+ Should(ContainSubstring("Started listPets (rest://get:/v1:/pets)"))
+ Eventually(IntegrationLogs(ns, "petstore"), TestTimeoutMedium).
+ Should(ContainSubstring("Started createPets (rest://post:/v1:/pets)"))
+ Eventually(IntegrationLogs(ns, "petstore"), TestTimeoutMedium).
+ Should(ContainSubstring("Started showPetById (rest://get:/v1:/pets/%7BpetId%7D)"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/traits/pdb_test.go b/e2e/common/traits/pdb_test.go
index 7c43e1ff7..6c4c0083e 100644
--- a/e2e/common/traits/pdb_test.go
+++ b/e2e/common/traits/pdb_test.go
@@ -43,110 +43,111 @@ import (
)
func TestPodDisruptionBudgetTrait(t *testing.T) {
- RegisterTestingT(t)
-
- name := RandomizedSuffixName("java")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "pdb.enabled=true",
- "-t", "pdb.min-available=2",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, name)()
- pdbTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "pdb")
- Expect(pdbTrait).ToNot(BeNil())
- Expect(len(pdbTrait)).To(Equal(2))
- Expect(pdbTrait["enabled"]).To(Equal(true))
- Expect(pdbTrait["minAvailable"]).To(Equal("2"))
-
- // Check PodDisruptionBudget
- Eventually(podDisruptionBudget(ns, name), TestTimeoutShort).ShouldNot(BeNil())
- pdb := podDisruptionBudget(ns, name)()
- // Assert PDB Spec
- Expect(pdb.Spec.MinAvailable).To(PointTo(Equal(intstr.FromInt(2))))
- // Assert PDB Status
- Eventually(podDisruptionBudget(ns, name), TestTimeoutShort).
- Should(MatchFieldsP(IgnoreExtras, Fields{
- "Status": MatchFields(IgnoreExtras, Fields{
- "ObservedGeneration": BeNumerically("==", 1),
- "DisruptionsAllowed": BeNumerically("==", 0),
- "CurrentHealthy": BeNumerically("==", 1),
- "DesiredHealthy": BeNumerically("==", 2),
- "ExpectedPods": BeNumerically("==", 1),
- }),
+ WithNewTestNamespace(t, func(ns string) {
+
+ name := RandomizedSuffixName("java")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "pdb.enabled=true",
+ "-t", "pdb.min-available=2",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, name)()
+ pdbTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "pdb")
+ Expect(pdbTrait).ToNot(BeNil())
+ Expect(len(pdbTrait)).To(Equal(2))
+ Expect(pdbTrait["enabled"]).To(Equal(true))
+ Expect(pdbTrait["minAvailable"]).To(Equal("2"))
+
+ // Check PodDisruptionBudget
+ Eventually(podDisruptionBudget(ns, name), TestTimeoutShort).ShouldNot(BeNil())
+ pdb := podDisruptionBudget(ns, name)()
+ // Assert PDB Spec
+ Expect(pdb.Spec.MinAvailable).To(PointTo(Equal(intstr.FromInt(2))))
+ // Assert PDB Status
+ Eventually(podDisruptionBudget(ns, name), TestTimeoutShort).
+ Should(MatchFieldsP(IgnoreExtras, Fields{
+ "Status": MatchFields(IgnoreExtras, Fields{
+ "ObservedGeneration": BeNumerically("==", 1),
+ "DisruptionsAllowed": BeNumerically("==", 0),
+ "CurrentHealthy": BeNumerically("==", 1),
+ "DesiredHealthy": BeNumerically("==", 2),
+ "ExpectedPods": BeNumerically("==", 1),
+ }),
+ }))
+
+ // Scale Integration
+ Expect(ScaleIntegration(ns, name, 2)).To(Succeed())
+ Eventually(IntegrationPods(ns, name), TestTimeoutMedium).Should(HaveLen(2))
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(PointTo(BeNumerically("==", 2)))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+
+ // Check PodDisruptionBudget
+ pdb = podDisruptionBudget(ns, name)()
+ Expect(pdb).NotTo(BeNil())
+ // Assert PDB Status according to the scale change
+ Eventually(podDisruptionBudget(ns, name), TestTimeoutShort).
+ Should(MatchFieldsP(IgnoreExtras, Fields{
+ "Status": MatchFields(IgnoreExtras, Fields{
+ "ObservedGeneration": BeNumerically("==", 1),
+ "DisruptionsAllowed": BeNumerically("==", 0),
+ "CurrentHealthy": BeNumerically("==", 2),
+ "DesiredHealthy": BeNumerically("==", 2),
+ "ExpectedPods": BeNumerically("==", 2),
+ }),
+ }))
+
+ // Eviction attempt
+ pods := IntegrationPods(ns, name)()
+ Expect(pods).To(HaveLen(2))
+ err := TestClient().CoreV1().Pods(ns).EvictV1(TestContext, &policyv1.Eviction{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: pods[0].Name,
+ },
+ })
+ Expect(err).To(MatchError(&k8serrors.StatusError{
+ ErrStatus: metav1.Status{
+ Status: "Failure",
+ Message: "Cannot evict pod as it would violate the pod's disruption budget.",
+ Reason: "TooManyRequests",
+ Code: http.StatusTooManyRequests,
+ Details: &metav1.StatusDetails{
+ Causes: []metav1.StatusCause{
+ {
+ Type: "DisruptionBudget",
+ Message: "The disruption budget " + name + " needs 2 healthy pods and has 2 currently",
+ },
+ },
+ },
+ },
}))
- // Scale Integration
- Expect(ScaleIntegration(ns, name, 2)).To(Succeed())
- Eventually(IntegrationPods(ns, name), TestTimeoutMedium).Should(HaveLen(2))
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(PointTo(BeNumerically("==", 2)))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
-
- // Check PodDisruptionBudget
- pdb = podDisruptionBudget(ns, name)()
- Expect(pdb).NotTo(BeNil())
- // Assert PDB Status according to the scale change
- Eventually(podDisruptionBudget(ns, name), TestTimeoutShort).
- Should(MatchFieldsP(IgnoreExtras, Fields{
- "Status": MatchFields(IgnoreExtras, Fields{
- "ObservedGeneration": BeNumerically("==", 1),
- "DisruptionsAllowed": BeNumerically("==", 0),
- "CurrentHealthy": BeNumerically("==", 2),
- "DesiredHealthy": BeNumerically("==", 2),
- "ExpectedPods": BeNumerically("==", 2),
- }),
- }))
+ // Scale Integration to Scale > PodDisruptionBudgetSpec.MinAvailable
+ // for the eviction request to succeed once replicas are ready
+ Expect(ScaleIntegration(ns, name, 3)).To(Succeed())
+ Eventually(IntegrationPods(ns, name), TestTimeoutMedium).Should(HaveLen(3))
+ Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
+ Should(PointTo(BeNumerically("==", 3)))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+
+ pods = IntegrationPods(ns, name)()
+ Expect(pods).To(HaveLen(3))
+ Expect(TestClient().CoreV1().Pods(ns).EvictV1(TestContext, &policyv1.Eviction{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: pods[0].Name,
+ },
+ })).To(Succeed())
- // Eviction attempt
- pods := IntegrationPods(ns, name)()
- Expect(pods).To(HaveLen(2))
- err := TestClient().CoreV1().Pods(ns).EvictV1(TestContext, &policyv1.Eviction{
- ObjectMeta: metav1.ObjectMeta{
- Name: pods[0].Name,
- },
+ // Clean up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
- Expect(err).To(MatchError(&k8serrors.StatusError{
- ErrStatus: metav1.Status{
- Status: "Failure",
- Message: "Cannot evict pod as it would violate the pod's disruption budget.",
- Reason: "TooManyRequests",
- Code: http.StatusTooManyRequests,
- Details: &metav1.StatusDetails{
- Causes: []metav1.StatusCause{
- {
- Type: "DisruptionBudget",
- Message: "The disruption budget " + name + " needs 2 healthy pods and has 2 currently",
- },
- },
- },
- },
- }))
-
- // Scale Integration to Scale > PodDisruptionBudgetSpec.MinAvailable
- // for the eviction request to succeed once replicas are ready
- Expect(ScaleIntegration(ns, name, 3)).To(Succeed())
- Eventually(IntegrationPods(ns, name), TestTimeoutMedium).Should(HaveLen(3))
- Eventually(IntegrationStatusReplicas(ns, name), TestTimeoutShort).
- Should(PointTo(BeNumerically("==", 3)))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
-
- pods = IntegrationPods(ns, name)()
- Expect(pods).To(HaveLen(3))
- Expect(TestClient().CoreV1().Pods(ns).EvictV1(TestContext, &policyv1.Eviction{
- ObjectMeta: metav1.ObjectMeta{
- Name: pods[0].Name,
- },
- })).To(Succeed())
-
- // Clean up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
func podDisruptionBudget(ns string, name string) func() *policyv1.PodDisruptionBudget {
diff --git a/e2e/common/traits/pod_test.go b/e2e/common/traits/pod_test.go
index 19c229064..bfc679655 100644
--- a/e2e/common/traits/pod_test.go
+++ b/e2e/common/traits/pod_test.go
@@ -34,72 +34,73 @@ import (
)
func TestPodTrait(t *testing.T) {
- RegisterTestingT(t)
-
- tc := []struct {
- name string
- templateName string
- assertions func(t *testing.T, ns string, name string)
- }{
- {
- name: "pod trait with env vars and volume mounts",
- templateName: "files/template.yaml",
- //nolint: thelper
- assertions: func(t *testing.T, ns string, name string) {
- // check that integrations is working and reading data created by sidecar container
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Content from the sidecar container"))
- // check that env var is injected
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("hello from the template"))
- pod := IntegrationPod(ns, name)()
-
- // check if ENV variable is applied
- envValue := getEnvVar("TEST_VARIABLE", pod.Spec)
- Expect(envValue).To(Equal("hello from the template"))
+ WithNewTestNamespace(t, func(ns string) {
+
+ tc := []struct {
+ name string
+ templateName string
+ assertions func(t *testing.T, ns string, name string)
+ }{
+ {
+ name: "pod trait with env vars and volume mounts",
+ templateName: "files/template.yaml",
+ //nolint: thelper
+ assertions: func(t *testing.T, ns string, name string) {
+ // check that integrations is working and reading data created by sidecar container
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Content from the sidecar container"))
+ // check that env var is injected
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("hello from the template"))
+ pod := IntegrationPod(ns, name)()
+
+ // check if ENV variable is applied
+ envValue := getEnvVar("TEST_VARIABLE", pod.Spec)
+ Expect(envValue).To(Equal("hello from the template"))
+ },
},
- },
- {
- name: "pod trait with supplemental groups",
- templateName: "files/template-with-supplemental-groups.yaml",
- //nolint: thelper
- assertions: func(t *testing.T, ns string, name string) {
- Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
- if pod.Spec.SecurityContext == nil {
- return false
- }
- for _, sg := range pod.Spec.SecurityContext.SupplementalGroups {
- if sg == 666 {
- return true
+ {
+ name: "pod trait with supplemental groups",
+ templateName: "files/template-with-supplemental-groups.yaml",
+ //nolint: thelper
+ assertions: func(t *testing.T, ns string, name string) {
+ Eventually(IntegrationPodHas(ns, name, func(pod *corev1.Pod) bool {
+ if pod.Spec.SecurityContext == nil {
+ return false
+ }
+ for _, sg := range pod.Spec.SecurityContext.SupplementalGroups {
+ if sg == 666 {
+ return true
+ }
}
- }
- return false
- }), TestTimeoutShort).Should(BeTrue())
+ return false
+ }), TestTimeoutShort).Should(BeTrue())
+ },
},
- },
- }
+ }
- name := RandomizedSuffixName("pod-template-test")
+ name := RandomizedSuffixName("pod-template-test")
- for i := range tc {
- test := tc[i]
+ for i := range tc {
+ test := tc[i]
- t.Run(test.name, func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PodTest.groovy",
- "--name", name,
- "--pod-template", test.templateName,
- ).Execute()).To(Succeed())
+ t.Run(test.name, func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PodTest.groovy",
+ "--name", name,
+ "--pod-template", test.templateName,
+ ).Execute()).To(Succeed())
- // check integration is deployed
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ // check integration is deployed
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- test.assertions(t, ns, name)
+ test.assertions(t, ns, name)
- // Clean up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
- }
+ // Clean up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+ }
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func getEnvVar(name string, spec corev1.PodSpec) string {
diff --git a/e2e/common/traits/prometheus_test.go b/e2e/common/traits/prometheus_test.go
index 5b28db448..5a1bb4f1e 100644
--- a/e2e/common/traits/prometheus_test.go
+++ b/e2e/common/traits/prometheus_test.go
@@ -44,45 +44,46 @@ import (
)
func TestPrometheusTrait(t *testing.T) {
- RegisterTestingT(t)
-
- ocp, err := openshift.IsOpenShift(TestClient())
- require.NoError(t, err)
- // Do not create PodMonitor for the time being as CI test runs on OCP 3.11
- createPodMonitor := false
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "-t", "prometheus.enabled=true",
- "-t", fmt.Sprintf("prometheus.pod-monitor=%v", createPodMonitor)).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, "java")).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, "java")()
- prometheusTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "prometheus")
- Expect(prometheusTrait).ToNot(BeNil())
- Expect(len(prometheusTrait)).To(Equal(2))
- Expect(prometheusTrait["enabled"]).To(Equal(true))
- Expect(prometheusTrait["podMonitor"]).ToNot(BeNil())
- t.Run("Metrics endpoint works", func(t *testing.T) {
- pod := IntegrationPod(ns, "java")
- response, err := TestClient().CoreV1().RESTClient().Get().
- AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/q/metrics", ns, pod().Name)).DoRaw(TestContext)
- if err != nil {
- assert.Fail(t, err.Error())
- }
- assert.Contains(t, string(response), "camel_exchanges_total")
- })
-
- if ocp && createPodMonitor {
- t.Run("PodMonitor is created", func(t *testing.T) {
- sm := podMonitor(ns, "java")
- Eventually(sm, TestTimeoutShort).ShouldNot(BeNil())
+ WithNewTestNamespace(t, func(ns string) {
+
+ ocp, err := openshift.IsOpenShift(TestClient())
+ require.NoError(t, err)
+ // Do not create PodMonitor for the time being as CI test runs on OCP 3.11
+ createPodMonitor := false
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "-t", "prometheus.enabled=true",
+ "-t", fmt.Sprintf("prometheus.pod-monitor=%v", createPodMonitor)).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, "java")).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, "java")()
+ prometheusTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "prometheus")
+ Expect(prometheusTrait).ToNot(BeNil())
+ Expect(len(prometheusTrait)).To(Equal(2))
+ Expect(prometheusTrait["enabled"]).To(Equal(true))
+ Expect(prometheusTrait["podMonitor"]).ToNot(BeNil())
+ t.Run("Metrics endpoint works", func(t *testing.T) {
+ pod := IntegrationPod(ns, "java")
+ response, err := TestClient().CoreV1().RESTClient().Get().
+ AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/q/metrics", ns, pod().Name)).DoRaw(TestContext)
+ if err != nil {
+ assert.Fail(t, err.Error())
+ }
+ assert.Contains(t, string(response), "camel_exchanges_total")
})
- }
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ if ocp && createPodMonitor {
+ t.Run("PodMonitor is created", func(t *testing.T) {
+ sm := podMonitor(ns, "java")
+ Eventually(sm, TestTimeoutShort).ShouldNot(BeNil())
+ })
+ }
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
func podMonitor(ns string, name string) func() *monitoringv1.PodMonitor {
diff --git a/e2e/common/traits/pull_secret_test.go b/e2e/common/traits/pull_secret_test.go
index ade72f144..61563bc39 100644
--- a/e2e/common/traits/pull_secret_test.go
+++ b/e2e/common/traits/pull_secret_test.go
@@ -36,64 +36,65 @@ import (
)
func TestPullSecretTrait(t *testing.T) {
- RegisterTestingT(t)
-
- ocp, err := openshift.IsOpenShift(TestClient())
- Expect(err).To(BeNil())
-
- t.Run("Image pull secret is set on pod", func(t *testing.T) {
- name := RandomizedSuffixName("java1")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
- "-t", "pull-secret.enabled=true",
- "-t", "pull-secret.secret-name=dummy-secret").Execute()).To(Succeed())
- // pod may not run because the pull secret is dummy
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Or(Equal(corev1.PodRunning), Equal(corev1.PodPending)))
-
- pod := IntegrationPod(ns, name)()
- Expect(pod.Spec.ImagePullSecrets).NotTo(BeEmpty())
- Expect(pod.Spec.ImagePullSecrets[0].Name).To(Equal("dummy-secret"))
- })
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("Explicitly disable image pull secret", func(t *testing.T) {
- name := RandomizedSuffixName("java2")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
- "-t", "pull-secret.enabled=false").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, name)()
- pullSecretTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "pull-secret")
- Expect(pullSecretTrait).ToNot(BeNil())
- Expect(len(pullSecretTrait)).To(Equal(1))
- Expect(pullSecretTrait["enabled"]).To(Equal(false))
-
- pod := IntegrationPod(ns, name)()
- if ocp {
- // OpenShift `default` service account has imagePullSecrets so it's always set
+ ocp, err := openshift.IsOpenShift(TestClient())
+ Expect(err).To(BeNil())
+
+ t.Run("Image pull secret is set on pod", func(t *testing.T) {
+ name := RandomizedSuffixName("java1")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
+ "-t", "pull-secret.enabled=true",
+ "-t", "pull-secret.secret-name=dummy-secret").Execute()).To(Succeed())
+ // pod may not run because the pull secret is dummy
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Or(Equal(corev1.PodRunning), Equal(corev1.PodPending)))
+
+ pod := IntegrationPod(ns, name)()
Expect(pod.Spec.ImagePullSecrets).NotTo(BeEmpty())
- } else {
- Expect(pod.Spec.ImagePullSecrets).To(BeNil())
- }
- })
+ Expect(pod.Spec.ImagePullSecrets[0].Name).To(Equal("dummy-secret"))
+ })
- if ocp {
- // OpenShift always has an internal registry so image pull secret is set by default
- t.Run("Image pull secret is automatically set by default", func(t *testing.T) {
- name := RandomizedSuffixName("java3")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ t.Run("Explicitly disable image pull secret", func(t *testing.T) {
+ name := RandomizedSuffixName("java2")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
+ "-t", "pull-secret.enabled=false").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, name)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, name)()
+ pullSecretTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "pull-secret")
+ Expect(pullSecretTrait).ToNot(BeNil())
+ Expect(len(pullSecretTrait)).To(Equal(1))
+ Expect(pullSecretTrait["enabled"]).To(Equal(false))
+
pod := IntegrationPod(ns, name)()
- Expect(pod.Spec.ImagePullSecrets).NotTo(BeEmpty())
- Expect(pod.Spec.ImagePullSecrets[0].Name).To(HavePrefix("default-dockercfg-"))
+ if ocp {
+ // OpenShift `default` service account has imagePullSecrets so it's always set
+ Expect(pod.Spec.ImagePullSecrets).NotTo(BeEmpty())
+ } else {
+ Expect(pod.Spec.ImagePullSecrets).To(BeNil())
+ }
})
- }
- // Clean-up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ if ocp {
+ // OpenShift always has an internal registry so image pull secret is set by default
+ t.Run("Image pull secret is automatically set by default", func(t *testing.T) {
+ name := RandomizedSuffixName("java3")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ pod := IntegrationPod(ns, name)()
+ Expect(pod.Spec.ImagePullSecrets).NotTo(BeEmpty())
+ Expect(pod.Spec.ImagePullSecrets[0].Name).To(HavePrefix("default-dockercfg-"))
+ })
+ }
+
+ // Clean-up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/traits/route_test.go b/e2e/common/traits/route_test.go
index 451f2db10..33f5a1dc3 100644
--- a/e2e/common/traits/route_test.go
+++ b/e2e/common/traits/route_test.go
@@ -71,158 +71,159 @@ var certPem []byte
var skipClientTLSVerification = true
func TestRunRoutes(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- ocp, err := openshift.IsOpenShift(TestClient())
- if !ocp {
- t.Skip("This test requires route object which is available on OpenShift only.")
- return
- }
- require.NoError(t, err)
-
- operatorID := "camel-k-trait-route"
- Expect(KamelInstallWithID(operatorID, ns, "--trait-profile=openshift").Execute()).To(Succeed())
-
- // create a test secret of type tls with certificates
- // this secret is used to setupt the route TLS object across diferent tests
- secret, err := createSecret(ns)
- require.NoError(t, err)
-
- // they refer to the certificates create in the secret and are reused the different tests
- refKey := secretName + "/" + corev1.TLSPrivateKeyKey
- refCert := secretName + "/" + corev1.TLSCertKey
-
- // =============================
- // Insecure Route / No TLS
- // =============================
- t.Run("Route unsecure http works", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- route := Route(ns, integrationName)
- Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
- // must wait a little time after route is created, before doing an http request,
- // otherwise the route is unavailable and the http request will fail
- time.Sleep(waitBeforeHttpRequest)
- url := fmt.Sprintf("http://%s/hello?name=Simple", route().Spec.Host)
- Eventually(httpRequest(url, false), TestTimeoutShort).Should(Equal("Hello Simple"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
- })
-
- // =============================
- // TLS Route Edge
- // =============================
- t.Run("Route Edge https works", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java", "-t", "route.tls-termination=edge").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- route := Route(ns, integrationName)
- Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
- // must wait a little time after route is created, before an http request,
- // otherwise the route is unavailable and the http request will fail
- time.Sleep(waitBeforeHttpRequest)
- url := fmt.Sprintf("https://%s/hello?name=TLS_Edge", route().Spec.Host)
- Eventually(httpRequest(url, true), TestTimeoutShort).Should(Equal("Hello TLS_Edge"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
- })
-
- // =============================
- // TLS Route Edge with custom certificate
- // =============================
- t.Run("Route Edge (custom certificate) https works", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
- "-t", "route.tls-termination=edge",
- "-t", "route.tls-certificate-secret="+refCert,
- "-t", "route.tls-key-secret="+refKey,
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- route := Route(ns, integrationName)
- Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
- // must wait a little time after route is created, before an http request,
- // otherwise the route is unavailable and the http request will fail
- time.Sleep(waitBeforeHttpRequest)
- code := "TLS_EdgeCustomCertificate"
- url := fmt.Sprintf("https://%s/hello?name=%s", route().Spec.Host, code)
- Eventually(httpRequest(url, true), TestTimeoutShort).Should(Equal("Hello " + code))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
- })
-
- // =============================
- // TLS Route Passthrough
- // =============================
- t.Run("Route passthrough https works", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
- // the --resource mounts the certificates inside secret as files in the integration pod
- "--resource", "secret:"+secretName+"@/etc/ssl/"+secretName,
- // quarkus platform-http uses these two properties to setup the HTTP endpoint with TLS support
- "-p", "quarkus.http.ssl.certificate.file=/etc/ssl/"+secretName+"/tls.crt",
- "-p", "quarkus.http.ssl.certificate.key-file=/etc/ssl/"+secretName+"/tls.key",
- "-t", "route.tls-termination=passthrough",
- "-t", "container.port=8443",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- route := Route(ns, integrationName)
- Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
- // must wait a little time after route is created, before an http request,
- // otherwise the route is unavailable and the http request will fail
- time.Sleep(waitBeforeHttpRequest)
- code := "TLS_Passthrough"
- url := fmt.Sprintf("https://%s/hello?name=%s", route().Spec.Host, code)
- Eventually(httpRequest(url, true), TestTimeoutShort).Should(Equal("Hello " + code))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
- })
-
- // =============================
- // TLS Route Reencrypt
- // =============================
- t.Run("Route Reencrypt https works", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
- // the --resource mounts the certificates inside secret as files in the integration pod
- "--resource", "secret:"+secretName+"@/etc/ssl/"+secretName,
- // quarkus platform-http uses these two properties to setup the HTTP endpoint with TLS support
- "-p", "quarkus.http.ssl.certificate.file=/etc/ssl/"+secretName+"/tls.crt",
- "-p", "quarkus.http.ssl.certificate.key-file=/etc/ssl/"+secretName+"/tls.key",
- "-t", "route.tls-termination=reencrypt",
- // the destination CA certificate which the route service uses to validate the HTTP endpoint TLS certificate
- "-t", "route.tls-destination-ca-certificate-secret="+refCert,
- "-t", "route.tls-certificate-secret="+refCert,
- "-t", "route.tls-key-secret="+refKey,
- "-t", "container.port=8443",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- route := Route(ns, integrationName)
- Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
- // must wait a little time after route is created, before an http request,
- // otherwise the route is unavailable and the http request will fail
- time.Sleep(waitBeforeHttpRequest)
- code := "TLS_Reencrypt"
- url := fmt.Sprintf("https://%s/hello?name=%s", route().Spec.Host, code)
- Eventually(httpRequest(url, true), TestTimeoutShort).Should(Equal("Hello " + code))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
- })
-
- t.Run("Route annotations added", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
- "-t", "route.annotations.'haproxy.router.openshift.io/balance'=roundrobin").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- route := RouteFull(ns, integrationName)()
- Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
- // must wait a little time after route is created, before an http request,
- // otherwise the route is unavailable and the http request will fail
- time.Sleep(waitBeforeHttpRequest)
- var annotations = route.ObjectMeta.Annotations
- Expect(annotations["haproxy.router.openshift.io/balance"]).To(Equal("roundrobin"))
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, integrationName)).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, integrationName)()
- routeTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "route")
- Expect(routeTrait).ToNot(BeNil())
- Expect(len(routeTrait)).To(Equal(1))
- Expect(routeTrait["enabled"]).To(Equal(true))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+ ocp, err := openshift.IsOpenShift(TestClient())
+ if !ocp {
+ t.Skip("This test requires route object which is available on OpenShift only.")
+ return
+ }
+ require.NoError(t, err)
+
+ operatorID := "camel-k-trait-route"
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile=openshift").Execute()).To(Succeed())
+
+ // create a test secret of type tls with certificates
+ // this secret is used to setupt the route TLS object across diferent tests
+ secret, err := createSecret(ns)
+ require.NoError(t, err)
+
+ // they refer to the certificates create in the secret and are reused the different tests
+ refKey := secretName + "/" + corev1.TLSPrivateKeyKey
+ refCert := secretName + "/" + corev1.TLSCertKey
+
+ // =============================
+ // Insecure Route / No TLS
+ // =============================
+ t.Run("Route unsecure http works", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ route := Route(ns, integrationName)
+ Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
+ // must wait a little time after route is created, before doing an http request,
+ // otherwise the route is unavailable and the http request will fail
+ time.Sleep(waitBeforeHttpRequest)
+ url := fmt.Sprintf("http://%s/hello?name=Simple", route().Spec.Host)
+ Eventually(httpRequest(url, false), TestTimeoutShort).Should(Equal("Hello Simple"))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+ })
+
+ // =============================
+ // TLS Route Edge
+ // =============================
+ t.Run("Route Edge https works", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java", "-t", "route.tls-termination=edge").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ route := Route(ns, integrationName)
+ Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
+ // must wait a little time after route is created, before an http request,
+ // otherwise the route is unavailable and the http request will fail
+ time.Sleep(waitBeforeHttpRequest)
+ url := fmt.Sprintf("https://%s/hello?name=TLS_Edge", route().Spec.Host)
+ Eventually(httpRequest(url, true), TestTimeoutShort).Should(Equal("Hello TLS_Edge"))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+ })
+
+ // =============================
+ // TLS Route Edge with custom certificate
+ // =============================
+ t.Run("Route Edge (custom certificate) https works", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
+ "-t", "route.tls-termination=edge",
+ "-t", "route.tls-certificate-secret="+refCert,
+ "-t", "route.tls-key-secret="+refKey,
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ route := Route(ns, integrationName)
+ Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
+ // must wait a little time after route is created, before an http request,
+ // otherwise the route is unavailable and the http request will fail
+ time.Sleep(waitBeforeHttpRequest)
+ code := "TLS_EdgeCustomCertificate"
+ url := fmt.Sprintf("https://%s/hello?name=%s", route().Spec.Host, code)
+ Eventually(httpRequest(url, true), TestTimeoutShort).Should(Equal("Hello " + code))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+ })
+
+ // =============================
+ // TLS Route Passthrough
+ // =============================
+ t.Run("Route passthrough https works", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
+ // the --resource mounts the certificates inside secret as files in the integration pod
+ "--resource", "secret:"+secretName+"@/etc/ssl/"+secretName,
+ // quarkus platform-http uses these two properties to setup the HTTP endpoint with TLS support
+ "-p", "quarkus.http.ssl.certificate.file=/etc/ssl/"+secretName+"/tls.crt",
+ "-p", "quarkus.http.ssl.certificate.key-file=/etc/ssl/"+secretName+"/tls.key",
+ "-t", "route.tls-termination=passthrough",
+ "-t", "container.port=8443",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ route := Route(ns, integrationName)
+ Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
+ // must wait a little time after route is created, before an http request,
+ // otherwise the route is unavailable and the http request will fail
+ time.Sleep(waitBeforeHttpRequest)
+ code := "TLS_Passthrough"
+ url := fmt.Sprintf("https://%s/hello?name=%s", route().Spec.Host, code)
+ Eventually(httpRequest(url, true), TestTimeoutShort).Should(Equal("Hello " + code))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+ })
+
+ // =============================
+ // TLS Route Reencrypt
+ // =============================
+ t.Run("Route Reencrypt https works", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
+ // the --resource mounts the certificates inside secret as files in the integration pod
+ "--resource", "secret:"+secretName+"@/etc/ssl/"+secretName,
+ // quarkus platform-http uses these two properties to setup the HTTP endpoint with TLS support
+ "-p", "quarkus.http.ssl.certificate.file=/etc/ssl/"+secretName+"/tls.crt",
+ "-p", "quarkus.http.ssl.certificate.key-file=/etc/ssl/"+secretName+"/tls.key",
+ "-t", "route.tls-termination=reencrypt",
+ // the destination CA certificate which the route service uses to validate the HTTP endpoint TLS certificate
+ "-t", "route.tls-destination-ca-certificate-secret="+refCert,
+ "-t", "route.tls-certificate-secret="+refCert,
+ "-t", "route.tls-key-secret="+refKey,
+ "-t", "container.port=8443",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+ route := Route(ns, integrationName)
+ Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
+ // must wait a little time after route is created, before an http request,
+ // otherwise the route is unavailable and the http request will fail
+ time.Sleep(waitBeforeHttpRequest)
+ code := "TLS_Reencrypt"
+ url := fmt.Sprintf("https://%s/hello?name=%s", route().Spec.Host, code)
+ Eventually(httpRequest(url, true), TestTimeoutShort).Should(Equal("Hello " + code))
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+ })
+
+ t.Run("Route annotations added", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
+ "-t", "route.annotations.'haproxy.router.openshift.io/balance'=roundrobin").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ route := RouteFull(ns, integrationName)()
+ Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
+ // must wait a little time after route is created, before an http request,
+ // otherwise the route is unavailable and the http request will fail
+ time.Sleep(waitBeforeHttpRequest)
+ var annotations = route.ObjectMeta.Annotations
+ Expect(annotations["haproxy.router.openshift.io/balance"]).To(Equal("roundrobin"))
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, integrationName)).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, integrationName)()
+ routeTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "route")
+ Expect(routeTrait).ToNot(BeNil())
+ Expect(len(routeTrait)).To(Equal(1))
+ Expect(routeTrait["enabled"]).To(Equal(true))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+ })
+ Expect(TestClient().Delete(TestContext, &secret)).To(Succeed())
})
- Expect(TestClient().Delete(TestContext, &secret)).To(Succeed())
}
func httpRequest(url string, tlsEnabled bool) func() (string, error) {
diff --git a/e2e/common/traits/service_binding_test.go b/e2e/common/traits/service_binding_test.go
index ae43c5f8c..306529892 100644
--- a/e2e/common/traits/service_binding_test.go
+++ b/e2e/common/traits/service_binding_test.go
@@ -36,73 +36,74 @@ import (
)
func TestServiceBindingTrait(t *testing.T) {
- RegisterTestingT(t)
+ WithNewTestNamespace(t, func(ns string) {
- t.Run("Integration Service Binding", func(t *testing.T) {
- // Create our mock service config
- host := "hostname"
- port := "12324"
- service := &corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: "mock-service-config-it",
- Namespace: ns,
- Annotations: map[string]string{
- "service.binding/host": "path={.data.service-host}",
- "service.binding/port": "path={.data.service-port}",
+ t.Run("Integration Service Binding", func(t *testing.T) {
+ // Create our mock service config
+ host := "hostname"
+ port := "12324"
+ service := &corev1.ConfigMap{
+ TypeMeta: metav1.TypeMeta{
+ Kind: "ConfigMap",
+ APIVersion: "v1",
},
- },
- Data: map[string]string{
- "service-host": host,
- "service-port": port,
- },
- }
- serviceRef := fmt.Sprintf("%s:%s/%s", service.TypeMeta.Kind, ns, service.ObjectMeta.Name)
- Expect(TestClient().Create(TestContext, service)).To(Succeed())
- // Create integration and bind it to our service
- name := RandomizedSuffixName("service-binding")
- Expect(KamelRunWithID(operatorID, ns, "files/ServiceBinding.java",
- "--name", name,
- "--connect", serviceRef,
- ).Execute()).To(Succeed())
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "mock-service-config-it",
+ Namespace: ns,
+ Annotations: map[string]string{
+ "service.binding/host": "path={.data.service-host}",
+ "service.binding/port": "path={.data.service-port}",
+ },
+ },
+ Data: map[string]string{
+ "service-host": host,
+ "service-port": port,
+ },
+ }
+ serviceRef := fmt.Sprintf("%s:%s/%s", service.TypeMeta.Kind, ns, service.ObjectMeta.Name)
+ Expect(TestClient().Create(TestContext, service)).To(Succeed())
+ // Create integration and bind it to our service
+ name := RandomizedSuffixName("service-binding")
+ Expect(KamelRunWithID(operatorID, ns, "files/ServiceBinding.java",
+ "--name", name,
+ "--connect", serviceRef,
+ ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring(fmt.Sprintf("%s:%s", host, port)))
- })
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring(fmt.Sprintf("%s:%s", host, port)))
+ })
- t.Run("Binding Service Binding", func(t *testing.T) {
- // Create our mock service config
- message := "hello"
- service := &corev1.ConfigMap{
- TypeMeta: metav1.TypeMeta{
- Kind: "ConfigMap",
- APIVersion: "v1",
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: "mock-service-config-kb",
- Namespace: ns,
- Annotations: map[string]string{
- "service.binding/message": "path={.data.message}",
+ t.Run("Binding Service Binding", func(t *testing.T) {
+ // Create our mock service config
+ message := "hello"
+ service := &corev1.ConfigMap{
+ TypeMeta: metav1.TypeMeta{
+ Kind: "ConfigMap",
+ APIVersion: "v1",
},
- },
- Data: map[string]string{
- "message": message,
- },
- }
- serviceRef := fmt.Sprintf("%s:%s/%s", service.TypeMeta.Kind, ns, service.ObjectMeta.Name)
- Expect(TestClient().Create(TestContext, service)).To(Succeed())
- Expect(CreateTimerKamelet(ns, "my-timer-source")()).To(Succeed())
- Expect(KamelBindWithID(operatorID, ns, "my-timer-source", "log:info",
- "-p", "source.message=Hello+world",
- "--connect", serviceRef).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "my-timer-source-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationLogs(ns, "my-timer-source-to-log")).Should(ContainSubstring("Body: Hello+world"))
- })
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "mock-service-config-kb",
+ Namespace: ns,
+ Annotations: map[string]string{
+ "service.binding/message": "path={.data.message}",
+ },
+ },
+ Data: map[string]string{
+ "message": message,
+ },
+ }
+ serviceRef := fmt.Sprintf("%s:%s/%s", service.TypeMeta.Kind, ns, service.ObjectMeta.Name)
+ Expect(TestClient().Create(TestContext, service)).To(Succeed())
+ Expect(CreateTimerKamelet(ns, "my-timer-source")()).To(Succeed())
+ Expect(KamelBindWithID(operatorID, ns, "my-timer-source", "log:info",
+ "-p", "source.message=Hello+world",
+ "--connect", serviceRef).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "my-timer-source-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationLogs(ns, "my-timer-source-to-log")).Should(ContainSubstring("Body: Hello+world"))
+ })
- // Clean up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ // Clean up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/common/traits/service_test.go b/e2e/common/traits/service_test.go
index 8b5e5f168..27df68325 100644
--- a/e2e/common/traits/service_test.go
+++ b/e2e/common/traits/service_test.go
@@ -34,88 +34,89 @@ import (
)
func TestServiceTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("NodePort service", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
- "-t", "service.enabled=true",
- "-t", "service.node-port=true").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- //
- // Service names can vary with the ExternalName Service
- // sometimes being created first and being given the root name
- //
- Eventually(ServicesByType(ns, corev1.ServiceTypeNodePort), TestTimeoutLong).ShouldNot(BeEmpty())
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Default service (ClusterIP)", func(t *testing.T) {
- // Service trait is enabled by default
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- //
- // Service names can vary with the ExternalName Service
- // sometimes being created first and being given the root name
- //
- Eventually(ServicesByType(ns, corev1.ServiceTypeClusterIP), TestTimeoutLong).ShouldNot(BeEmpty())
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("NodePort service from Type", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
- "-t", "service.enabled=true",
- "-t", "service.type=NodePort").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- //
- // Service names can vary with the ExternalName Service
- // sometimes being created first and being given the root name
- //
- Eventually(ServicesByType(ns, corev1.ServiceTypeNodePort), TestTimeoutLong).ShouldNot(BeEmpty())
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("ClusterIP service from Type", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
- "-t", "service.enabled=true",
- "-t", "service.type=ClusterIP").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- //
- // Service names can vary with the ExternalName Service
- // sometimes being created first and being given the root name
- //
- Eventually(ServicesByType(ns, corev1.ServiceTypeClusterIP), TestTimeoutLong).ShouldNot(BeEmpty())
-
- // check integration schema does not contains unwanted default trait value.
- Eventually(UnstructuredIntegration(ns, "platform-http-server")).ShouldNot(BeNil())
- unstructuredIntegration := UnstructuredIntegration(ns, "platform-http-server")()
- serviceTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "service")
- Expect(serviceTrait).ToNot(BeNil())
- Expect(len(serviceTrait)).To(Equal(2))
- Expect(serviceTrait["enabled"]).To(Equal(true))
- Expect(serviceTrait["type"]).To(Equal("ClusterIP"))
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("LoadBalancer service from Type", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
- "-t", "service.enabled=true",
- "-t", "service.type=LoadBalancer").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-
- //
- // Service names can vary with the ExternalName Service
- // sometimes being created first and being given the root name
- //
- Eventually(ServicesByType(ns, corev1.ServiceTypeLoadBalancer), TestTimeoutLong).ShouldNot(BeEmpty())
-
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("NodePort service", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
+ "-t", "service.enabled=true",
+ "-t", "service.node-port=true").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+ //
+ // Service names can vary with the ExternalName Service
+ // sometimes being created first and being given the root name
+ //
+ Eventually(ServicesByType(ns, corev1.ServiceTypeNodePort), TestTimeoutLong).ShouldNot(BeEmpty())
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("Default service (ClusterIP)", func(t *testing.T) {
+ // Service trait is enabled by default
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+ //
+ // Service names can vary with the ExternalName Service
+ // sometimes being created first and being given the root name
+ //
+ Eventually(ServicesByType(ns, corev1.ServiceTypeClusterIP), TestTimeoutLong).ShouldNot(BeEmpty())
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("NodePort service from Type", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
+ "-t", "service.enabled=true",
+ "-t", "service.type=NodePort").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+ //
+ // Service names can vary with the ExternalName Service
+ // sometimes being created first and being given the root name
+ //
+ Eventually(ServicesByType(ns, corev1.ServiceTypeNodePort), TestTimeoutLong).ShouldNot(BeEmpty())
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("ClusterIP service from Type", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
+ "-t", "service.enabled=true",
+ "-t", "service.type=ClusterIP").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+ //
+ // Service names can vary with the ExternalName Service
+ // sometimes being created first and being given the root name
+ //
+ Eventually(ServicesByType(ns, corev1.ServiceTypeClusterIP), TestTimeoutLong).ShouldNot(BeEmpty())
+
+ // check integration schema does not contains unwanted default trait value.
+ Eventually(UnstructuredIntegration(ns, "platform-http-server")).ShouldNot(BeNil())
+ unstructuredIntegration := UnstructuredIntegration(ns, "platform-http-server")()
+ serviceTrait, _, _ := unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "service")
+ Expect(serviceTrait).ToNot(BeNil())
+ Expect(len(serviceTrait)).To(Equal(2))
+ Expect(serviceTrait["enabled"]).To(Equal(true))
+ Expect(serviceTrait["type"]).To(Equal("ClusterIP"))
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
+
+ t.Run("LoadBalancer service from Type", func(t *testing.T) {
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
+ "-t", "service.enabled=true",
+ "-t", "service.type=LoadBalancer").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+ //
+ // Service names can vary with the ExternalName Service
+ // sometimes being created first and being given the root name
+ //
+ Eventually(ServicesByType(ns, corev1.ServiceTypeLoadBalancer), TestTimeoutLong).ShouldNot(BeEmpty())
+
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
})
}
diff --git a/e2e/common/traits/toleration_test.go b/e2e/common/traits/toleration_test.go
index 5a723785b..9f5818d4c 100644
--- a/e2e/common/traits/toleration_test.go
+++ b/e2e/common/traits/toleration_test.go
@@ -36,94 +36,95 @@ import (
)
func TestTolerationTrait(t *testing.T) {
- RegisterTestingT(t)
-
- t.Run("Run Java with node toleration operation exists", func(t *testing.T) {
- name := RandomizedSuffixName("java1")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "toleration.enabled=true",
- "-t", "toleration.taints=camel.apache.org/master:NoExecute:300",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- pod := IntegrationPod(ns, name)()
- Expect(pod.Spec.Tolerations).NotTo(BeNil())
-
- Expect(pod.Spec.Tolerations).To(ContainElement(corev1.Toleration{
- Key: "camel.apache.org/master",
- Operator: corev1.TolerationOpExists,
- Effect: corev1.TaintEffectNoExecute,
- TolerationSeconds: pointer.Int64(300),
- }))
- })
-
- t.Run("Run Java with node toleration operation equals", func(t *testing.T) {
- name := RandomizedSuffixName("java2")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- "-t", "toleration.enabled=true",
- "-t", "toleration.taints=camel.apache.org/master=test:NoExecute:300",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- pod := IntegrationPod(ns, name)()
- Expect(pod.Spec.Tolerations).NotTo(BeNil())
-
- Expect(pod.Spec.Tolerations).To(ContainElement(corev1.Toleration{
- Key: "camel.apache.org/master",
- Operator: corev1.TolerationOpEqual,
- Value: "test", Effect: corev1.TaintEffectNoExecute,
- TolerationSeconds: pointer.Int64(300),
- }))
- })
-
- t.Run("Run Java with master node toleration", func(t *testing.T) {
- if len(Nodes()()) == 1 {
- t.Skip("Skip master node toleration test on single-node cluster")
- }
-
- name := RandomizedSuffixName("java3")
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
- "--name", name,
- // Use the affinity trait to force the scheduling of the Integration pod onto a master node
- "-t", "affinity.enabled=true",
- "-t", "affinity.node-affinity-labels=node-role.kubernetes.io/master",
- // And tolerate the corresponding taint
- "-t", "toleration.enabled=true",
- "-t", "toleration.taints=node-role.kubernetes.io/master:NoSchedule",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- pod := IntegrationPod(ns, name)()
- Expect(pod).NotTo(BeNil())
-
- // Check the Integration pod contains the toleration
- Expect(pod.Spec.Tolerations).To(ContainElement(corev1.Toleration{
- Key: "node-role.kubernetes.io/master",
- Operator: corev1.TolerationOpExists,
- Effect: corev1.TaintEffectNoSchedule,
- }))
-
- // Check the Integration pod is running on a master node
- Expect(Node(pod.Spec.NodeName)()).NotTo(BeNil())
- Expect(Node(pod.Spec.NodeName)()).To(PointTo(MatchFields(IgnoreExtras, Fields{
- "Spec": MatchFields(IgnoreExtras, Fields{
- "Taints": ContainElement(corev1.Taint{
- Key: "node-role.kubernetes.io/master",
- Effect: corev1.TaintEffectNoSchedule,
+ WithNewTestNamespace(t, func(ns string) {
+
+ t.Run("Run Java with node toleration operation exists", func(t *testing.T) {
+ name := RandomizedSuffixName("java1")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "toleration.enabled=true",
+ "-t", "toleration.taints=camel.apache.org/master:NoExecute:300",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ pod := IntegrationPod(ns, name)()
+ Expect(pod.Spec.Tolerations).NotTo(BeNil())
+
+ Expect(pod.Spec.Tolerations).To(ContainElement(corev1.Toleration{
+ Key: "camel.apache.org/master",
+ Operator: corev1.TolerationOpExists,
+ Effect: corev1.TaintEffectNoExecute,
+ TolerationSeconds: pointer.Int64(300),
+ }))
+ })
+
+ t.Run("Run Java with node toleration operation equals", func(t *testing.T) {
+ name := RandomizedSuffixName("java2")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ "-t", "toleration.enabled=true",
+ "-t", "toleration.taints=camel.apache.org/master=test:NoExecute:300",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ pod := IntegrationPod(ns, name)()
+ Expect(pod.Spec.Tolerations).NotTo(BeNil())
+
+ Expect(pod.Spec.Tolerations).To(ContainElement(corev1.Toleration{
+ Key: "camel.apache.org/master",
+ Operator: corev1.TolerationOpEqual,
+ Value: "test", Effect: corev1.TaintEffectNoExecute,
+ TolerationSeconds: pointer.Int64(300),
+ }))
+ })
+
+ t.Run("Run Java with master node toleration", func(t *testing.T) {
+ if len(Nodes()()) == 1 {
+ t.Skip("Skip master node toleration test on single-node cluster")
+ }
+
+ name := RandomizedSuffixName("java3")
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+ "--name", name,
+ // Use the affinity trait to force the scheduling of the Integration pod onto a master node
+ "-t", "affinity.enabled=true",
+ "-t", "affinity.node-affinity-labels=node-role.kubernetes.io/master",
+ // And tolerate the corresponding taint
+ "-t", "toleration.enabled=true",
+ "-t", "toleration.taints=node-role.kubernetes.io/master:NoSchedule",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+ pod := IntegrationPod(ns, name)()
+ Expect(pod).NotTo(BeNil())
+
+ // Check the Integration pod contains the toleration
+ Expect(pod.Spec.Tolerations).To(ContainElement(corev1.Toleration{
+ Key: "node-role.kubernetes.io/master",
+ Operator: corev1.TolerationOpExists,
+ Effect: corev1.TaintEffectNoSchedule,
+ }))
+
+ // Check the Integration pod is running on a master node
+ Expect(Node(pod.Spec.NodeName)()).NotTo(BeNil())
+ Expect(Node(pod.Spec.NodeName)()).To(PointTo(MatchFields(IgnoreExtras, Fields{
+ "Spec": MatchFields(IgnoreExtras, Fields{
+ "Taints": ContainElement(corev1.Taint{
+ Key: "node-role.kubernetes.io/master",
+ Effect: corev1.TaintEffectNoSchedule,
+ }),
}),
- }),
- })))
- })
+ })))
+ })
- // Clean up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ // Clean up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ })
}
diff --git a/e2e/install/cli/uninstall_test.go b/e2e/install/cli/uninstall_test.go
index 0ff450d11..7bda494eb 100644
--- a/e2e/install/cli/uninstall_test.go
+++ b/e2e/install/cli/uninstall_test.go
@@ -46,7 +46,7 @@ func TestBasicUninstall(t *testing.T) {
// Roles only removed in non-olm use-case
uninstallViaOLM := false
var err error
- if uninstallViaOLM, err = olm.IsAPIAvailable(TestContext, TestClient(), ns); err != nil {
+ if uninstallViaOLM, err = olm.IsAPIAvailable(TestClient()); err != nil {
t.Error(err)
t.FailNow()
}
diff --git a/e2e/install/kustomize/operator_test.go b/e2e/install/kustomize/operator_test.go
index 418f71ed0..bf5b67064 100644
--- a/e2e/install/kustomize/operator_test.go
+++ b/e2e/install/kustomize/operator_test.go
@@ -41,7 +41,8 @@ func TestOperatorBasic(t *testing.T) {
os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
- UninstallAll()
+ RegisterTestingT(t)
+ Expect(UninstallAll()).To(Succeed())
// Return the cluster to previous state
defer Cleanup()
@@ -84,7 +85,8 @@ func TestOperatorKustomizeAlternativeImage(t *testing.T) {
os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
- UninstallAll()
+ RegisterTestingT(t)
+ Expect(UninstallAll()).To(Succeed())
// Return the cluster to previous state
defer Cleanup()
@@ -115,7 +117,8 @@ func TestOperatorKustomizeGlobal(t *testing.T) {
os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
- UninstallAll()
+ RegisterTestingT(t)
+ Expect(UninstallAll()).To(Succeed())
// Return the cluster to previous state
defer Cleanup()
diff --git a/e2e/install/kustomize/setup_test.go b/e2e/install/kustomize/setup_test.go
index 429f516e7..9434e17f4 100644
--- a/e2e/install/kustomize/setup_test.go
+++ b/e2e/install/kustomize/setup_test.go
@@ -29,6 +29,7 @@ import (
. "github.com/apache/camel-k/v2/e2e/support"
testutil "github.com/apache/camel-k/v2/e2e/support/util"
+ "github.com/apache/camel-k/v2/pkg/util/defaults"
. "github.com/onsi/gomega"
)
@@ -38,7 +39,7 @@ func TestSetupKustomizeBasic(t *testing.T) {
os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
- UninstallAll()
+ Expect(UninstallAll()).To(Succeed())
Eventually(CRDs()).Should(HaveLen(0))
// Return the cluster to previous state
@@ -47,7 +48,7 @@ func TestSetupKustomizeBasic(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
namespaceArg := fmt.Sprintf("NAMESPACE=%s", ns)
ExpectExecSucceed(t, Make("setup-cluster", namespaceArg))
- Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
+ Eventually(CRDs()).Should(HaveLen(GetExpectedCRDs(defaults.Version)))
ExpectExecSucceed(t, Make("setup", namespaceArg))
@@ -70,7 +71,8 @@ func TestSetupKustomizeGlobal(t *testing.T) {
os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
- UninstallAll()
+ RegisterTestingT(t)
+ Expect(UninstallAll()).To(Succeed())
Eventually(CRDs()).Should(HaveLen(0))
// Return the cluster to previous state
@@ -79,7 +81,7 @@ func TestSetupKustomizeGlobal(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
namespaceArg := fmt.Sprintf("NAMESPACE=%s", ns)
ExpectExecSucceed(t, Make("setup-cluster", namespaceArg))
- Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
+ Eventually(CRDs()).Should(HaveLen(GetExpectedCRDs(defaults.Version)))
ExpectExecSucceed(t, Make("setup", "GLOBAL=true", namespaceArg))
diff --git a/e2e/install/kustomize/uninstall_test.go b/e2e/install/kustomize/uninstall_test.go
index c56bc74f5..7c8e93c35 100644
--- a/e2e/install/kustomize/uninstall_test.go
+++ b/e2e/install/kustomize/uninstall_test.go
@@ -31,6 +31,7 @@ import (
. "github.com/apache/camel-k/v2/e2e/support"
testutil "github.com/apache/camel-k/v2/e2e/support/util"
+ "github.com/apache/camel-k/v2/pkg/util/defaults"
. "github.com/onsi/gomega"
)
@@ -40,7 +41,7 @@ func TestKustomizeUninstallBasic(t *testing.T) {
os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
- UninstallAll()
+ Expect(UninstallAll()).To(Succeed())
Eventually(CRDs()).Should(HaveLen(0))
// Return the cluster to previous state
@@ -69,7 +70,7 @@ func TestKustomizeUninstallBasic(t *testing.T) {
Eventually(Role(ns)).Should(BeNil())
Eventually(ClusterRole()).Should(BeNil())
// CRDs should be still there
- Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
+ Eventually(CRDs()).Should(HaveLen(GetExpectedCRDs(defaults.Version)))
// Do uninstall all
ExpectExecSucceed(t, Make("uninstall", namespaceArg, "UNINSTALL_ALL=true"))
@@ -85,7 +86,7 @@ func TestUninstallGlobal(t *testing.T) {
os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
- UninstallAll()
+ Expect(UninstallAll()).To(Succeed())
Eventually(CRDs()).Should(HaveLen(0))
// Return the cluster to previous state
@@ -112,7 +113,7 @@ func TestUninstallGlobal(t *testing.T) {
Eventually(Role(ns)).Should(BeNil())
Eventually(ClusterRole()).Should(BeNil())
// CRDs should be still there
- Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
+ Eventually(CRDs()).Should(HaveLen(GetExpectedCRDs(defaults.Version)))
// Do uninstall all
ExpectExecSucceed(t, Make("uninstall", namespaceArg, "UNINSTALL_ALL=true"))
diff --git a/e2e/install/upgrade/cli_upgrade_test.go b/e2e/install/upgrade/cli_upgrade_test.go
index 9f87f753a..276e697f5 100644
--- a/e2e/install/upgrade/cli_upgrade_test.go
+++ b/e2e/install/upgrade/cli_upgrade_test.go
@@ -30,6 +30,7 @@ import (
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
+ kerrors "k8s.io/apimachinery/pkg/api/errors"
. "github.com/apache/camel-k/v2/e2e/support"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -51,6 +52,15 @@ func TestCLIOperatorUpgrade(t *testing.T) {
// Set KAMEL_BIN only for this test - don't override the ENV variable for all tests
Expect(os.Setenv("KAMEL_BIN", kamel)).To(Succeed())
+ if len(CRDs()()) > 0 {
+ // Clean up old installation - maybe leftover from another test
+ if err := UninstallAll(); err != nil && !kerrors.IsNotFound(err) {
+ t.Error(err)
+ t.FailNow()
+ }
+ }
+ Eventually(CRDs()).Should(HaveLen(0))
+
// Should both install the CRDs and kamel in the given namespace
Expect(Kamel(
"install",
@@ -126,6 +136,8 @@ func TestCLIOperatorUpgrade(t *testing.T) {
// Clean up
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ // Delete Integration Platform as it does not get removed with uninstall and might cause next tests to fail
+ DeletePlatform(ns)()
Expect(Kamel("uninstall", "--all", "-n", ns, "--olm=false").Execute()).To(Succeed())
})
}
diff --git a/e2e/install/upgrade/helm_upgrade_test.go b/e2e/install/upgrade/helm_upgrade_test.go
index 17287386d..6b72728ce 100644
--- a/e2e/install/upgrade/helm_upgrade_test.go
+++ b/e2e/install/upgrade/helm_upgrade_test.go
@@ -29,10 +29,13 @@ import (
"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"
+ kerrors "k8s.io/apimachinery/pkg/api/errors"
+
+ . "github.com/apache/camel-k/v2/e2e/support"
+ "github.com/apache/camel-k/v2/pkg/util/defaults"
)
// WARNING: this test is not OLM specific but needs certain setting we provide in OLM installation scenario
@@ -51,14 +54,20 @@ func TestHelmOperatorUpgrade(t *testing.T) {
customImage := fmt.Sprintf("%s/apache/camel-k", KAMEL_INSTALL_REGISTRY)
- os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../")
+ if err := os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../"); err != nil {
+ t.Logf("Unable to set makefile directory envvar - %s", err.Error())
+ }
- // Ensure no CRDs are already installed
- UninstallAll()
+ if len(CRDs()()) > 0 {
+ // Clean up old installation - maybe leftover from another test
+ if err := UninstallAll(); err != nil && !kerrors.IsNotFound(err) {
+ t.Error(err)
+ t.FailNow()
+ }
+ }
Eventually(CRDs()).Should(HaveLen(0))
WithNewTestNamespace(t, func(ns string) {
-
// Install operator in last released version
ExpectExecSucceed(t,
exec.Command(
@@ -77,9 +86,9 @@ func TestHelmOperatorUpgrade(t *testing.T) {
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
Eventually(OperatorImage(ns)).Should(ContainSubstring(releaseVersion))
- Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
+ Eventually(CRDs()).Should(HaveLen(GetExpectedCRDs(releaseVersion)))
- //Test a simple route
+ // Test a simple route
t.Run("simple route", func(t *testing.T) {
name := RandomizedSuffixName("yaml")
Expect(KamelRun(ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
@@ -134,7 +143,7 @@ func TestHelmOperatorUpgrade(t *testing.T) {
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
Eventually(OperatorImage(ns)).Should(ContainSubstring(defaults.Version))
- //Test again a simple route
+ // Test again a simple route
t.Run("simple route upgraded", func(t *testing.T) {
name := RandomizedSuffixName("yaml")
Expect(KamelRun(ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
@@ -142,6 +151,12 @@ func TestHelmOperatorUpgrade(t *testing.T) {
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
})
+ // Clean up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+
+ // Delete Integration Platform as it does not get removed with uninstall and might cause next tests to fail
+ DeletePlatform(ns)()
+
// Uninstall with helm
ExpectExecSucceed(t,
exec.Command(
@@ -155,7 +170,7 @@ func TestHelmOperatorUpgrade(t *testing.T) {
Eventually(OperatorPod(ns)).Should(BeNil())
// helm does not remove the CRDs
- Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
+ Eventually(CRDs()).Should(HaveLen(GetExpectedCRDs(defaults.Version)))
ExpectExecSucceed(t,
exec.Command(
"kubectl",
diff --git a/e2e/install/upgrade/olm_upgrade_test.go b/e2e/install/upgrade/olm_upgrade_test.go
index 09b20315b..e1af933ee 100644
--- a/e2e/install/upgrade/olm_upgrade_test.go
+++ b/e2e/install/upgrade/olm_upgrade_test.go
@@ -32,6 +32,7 @@ import (
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/require"
+ kerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
@@ -72,7 +73,7 @@ func TestOLMOperatorUpgrade(t *testing.T) {
if ocp {
// Wait for pull secret to be created in namespace
- // eg. test-camel-k-source-dockercfg-zlltn
+ // e.g. test-camel-k-source-dockercfg-zlltn
secretPrefix := fmt.Sprintf("%s-dockercfg-", catalogSourceName)
Eventually(SecretByName(ns, secretPrefix), TestTimeoutLong).Should(Not(BeNil()))
}
@@ -83,6 +84,15 @@ func TestOLMOperatorUpgrade(t *testing.T) {
// Set KAMEL_BIN only for this test - don't override the ENV variable for all tests
Expect(os.Setenv("KAMEL_BIN", kamel)).To(Succeed())
+ if len(CRDs()()) > 0 {
+ // Clean up old installation - maybe leftover from another test
+ if err := UninstallAll(); err != nil && !kerrors.IsNotFound(err) {
+ t.Error(err)
+ t.FailNow()
+ }
+ }
+ Eventually(CRDs()).Should(HaveLen(0))
+
args := []string{
"install",
"-n", ns,
@@ -241,6 +251,8 @@ func TestOLMOperatorUpgrade(t *testing.T) {
// Clean up
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ // Delete Integration Platform as it does not get removed with uninstall and might cause next tests to fail
+ DeletePlatform(ns)()
Expect(Kamel("uninstall", "-n", ns).Execute()).To(Succeed())
// Clean up cluster-wide resources that are not removed by OLM
Expect(Kamel("uninstall", "--all", "-n", ns, "--olm=false").Execute()).To(Succeed())
diff --git a/e2e/knative/default.go b/e2e/knative/default.go
index 20fe113af..1def62779 100644
--- a/e2e/knative/default.go
+++ b/e2e/knative/default.go
@@ -20,7 +20,10 @@ limitations under the License.
package knative
-import "github.com/apache/camel-k/v2/e2e/support"
+import (
+ "github.com/apache/camel-k/v2/e2e/support"
+ "github.com/apache/camel-k/v2/pkg/platform"
+)
-var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.GetCIProcessID())
-var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", support.GetCIProcessID())
+var ns = support.GetEnvOrDefault("CAMEL_K_TEST_NAMESPACE", support.TestDefaultNamespace)
+var operatorID = support.GetEnvOrDefault("CAMEL_K_OPERATOR_ID", platform.DefaultPlatformName)
diff --git a/e2e/knative/knative_platform_test.go b/e2e/knative/knative_platform_test.go
index 94da2022a..52f001e4c 100644
--- a/e2e/knative/knative_platform_test.go
+++ b/e2e/knative/knative_platform_test.go
@@ -49,7 +49,7 @@ func TestKnativePlatformDetection(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-knative"
- // Install withouth profile (should automatically detect the presence of KNative)
+ // Install without profile (should automatically detect the presence of Knative)
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
Eventually(PlatformProfile(ns), TestTimeoutShort).Should(Equal(v1.TraitProfile("")))
@@ -60,7 +60,7 @@ func TestKnativePlatformDetection(t *testing.T) {
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Eventually(IntegrationTraitProfile(ns, "yaml"), TestTimeoutShort).Should(Equal(v1.TraitProfile(string(cluster))))
- // Change something in the integration to produce a redeploy
+ // Change something in the integration to produce a redeployment
Expect(UpdateIntegration(ns, "yaml", func(it *v1.Integration) {
it.Spec.Profile = ""
content, err := dsl.ToYamlDSL(it.Spec.Flows)
diff --git a/e2e/knative/support/startup_test.go b/e2e/knative/support/startup_test.go
deleted file mode 100644
index da04425db..000000000
--- a/e2e/knative/support/startup_test.go
+++ /dev/null
@@ -1,51 +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 support
-
-import (
- "testing"
-
- . "github.com/onsi/gomega"
- corev1 "k8s.io/api/core/v1"
-
- . "github.com/apache/camel-k/v2/e2e/support"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-)
-
-func TestKNativeCamelKInstallStartup(t *testing.T) {
- RegisterTestingT(t)
-
- ns := NewTestNamespace(false)
- Expect(ns).ShouldNot(BeNil())
- // the namespace is dynamic if there is some collision
- // we store this value as it will be used for cleaning in the teardown process
- SaveCIProcessID(ns.GetName())
- // fail fast if something did not work writing the resource
- Expect(GetCIProcessID()).ShouldNot(Equal(""))
-
- Expect(KamelInstallWithIDAndKameletCatalog(ns.GetName(), ns.GetName(), "--trait-profile", "knative").Execute()).To(Succeed())
- Eventually(OperatorPod(ns.GetName())).ShouldNot(BeNil())
- Eventually(Platform(ns.GetName())).ShouldNot(BeNil())
- Eventually(PlatformConditionStatus(ns.GetName(), v1.IntegrationPlatformConditionTypeCreated), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
-}
diff --git a/e2e/knative/support/teardown_test.go b/e2e/knative/support/teardown_test.go
deleted file mode 100644
index af4f0c9d8..000000000
--- a/e2e/knative/support/teardown_test.go
+++ /dev/null
@@ -1,40 +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 support
-
-import (
- "testing"
-
- . "github.com/onsi/gomega"
-
- . "github.com/apache/camel-k/v2/e2e/support"
-)
-
-func TestKNativeCamelKInstallTeardown(t *testing.T) {
- RegisterTestingT(t)
-
- ns := GetCIProcessID()
- Expect(ns).ShouldNot(Equal(""))
- Expect(DeleteNamespace(t, ns)).To(Succeed())
- DeleteCIProcessID()
-}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 5e351328b..e54d8ba5c 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -98,10 +98,10 @@ const kubeConfigEnvVar = "KUBECONFIG"
const ciPID = "/tmp/ci-k8s-pid"
// v1.Build, v1.Integration
-// v1.IntegrationKit, v1.IntegrationPlatform
+// v1.IntegrationKit, v1.IntegrationPlatform, v1.IntegrationProfile
// v1.Kamelet, v1.Pipe,
// v1alpha1.Kamelet, v1alpha1.KameletBinding
-const ExpectedCRDs = 8
+const ExpectedCRDs = 9
// camel-k-operator,
// camel-k-operator-events,
@@ -124,6 +124,8 @@ const ExpectedOSPromoteRoles = 1
// camel-k-operator-console-openshift
const ExpectedOSClusterRoles = 1
+var TestDefaultNamespace = "default"
+
var TestTimeoutShort = 1 * time.Minute
var TestTimeoutMedium = 5 * time.Minute
var TestTimeoutLong = 15 * time.Minute
@@ -347,20 +349,6 @@ func KamelCommandWithContext(ctx context.Context, command string, operatorID str
return KamelWithContext(ctx, cmdArgs...)
}
-func verifyGlobalOperator() error {
- opns := os.Getenv("CAMEL_K_GLOBAL_OPERATOR_NS")
- if opns == "" {
- return errors.New("no operator namespace defined in CAMEL_K_GLOBAL_OPERATOR_NS")
- }
-
- oppod := OperatorPod(opns)()
- if oppod == nil {
- return fmt.Errorf("no operator pod detected in namespace %s. Operator install is a pre-requisite of the test", opns)
- }
-
- return nil
-}
-
func KamelWithContext(ctx context.Context, args ...string) *cobra.Command {
var c *cobra.Command
var err error
@@ -1945,10 +1933,48 @@ func PlatformByName(ns string, name string) func() *v1.IntegrationPlatform {
}
}
+func CopyIntegrationKits(ns, operatorID string) error {
+ opns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)
+
+ lst := v1.NewIntegrationKitList()
+ if err := TestClient().List(TestContext, &lst, ctrl.InNamespace(opns)); err != nil {
+ failTest(err)
+ }
+ for _, kit := range lst.Items {
+ if kit.Status.Image != "" {
+ copyKit := v1.IntegrationKit{
+ ObjectMeta: metav1.ObjectMeta{
+ Namespace: ns,
+ Name: kit.Name,
+ },
+ Spec: *kit.Spec.DeepCopy(),
+ }
+
+ if copyKit.Labels == nil {
+ copyKit.Labels = make(map[string]string)
+ }
+
+ copyKit.Labels[v1.IntegrationKitTypeLabel] = v1.IntegrationKitTypeExternal
+ copyKit.Spec.Image = kit.Status.Image
+
+ v1.SetAnnotation(©Kit.ObjectMeta, v1.OperatorIDAnnotation, operatorID)
+ fmt.Printf("Copy integration kit %s from namespace %s\n", kit.Name, opns)
+ if err := CreateIntegrationKit(©Kit)(); err != nil {
+ return err
+ }
+ }
+ }
+
+ return nil
+}
+
func CopyCamelCatalog(ns, operatorID string) error {
catalogName := fmt.Sprintf("camel-catalog-%s", strings.ToLower(defaults.DefaultRuntimeVersion))
- defaultCatalog := CamelCatalog("default", catalogName)()
+ opns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)
+
+ defaultCatalog := CamelCatalog(opns, catalogName)()
if defaultCatalog != nil {
+ fmt.Printf("Copy catalog %s from namespace %s\n", catalogName, opns)
catalog := v1.CamelCatalog{
ObjectMeta: metav1.ObjectMeta{
Namespace: ns,
@@ -2037,6 +2063,12 @@ func CreateCamelCatalog(catalog *v1.CamelCatalog) func() error {
}
}
+func CreateIntegrationKit(kit *v1.IntegrationKit) func() error {
+ return func() error {
+ return TestClient().Create(TestContext, kit)
+ }
+}
+
func DeleteCamelCatalog(ns, name string) func() bool {
return func() bool {
cat := CamelCatalog(ns, name)()
@@ -2225,6 +2257,17 @@ func AssignPlatformToOperator(ns, operator string) error {
return TestClient().Update(TestContext, pl)
}
+func GetExpectedCRDs(releaseVersion string) int {
+ switch releaseVersion {
+ case "2.2.0":
+ return 8
+ case defaults.Version:
+ return ExpectedCRDs
+ }
+
+ return ExpectedCRDs
+}
+
func CRDs() func() []metav1.APIResource {
return func() []metav1.APIResource {
@@ -2233,6 +2276,7 @@ func CRDs() func() []metav1.APIResource {
reflect.TypeOf(v1.Integration{}).Name(),
reflect.TypeOf(v1.IntegrationKit{}).Name(),
reflect.TypeOf(v1.IntegrationPlatform{}).Name(),
+ reflect.TypeOf(v1.IntegrationProfile{}).Name(),
reflect.TypeOf(v1.Kamelet{}).Name(),
reflect.TypeOf(v1.Pipe{}).Name(),
reflect.TypeOf(v1alpha1.KameletBinding{}).Name(),
@@ -2789,7 +2833,7 @@ func deleteKnativeBroker(ns metav1.Object) {
},
ObjectMeta: metav1.ObjectMeta{
Namespace: ns.GetName(),
- Name: "default",
+ Name: TestDefaultNamespace,
},
}
if err := TestClient().Delete(TestContext, &broker); err != nil {
diff --git a/e2e/support/test_util.go b/e2e/support/test_util.go
index e2cbd933f..5753622d4 100644
--- a/e2e/support/test_util.go
+++ b/e2e/support/test_util.go
@@ -23,6 +23,7 @@ limitations under the License.
package support
import (
+ "github.com/apache/camel-k/v2/pkg/util/log"
"os"
"os/exec"
"strings"
@@ -77,7 +78,7 @@ func ExpectExecSucceed(t *testing.T, command *exec.Cmd) {
assert.NotContains(t, strings.ToUpper(cmdErr.String()), "ERROR")
}
-// Expect a command error with an exit code of 1
+// ExpectExecError Expect a command error with an exit code of 1
func ExpectExecError(t *testing.T, command *exec.Cmd) {
t.Helper()
@@ -98,16 +99,20 @@ func ExpectExecError(t *testing.T, command *exec.Cmd) {
assert.Contains(t, strings.ToUpper(cmdErr.String()), "ERROR")
}
-// Clean up the cluster ready for the next set of tests
+// Cleanup Clean up the cluster ready for the next set of tests
func Cleanup() {
// Remove the locally installed operator
- UninstallAll()
+ if err := UninstallAll(); err != nil {
+ log.Error(err, "Failed to uninstall Camel K")
+ }
// Ensure the CRDs & ClusterRoles are reinstalled if not already
- Kamel("install", "--olm=false", "--cluster-setup").Execute()
+ if err := Kamel("install", "--olm=false", "--cluster-setup").Execute(); err != nil {
+ log.Error(err, "Failed to perform Camel K cluster setup")
+ }
}
-// Removes all items
-func UninstallAll() {
- Kamel("uninstall", "--olm=false", "--all").Execute()
+// UninstallAll Removes all items
+func UninstallAll() error {
+ return Kamel("uninstall", "--olm=false", "--all").Execute()
}
diff --git a/e2e/support/util/dump.go b/e2e/support/util/dump.go
index c170cf6aa..a5741e697 100644
--- a/e2e/support/util/dump.go
+++ b/e2e/support/util/dump.go
@@ -258,7 +258,7 @@ func Dump(ctx context.Context, c client.Client, ns string, t *testing.T) error {
// OLM CSV
csvs := olm.ClusterServiceVersionList{}
err = c.List(ctx, &csvs, ctrl.InNamespace(ns))
- if err != nil {
+ if err != nil && !kubernetes.IsUnknownAPIError(err) {
return err
}
t.Logf("\nFound %d OLM CSVs:\n", len(csvs.Items))
diff --git a/e2e/telemetry/telemetry_test.go b/e2e/telemetry/telemetry_test.go
index b32730092..33fc69bac 100644
--- a/e2e/telemetry/telemetry_test.go
+++ b/e2e/telemetry/telemetry_test.go
@@ -59,12 +59,12 @@ func TestTelemetryTrait(t *testing.T) {
Eventually(IntegrationLogs(ns, "rest-consumer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
Eventually(IntegrationLogs(ns, "rest-producer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("%s Doe", name)))
- // Find opentelemetrycollector pod : the exporter is configured to log traces with detailed verborsity.
+ // Find opentelemetry collector pod : the exporter is configured to log traces with detailed verbosity.
pod, err := Pod("otlp", "opentelemetrycollector")()
Expect(err).To(BeNil())
Expect(pod).NotTo(BeNil())
- // Ensured logs in opentelemetrycollector pod are present
+ // Ensured logs in opentelemetry collector pod are present
Eventually(TailedLogs(pod.Namespace, pod.Name, 100), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("http.target: Str(/customers/%s)", name)))
Eventually(TailedLogs(pod.Namespace, pod.Name, 100), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("http.url: Str(http://rest-consumer/customers/%s)", name)))
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 51f69e4a8..c6e787706 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -277,7 +277,7 @@ func (o *installCmdOptions) tryInstallViaOLM(
if err != nil {
return false, err
}
- if olmAvailable, err := olm.IsAPIAvailable(o.Context, olmClient, o.Namespace); err != nil {
+ if olmAvailable, err := olm.IsAPIAvailable(olmClient); err != nil {
return false, fmt.Errorf("error while checking OLM availability. Run with '--olm=false' to skip this check: %w", err)
} else if !olmAvailable {
diff --git a/pkg/cmd/uninstall.go b/pkg/cmd/uninstall.go
index eb0e5b779..461435c0b 100644
--- a/pkg/cmd/uninstall.go
+++ b/pkg/cmd/uninstall.go
@@ -146,7 +146,7 @@ func (o *uninstallCmdOptions) uninstall(cmd *cobra.Command, _ []string) error {
uninstallViaOLM := false
if o.OlmEnabled {
var err error
- if uninstallViaOLM, err = olm.IsAPIAvailable(o.Context, c, o.Namespace); err != nil {
+ if uninstallViaOLM, err = olm.IsAPIAvailable(c); err != nil {
return fmt.Errorf("error while checking OLM availability. Run with '--olm=false' to skip this check: %w", err)
}
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index 9963f855e..e4f655bd0 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -135,7 +135,7 @@ func findAny(ctx context.Context, c k8sclient.Reader, namespace string) (*v1.Int
// findLocal returns the currently installed platform or any platform existing in local namespace.
func findLocal(ctx context.Context, c k8sclient.Reader, namespace string) (*v1.IntegrationPlatform, error) {
- log.Debug("Finding available platforms")
+ log.Debugf("Finding available platforms in namespace %s", namespace)
operatorNamespace := GetOperatorNamespace()
if namespace == operatorNamespace {
@@ -168,7 +168,7 @@ func findLocal(ctx context.Context, c k8sclient.Reader, namespace string) (*v1.I
return fallback, nil
}
- log.Debugf("Unable to find integration platform")
+ log.Debugf("Unable to find integration platform in namespace %s", namespace)
return nil, k8serrors.NewNotFound(v1.Resource("IntegrationPlatform"), DefaultPlatformName)
}
diff --git a/pkg/util/olm/available.go b/pkg/util/olm/available.go
index 68cd35c35..294d31ba1 100644
--- a/pkg/util/olm/available.go
+++ b/pkg/util/olm/available.go
@@ -18,8 +18,6 @@ limitations under the License.
package olm
import (
- "context"
-
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes"
@@ -34,7 +32,7 @@ import (
// IsAPIAvailable returns true if we are connected to a cluster with OLM installed.
//
// This method should not be called from the operator, as it might require permissions that are not available.
-func IsAPIAvailable(ctx context.Context, c kubernetes.Interface, namespace string) (bool, error) {
+func IsAPIAvailable(c kubernetes.Interface) (bool, error) {
// check some Knative APIs
for _, api := range getOLMGroupVersions() {
if installed, err := isAvailable(c, api); err != nil {
diff --git a/script/Makefile b/script/Makefile
index 4de49d689..9ac526c43 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -247,14 +247,13 @@ test: do-build
#
test-common: do-build
FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
- go test -timeout 10m -v ./e2e/common/support/startup_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
+ go test -timeout 10m -v ./e2e/common/setup -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
go test -timeout 30m -v ./e2e/common/languages -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
go test -timeout 30m -v ./e2e/common/cli -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
go test -timeout 30m -v ./e2e/common/config -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
go test -timeout 30m -v ./e2e/common/misc -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
go test -timeout 60m -v ./e2e/common/traits -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
go test -timeout 20m -v ./e2e/common/runtimes -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
- go test -timeout 10m -v ./e2e/common/support/teardown_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
exit $${FAILED}
#
@@ -262,7 +261,7 @@ test-common: do-build
#
test-smoke: do-build
FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
- go test -timeout 10m -v ./e2e/common/support/startup_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
+ go test -timeout 10m -v ./e2e/common/setup -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
go test -timeout 30m -v ./e2e/common/languages -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
go test -timeout 30m -v \
./e2e/common/misc/default.go \
@@ -277,7 +276,6 @@ test-smoke: do-build
./e2e/common/traits/openapi_test.go \
./e2e/common/traits/service_test.go \
-tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
- go test -timeout 10m -v ./e2e/common/support/teardown_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
exit $${FAILED}
#
@@ -317,9 +315,7 @@ test-install-upgrade: do-build
#
test-knative: do-build
STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
- go test -timeout 10m -v ./e2e/knative/support/startup_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
go test -timeout 60m -v ./e2e/knative -tags=integration $(TEST_KNATIVE_RUN) $(GOTESTFMT) || FAILED=1; \
- go test -timeout 10m -v ./e2e/knative/support/teardown_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
exit $${FAILED}
#