-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(e2e): Test on kamelets configurations
* Test of Integrations using kamelets and properties/secrets * Test of Pipes using kamelets and properties/secrets
- Loading branch information
Showing
7 changed files
with
514 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
e2e/common/config/files/TimerKameletIntegrationConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import java.lang.Exception; | ||
import java.lang.Override; | ||
import org.apache.camel.builder.RouteBuilder; | ||
|
||
public class TimerKameletIntegrationConfiguration extends RouteBuilder { | ||
@Override | ||
public void configure() throws Exception { | ||
from("kamelet:my-own-timer-source") | ||
.to("log:info"); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
e2e/common/config/files/TimerKameletIntegrationNamedConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import java.lang.Exception; | ||
import java.lang.Override; | ||
import org.apache.camel.builder.RouteBuilder; | ||
|
||
public class TimerKameletIntegrationNamedConfiguration extends RouteBuilder { | ||
@Override | ||
public void configure() throws Exception { | ||
from("kamelet:my-own-timer-source/mynamedconfig") | ||
.to("log:info"); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
e2e/common/config/files/timer-kamelet-integration-inlined-configuration.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# --------------------------------------------------------------------------- | ||
# 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:my-own-timer-source?message=important%20message" | ||
steps: | ||
- to: | ||
uri: "kamelet:my-own-log-sink?loggerName=integrationLogger" |
27 changes: 27 additions & 0 deletions
27
e2e/common/config/files/timer-kamelet-integration-parameters-configuration.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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:my-own-timer-source" | ||
parameters: | ||
message: "{{my-message}}" | ||
steps: | ||
- to: | ||
uri: "kamelet:my-own-log-sink" | ||
parameters: | ||
loggerName: "{{my-logger}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
//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 config | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
corev1 "k8s.io/api/core/v1" | ||
|
||
. "github.com/apache/camel-k/v2/e2e/support" | ||
) | ||
|
||
// Tests on integration with kamelets containing configuration from properties and secrets | ||
// without having to change the integration code. | ||
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-secrets" | ||
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-secrets" | ||
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", | ||
"-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 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 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 secrets", func(t *testing.T) { | ||
name := "my-own-timer-source-implicit-config-secrets" | ||
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 secrets", func(t *testing.T) { | ||
name := "my-own-timer-source-named-config-mounted-secrets" | ||
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()) | ||
}) | ||
|
||
}) | ||
|
||
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) | ||
Expect(DeleteKamelet(ns, "my-own-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()) | ||
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 secrer 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()) | ||
}) | ||
|
||
}) | ||
|
||
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()) | ||
} |
Oops, something went wrong.