Skip to content

Commit

Permalink
fix(e2e): Fix E2E test using kamelet my-own-timer-source
Browse files Browse the repository at this point in the history
  • Loading branch information
gansheer committed Sep 18, 2023
1 parent 370f8e9 commit 18b28f1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class TimerKameletIntegrationConfiguration extends RouteBuilder {
@Override
public void configure() throws Exception {
from("kamelet:my-own-timer-source")
from("kamelet:iconfig-test-timer-source")
.to("log:info");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class TimerKameletIntegrationNamedConfiguration extends RouteBuilder {
@Override
public void configure() throws Exception {
from("kamelet:my-own-timer-source/mynamedconfig")
from("kamelet:iconfig-test-timer-source/mynamedconfig")
.to("log:info");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

- route:
from:
uri: "kamelet:my-own-timer-source?message=important%20message"
uri: "kamelet:config-test-timer-source?message=important%20message"
steps:
- to:
uri: "kamelet:my-own-log-sink?loggerName=integrationLogger"
uri: "kamelet:config-test-log-sink?loggerName=integrationLogger"
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

- route:
from:
uri: "kamelet:my-own-timer-source"
uri: "kamelet:config-test-timer-source"
parameters:
message: "{{my-message}}"
steps:
- to:
uri: "kamelet:my-own-log-sink"
uri: "kamelet:config-test-log-sink"
parameters:
loggerName: "{{my-logger}}"
103 changes: 54 additions & 49 deletions e2e/common/config/kamelet_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,51 @@ import (
func TestKameletImplicitConfig(t *testing.T) {
RegisterTestingT(t)
t.Run("test custom timer source", func(t *testing.T) {
Expect(CreateTimerKamelet(ns, "my-own-timer-source")()).To(Succeed())
Expect(CreateTimerKamelet(ns, "iconfig-test-timer-source")()).To(Succeed())

t.Run("run test default config using properties", func(t *testing.T) {
name := "my-own-timer-source-config-properties"
name := "iconfig-test-timer-source-config-properties"

Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration.java",
"-p", "camel.kamelet.my-own-timer-source.message='My Default message'",
"-p", "camel.kamelet.iconfig-test-timer-source.message='My Default message'",
"--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My Default message"))

Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
})

t.Run("run test default config using labeled secret", func(t *testing.T) {
name := "my-own-timer-source-default-config-secret"
secretName := "my-own-timer-source-default"

var secData = make(map[string]string)
secData["camel.kamelet.my-own-timer-source.message"] = "very top secret message"
var labels = make(map[string]string)
labels["camel.apache.org/kamelet"] = "my-own-timer-source"
Expect(CreatePlainTextSecretWithLabels(ns, secretName, secData, labels)).To(Succeed())

Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration.java",
"-p", "camel.kamelet.my-own-timer-source.message='Default message'",
"--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top secret message"))

Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
Expect(DeleteSecret(ns, secretName)).To(Succeed())
})
// Comenting test as it is failing on a non documented behavior.
// See https://github.com/apache/camel-k/issues/4750
/*
t.Run("run test default config using labeled secret", func(t *testing.T) {
name := "iconfig-test-timer-source-default-config-secret"
secretName := "my-labeled-iconfig-test-timer-source-default-secret"
var secData = make(map[string]string)
secData["camel.kamelet.iconfig-test-timer-source.message"] = "very top secret message"
var labels = make(map[string]string)
labels["camel.apache.org/kamelet"] = "iconfig-test-timer-source"
Expect(CreatePlainTextSecretWithLabels(ns, secretName, secData, labels)).To(Succeed())
Eventually(SecretByName(ns, secretName), TestTimeoutLong).Should(Not(BeNil()))
Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration.java",
"-p", "camel.kamelet.iconfig-test-timer-source.message='Default message'",
"--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("very top secret message"))
Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
Expect(DeleteSecret(ns, secretName)).To(Succeed())
})
*/

t.Run("run test default config using mounted secret", func(t *testing.T) {
name := "my-own-timer-source-default-config-mounted-secret"
name := "iconfig-test-timer-source-default-config-mounted-secret"
secretName := "my-mounted-default-secret"

var secData = make(map[string]string)
secData["camel.kamelet.my-own-timer-source.message"] = "very top mounted secret message"
secData["camel.kamelet.iconfig-test-timer-source.message"] = "very top mounted secret message"
Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())

Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration.java",
Expand All @@ -90,11 +95,11 @@ func TestKameletImplicitConfig(t *testing.T) {
})

t.Run("run test default config using mounted configmap", func(t *testing.T) {
name := "my-own-timer-source-default-config-mounted-configmaps"
name := "iconfig-test-timer-source-default-config-mounted-configmaps"
cmName := "my-mounted-default-secret"

var cmData = make(map[string]string)
cmData["camel.kamelet.my-own-timer-source.message"] = "very top mounted configmap message"
cmData["camel.kamelet.iconfig-test-timer-source.message"] = "very top mounted configmap message"
Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())

Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration.java",
Expand All @@ -108,29 +113,29 @@ func TestKameletImplicitConfig(t *testing.T) {
})

t.Run("run test named config using properties", func(t *testing.T) {
name := "my-own-timer-source-config-properties"
name := "iconfig-test-timer-source-config-properties"
Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration.java",
"-p", "camel.kamelet.my-own-timer-source.message='Default message'",
"-p", "camel.kamelet.my-own-timer-source.mynamedconfig.message='My Named Config message'",
"-p", "camel.kamelet.iconfig-test-timer-source.message='Default message'",
"-p", "camel.kamelet.iconfig-test-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())
})

t.Run("run test named config using labeled secret", func(t *testing.T) {
name := "my-own-timer-source-implicit-config-secret"
secretName := "my-own-timer-source-mynamedconfig"
name := "iconfig-test-timer-source-implicit-config-secret"
secretName := "iconfig-test-timer-source-mynamedconfig"

var secData = make(map[string]string)
secData["camel.kamelet.my-own-timer-source.mynamedconfig.message"] = "very top named secret message"
secData["camel.kamelet.iconfig-test-timer-source.mynamedconfig.message"] = "very top named secret message"
var labels = make(map[string]string)
labels["camel.apache.org/kamelet"] = "my-own-timer-source"
labels["camel.apache.org/kamelet"] = "iconfig-test-timer-source"
labels["camel.apache.org/kamelet.configuration"] = "mynamedconfig"
Expect(CreatePlainTextSecretWithLabels(ns, secretName, secData, labels)).To(Succeed())

Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration.java",
"-p", "camel.kamelet.my-own-timer-source.message='Default message'",
"-p", "camel.kamelet.iconfig-test-timer-source.message='Default message'",
"--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"))
Expand All @@ -140,15 +145,15 @@ func TestKameletImplicitConfig(t *testing.T) {
})

t.Run("run test named config using mounted secret", func(t *testing.T) {
name := "my-own-timer-source-named-config-mounted-secret"
name := "iconfig-test-timer-source-named-config-mounted-secret"
secretName := "my-mounted-named-secret"

var secData = make(map[string]string)
secData["camel.kamelet.my-own-timer-source.mynamedconfig.message"] = "very top named mounted secret message"
secData["camel.kamelet.iconfig-test-timer-source.mynamedconfig.message"] = "very top named mounted secret message"
Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed())

Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration.java",
"-p", "camel.kamelet.my-own-timer-source.message='Default message'",
"-p", "camel.kamelet.iconfig-test-timer-source.message='Default message'",
"-t", "mount.configs=secret:"+secretName,
"--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expand All @@ -159,15 +164,15 @@ func TestKameletImplicitConfig(t *testing.T) {
})

t.Run("run test named config using mounted configmap", func(t *testing.T) {
name := "my-own-timer-source-named-config-mounted-configmap"
name := "iconfig-test-timer-source-named-config-mounted-configmap"
cmName := "my-mounted-named-secret"

var cmData = make(map[string]string)
cmData["camel.kamelet.my-own-timer-source.mynamedconfig.message"] = "very top named mounted configmap message"
cmData["camel.kamelet.iconfig-test-timer-source.mynamedconfig.message"] = "very top named mounted configmap message"
Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed())

Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration.java",
"-p", "camel.kamelet.my-own-timer-source.message='Default message'",
"-p", "camel.kamelet.iconfig-test-timer-source.message='Default message'",
"-t", "mount.configs=configmap:"+cmName,
"--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expand All @@ -180,17 +185,17 @@ func TestKameletImplicitConfig(t *testing.T) {
})

Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
Expect(DeleteKamelet(ns, "my-own-timer-source")).To(Succeed())
Expect(DeleteKamelet(ns, "iconfig-test-timer-source")).To(Succeed())
}

