diff --git a/e2e/common/config/files/TimerKameletIntegrationConfiguration.java b/e2e/common/config/files/TimerKameletIntegrationConfiguration.java index bed8647712..05f0ac09a3 100644 --- a/e2e/common/config/files/TimerKameletIntegrationConfiguration.java +++ b/e2e/common/config/files/TimerKameletIntegrationConfiguration.java @@ -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"); } } diff --git a/e2e/common/config/files/TimerKameletIntegrationConfiguration01.java b/e2e/common/config/files/TimerKameletIntegrationConfiguration01.java new file mode 100644 index 0000000000..28da13dde7 --- /dev/null +++ b/e2e/common/config/files/TimerKameletIntegrationConfiguration01.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 java.lang.Exception; +import java.lang.Override; +import org.apache.camel.builder.RouteBuilder; + +public class TimerKameletIntegrationConfiguration01 extends RouteBuilder { + @Override + public void configure() throws Exception { + from("kamelet:iconfig01-timer-source") + .to("log:info"); + } +} diff --git a/e2e/common/config/files/TimerKameletIntegrationConfiguration03.java b/e2e/common/config/files/TimerKameletIntegrationConfiguration03.java new file mode 100644 index 0000000000..fa48542245 --- /dev/null +++ b/e2e/common/config/files/TimerKameletIntegrationConfiguration03.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 java.lang.Exception; +import java.lang.Override; +import org.apache.camel.builder.RouteBuilder; + +public class TimerKameletIntegrationConfiguration03 extends RouteBuilder { + @Override + public void configure() throws Exception { + from("kamelet:iconfig03-timer-source") + .to("log:info"); + } +} diff --git a/e2e/common/config/files/TimerKameletIntegrationConfiguration04.java b/e2e/common/config/files/TimerKameletIntegrationConfiguration04.java new file mode 100644 index 0000000000..0468771467 --- /dev/null +++ b/e2e/common/config/files/TimerKameletIntegrationConfiguration04.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 java.lang.Exception; +import java.lang.Override; +import org.apache.camel.builder.RouteBuilder; + +public class TimerKameletIntegrationConfiguration04 extends RouteBuilder { + @Override + public void configure() throws Exception { + from("kamelet:iconfig04-timer-source") + .to("log:info"); + } +} diff --git a/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration.java b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration.java index 6149338275..211b4f4119 100644 --- a/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration.java +++ b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration.java @@ -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"); } } diff --git a/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration05.java b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration05.java new file mode 100644 index 0000000000..5ca3995e0e --- /dev/null +++ b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration05.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 java.lang.Exception; +import java.lang.Override; +import org.apache.camel.builder.RouteBuilder; + +public class TimerKameletIntegrationNamedConfiguration05 extends RouteBuilder { + @Override + public void configure() throws Exception { + from("kamelet:iconfig05-timer-source/mynamedconfig") + .to("log:info"); + } +} diff --git a/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration06.java b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration06.java new file mode 100644 index 0000000000..cfe4108e5c --- /dev/null +++ b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration06.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 java.lang.Exception; +import java.lang.Override; +import org.apache.camel.builder.RouteBuilder; + +public class TimerKameletIntegrationNamedConfiguration06 extends RouteBuilder { + @Override + public void configure() throws Exception { + from("kamelet:iconfig06-timer-source/mynamedconfig") + .to("log:info"); + } +} diff --git a/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration07.java b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration07.java new file mode 100644 index 0000000000..f263b876e5 --- /dev/null +++ b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration07.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 java.lang.Exception; +import java.lang.Override; +import org.apache.camel.builder.RouteBuilder; + +public class TimerKameletIntegrationNamedConfiguration07 extends RouteBuilder { + @Override + public void configure() throws Exception { + from("kamelet:iconfig07-timer-source/mynamedconfig") + .to("log:info"); + } +} diff --git a/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration08.java b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration08.java new file mode 100644 index 0000000000..1ce570df92 --- /dev/null +++ b/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration08.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 java.lang.Exception; +import java.lang.Override; +import org.apache.camel.builder.RouteBuilder; + +public class TimerKameletIntegrationNamedConfiguration08 extends RouteBuilder { + @Override + public void configure() throws Exception { + from("kamelet:iconfig08-timer-source/mynamedconfig") + .to("log:info"); + } +} diff --git a/e2e/common/config/files/timer-kamelet-integration-inlined-configuration.yaml b/e2e/common/config/files/timer-kamelet-integration-inlined-configuration-01.yaml similarity index 87% rename from e2e/common/config/files/timer-kamelet-integration-inlined-configuration.yaml rename to e2e/common/config/files/timer-kamelet-integration-inlined-configuration-01.yaml index d978a0b9ef..3e96ab6235 100644 --- a/e2e/common/config/files/timer-kamelet-integration-inlined-configuration.yaml +++ b/e2e/common/config/files/timer-kamelet-integration-inlined-configuration-01.yaml @@ -17,7 +17,7 @@ - route: from: - uri: "kamelet:my-own-timer-source?message=important%20message" + uri: "kamelet:config01-timer-source?message=important%20message" steps: - to: - uri: "kamelet:my-own-log-sink?loggerName=integrationLogger" \ No newline at end of file + uri: "kamelet:config01-log-sink?loggerName=integrationLogger" \ No newline at end of file diff --git a/e2e/common/config/files/timer-kamelet-integration-parameters-configuration.yaml b/e2e/common/config/files/timer-kamelet-integration-parameters-configuration-02.yaml similarity index 92% rename from e2e/common/config/files/timer-kamelet-integration-parameters-configuration.yaml rename to e2e/common/config/files/timer-kamelet-integration-parameters-configuration-02.yaml index 4926ec9148..3a13b83d3d 100644 --- a/e2e/common/config/files/timer-kamelet-integration-parameters-configuration.yaml +++ b/e2e/common/config/files/timer-kamelet-integration-parameters-configuration-02.yaml @@ -17,11 +17,11 @@ - route: from: - uri: "kamelet:my-own-timer-source" + uri: "kamelet:config02-timer-source" parameters: message: "{{my-message}}" steps: - to: - uri: "kamelet:my-own-log-sink" + uri: "kamelet:config02-log-sink" parameters: loggerName: "{{my-logger}}" \ No newline at end of file diff --git a/e2e/common/config/files/timer-kamelet-integration-parameters-configuration-03.yaml b/e2e/common/config/files/timer-kamelet-integration-parameters-configuration-03.yaml new file mode 100644 index 0000000000..08c830a2e2 --- /dev/null +++ b/e2e/common/config/files/timer-kamelet-integration-parameters-configuration-03.yaml @@ -0,0 +1,27 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "kamelet:config03-timer-source" + parameters: + message: "{{my-message}}" + steps: + - to: + uri: "kamelet:config03-log-sink" + parameters: + loggerName: "{{my-logger}}" \ No newline at end of file diff --git a/e2e/common/config/files/timer-kamelet-integration-parameters-configuration-04.yaml b/e2e/common/config/files/timer-kamelet-integration-parameters-configuration-04.yaml new file mode 100644 index 0000000000..4eefdd2aa2 --- /dev/null +++ b/e2e/common/config/files/timer-kamelet-integration-parameters-configuration-04.yaml @@ -0,0 +1,27 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "kamelet:config04-timer-source" + parameters: + message: "{{my-message}}" + steps: + - to: + uri: "kamelet:config04-log-sink" + parameters: + loggerName: "{{my-logger}}" \ No newline at end of file diff --git a/e2e/common/config/kamelet_config_test.go b/e2e/common/config/kamelet_config_test.go index 9c37e7e416..8b39c81926 100644 --- a/e2e/common/config/kamelet_config_test.go +++ b/e2e/common/config/kamelet_config_test.go @@ -31,233 +31,356 @@ import ( . "github.com/apache/camel-k/v2/e2e/support" ) -// Tests on integration with kamelets containing configuration from properties and secrets +// Tests on integrations with kamelets containing configuration from properties and secrets // // 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) { + + Expect(CreateTimerKamelet(ns, "iconfig01-timer-source")()).To(Succeed()) + + name := "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", "--all", "-n", ns).Execute()).To(Succeed()) +} + +func TestKameletImplicitConfigDefaultMountedSecret(t *testing.T) { + RegisterTestingT(t) + + t.Run("run test default config using mounted secret", func(t *testing.T) { + + Expect(CreateTimerKamelet(ns, "iconfig03-timer-source")()).To(Succeed()) + + name := "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())) + + 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", "--all", "-n", ns).Execute()).To(Succeed()) +} + +func TestKameletImplicitConfigDefaultMountedConfigmap(t *testing.T) { + RegisterTestingT(t) + + t.Run("run test default config using mounted configmap", func(t *testing.T) { + + Expect(CreateTimerKamelet(ns, "iconfig04-timer-source")()).To(Succeed()) + + name := "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()) + + 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", "--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 := "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()) +} + +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 := "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()) +} + +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 := "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()) +} + +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 := "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()) +} + +// Comenting test as it is failing on a non documented behavior. +// See https://github.com/apache/camel-k/issues/4750 +/* 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()) - - t.Run("run test default config using properties", func(t *testing.T) { - name := "my-own-timer-source-config-properties" - - Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration.java", - "-p", "camel.kamelet.my-own-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()) - }) - - t.Run("run test default config using mounted secret", func(t *testing.T) { - name := "my-own-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" - Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed()) - - Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration.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()) - Expect(DeleteSecret(ns, secretName)).To(Succeed()) - }) - - t.Run("run test default config using mounted configmap", func(t *testing.T) { - name := "my-own-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" - Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed()) - - Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration.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()) - Expect(DeleteConfigmap(ns, cmName)).To(Succeed()) - }) - - t.Run("run test named config using properties", func(t *testing.T) { - name := "my-own-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'", - "--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" - - var secData = make(map[string]string) - secData["camel.kamelet.my-own-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.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'", - "--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()) - Expect(DeleteSecret(ns, secretName)).To(Succeed()) - }) - - t.Run("run test named config using mounted secret", func(t *testing.T) { - name := "my-own-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" - Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed()) - - Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration.java", - "-p", "camel.kamelet.my-own-timer-source.message='Default message'", - "-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()) - Expect(DeleteSecret(ns, secretName)).To(Succeed()) - }) - - t.Run("run test named config using mounted configmap", func(t *testing.T) { - name := "my-own-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" - Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed()) - - Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration.java", - "-p", "camel.kamelet.my-own-timer-source.message='Default message'", - "-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()) - Expect(DeleteConfigmap(ns, cmName)).To(Succeed()) - }) + Expect(CreateTimerKamelet(ns, "iconfig-test-timer-source")()).To(Succeed()) + + t.Run("run test default config using labeled secret", func(t *testing.T) { + name := "iconfig-test-timer-source-int2" + 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 02'", + "--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()) + }) }) 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) { + +func TestKameletConfigInlinedUserPropery(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()) - t.Run("run test default config inlined properties", func(t *testing.T) { - name := "my-own-timer-source-inline-properties" - - Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-inlined-configuration.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()) - }) - - t.Run("run test default config parameters properties", func(t *testing.T) { - name := "my-own-timer-source-parameters-properties" - - Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-parameters-configuration.yaml", - "-p", "my-message='My parameter message'", - "-p", "my-logger='myIntegrationLogger'", - "--name", name).Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My parameter message")) - Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myIntegrationLogger")) - - Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed()) - }) - - t.Run("run test default config secret properties", func(t *testing.T) { - name := "my-own-timer-source-secret-properties" - secretName := "my-mounted-secret-properties" - - var secData = make(map[string]string) - secData["my-message"] = "My secret message" - secData["my-logger"] = "mySecretIntegrationLogger" - Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed()) - - Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-parameters-configuration.yaml", - "-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 secret message")) - Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("mySecretIntegrationLogger")) - - Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed()) - Expect(DeleteSecret(ns, secretName)).To(Succeed()) - }) - - t.Run("run test default config configmap properties", func(t *testing.T) { - name := "my-own-timer-source-configmap-properties" - cmName := "my-mounted-configmap-properties" - - var cmData = make(map[string]string) - cmData["my-message"] = "My configmap message" - cmData["my-logger"] = "myConfigmapIntegrationLogger" - Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed()) - - Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-parameters-configuration.yaml", - "-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 configmap message")) - Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myConfigmapIntegrationLogger")) - - Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed()) - Expect(DeleteConfigmap(ns, cmName)).To(Succeed()) - }) + 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 := "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()) +} + +func TestKameletConfigDefaultParamUserPropery(t *testing.T) { + RegisterTestingT(t) + t.Run("run test default config parameters properties", func(t *testing.T) { + + Expect(CreateTimerKamelet(ns, "config02-timer-source")()).To(Succeed()) + Expect(CreateLogKamelet(ns, "config02-log-sink")()).To(Succeed()) + + name := "config-test-timer-source-int2" + Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-parameters-configuration-02.yaml", + "-p", "my-message='My parameter message 02'", + "-p", "my-logger='myIntegrationLogger02'", + "--name", name).Execute()).To(Succeed()) + Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning)) + Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("My parameter message 02")) + Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myIntegrationLogger02")) + + Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed()) + Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil()) + Expect(DeleteKamelet(ns, "config02-timer-source")).To(Succeed()) + Expect(DeleteKamelet(ns, "config02-log-sink")).To(Succeed()) + }) + + Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) +} + +func TestKameletConfigDefaultParamMountedSecret(t *testing.T) { + RegisterTestingT(t) + t.Run("run test default config secret properties", func(t *testing.T) { + + Expect(CreateTimerKamelet(ns, "config03-timer-source")()).To(Succeed()) + Expect(CreateLogKamelet(ns, "config03-log-sink")()).To(Succeed()) + + name := "config-test-timer-source-int3" + secretName := "my-config-int3-secret" + + var secData = make(map[string]string) + secData["my-message"] = "My secret message 03" + secData["my-logger"] = "mySecretIntegrationLogger03" + Expect(CreatePlainTextSecret(ns, secretName, secData)).To(Succeed()) + + Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-parameters-configuration-03.yaml", + "-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 secret message 03")) + Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("mySecretIntegrationLogger03")) + + Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed()) + Eventually(Integration(ns, name), TestTimeoutLong).Should(BeNil()) + Expect(DeleteSecret(ns, secretName)).To(Succeed()) + Expect(DeleteKamelet(ns, "config03-timer-source")).To(Succeed()) + Expect(DeleteKamelet(ns, "config03-log-sink")).To(Succeed()) + }) + + Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) +} + +func TestKameletConfigDefaultParamMountedConfigmap(t *testing.T) { + RegisterTestingT(t) + t.Run("run test default config configmap properties", func(t *testing.T) { + + Expect(CreateTimerKamelet(ns, "config04-timer-source")()).To(Succeed()) + Expect(CreateLogKamelet(ns, "config04-log-sink")()).To(Succeed()) + + name := "config-test-timer-source-int4" + cmName := "my-config-int4-configmap" + + var cmData = make(map[string]string) + cmData["my-message"] = "My configmap message 04" + cmData["my-logger"] = "myConfigmapIntegrationLogger04" + Expect(CreatePlainTextConfigmap(ns, cmName, cmData)).To(Succeed()) + + Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-parameters-configuration-04.yaml", + "-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 configmap message 04")) + Eventually(IntegrationLogs(ns, name)).Should(ContainSubstring("myConfigmapIntegrationLogger04")) + + 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, "config04-timer-source")).To(Succeed()) + Expect(DeleteKamelet(ns, "config04-log-sink")).To(Succeed()) }) 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()) }