// Tests on integration with kamelets containing configuration from properties and secrets with parameters inside the integration.
func TestKameletConfig(t *testing.T) {
RegisterTestingT(t)
t.Run("test custom timer source", func(t *testing.T) {
Expect(CreateTimerKamelet(ns, "my-own-timer-source")()).To(Succeed())
Expect(CreateLogKamelet(ns, "my-own-log-sink")()).To(Succeed())
Expect(CreateTimerKamelet(ns, "config-test-timer-source")()).To(Succeed())
Expect(CreateLogKamelet(ns, "config-test-log-sink")()).To(Succeed())
t.Run("run test default config inlined properties", func(t *testing.T) {
name := "my-own-timer-source-inline-properties"
name := "config-test-timer-source-inline-properties"

Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-inlined-configuration.yaml",
"--name", name).Execute()).To(Succeed())
Expand All @@ -202,7 +207,7 @@ func TestKameletConfig(t *testing.T) {
})

t.Run("run test default config parameters properties", func(t *testing.T) {
name := "my-own-timer-source-parameters-properties"
name := "config-test-timer-source-parameters-properties"

Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-parameters-configuration.yaml",
"-p", "my-message='My parameter message'",
Expand All @@ -216,7 +221,7 @@ func TestKameletConfig(t *testing.T) {
})

t.Run("run test default config secret properties", func(t *testing.T) {
name := "my-own-timer-source-secret-properties"
name := "config-test-timer-source-secret-properties"
secretName := "my-mounted-secret-properties"

var secData = make(map[string]string)
Expand All @@ -236,7 +241,7 @@ func TestKameletConfig(t *testing.T) {
})

t.Run("run test default config configmap properties", func(t *testing.T) {
name := "my-own-timer-source-configmap-properties"
name := "config-test-timer-source-configmap-properties"
cmName := "my-mounted-configmap-properties"

var cmData = make(map[string]string)
Expand All @@ -258,6 +263,6 @@ func TestKameletConfig(t *testing.T) {
})

Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
Expect(DeleteKamelet(ns, "my-own-timer-source")).To(Succeed())
Expect(DeleteKamelet(ns, "my-own-log-sink")).To(Succeed())
Expect(DeleteKamelet(ns, "config-test-timer-source")).To(Succeed())
Expect(DeleteKamelet(ns, "config-test-log-sink")).To(Succeed())
}

0 comments on commit 18b28f1

Please sign in to comment.