diff --git a/addons/master/master.go b/addons/master/master.go index 33b4ff8a5a..d039cf19a5 100644 --- a/addons/master/master.go +++ b/addons/master/master.go @@ -174,7 +174,7 @@ func findAdditionalDependencies(e *trait.Environment, meta metadata.IntegrationM parts := strings.Split(endpoint, ":") if len(parts) > 2 { // syntax "master:lockname:endpoint:..." - childComponent := parts[2] + childComponent := strings.ReplaceAll(parts[2], "/", "") if artifact := e.CamelCatalog.GetArtifactByScheme(childComponent); artifact != nil { dependencies = append(dependencies, artifact.GetDependencyID()) } diff --git a/e2e/files/Master.java b/e2e/files/Master.java new file mode 100644 index 0000000000..ff28451da7 --- /dev/null +++ b/e2e/files/Master.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("master:lock:timer:tick") + .setHeader("m").constant("string!") + .setBody().simple("Magic${header.m}") + .log("${body}"); + } +} diff --git a/e2e/run_test.go b/e2e/run_test.go index 9eb83b6336..ba999950a0 100644 --- a/e2e/run_test.go +++ b/e2e/run_test.go @@ -53,6 +53,21 @@ func TestRunSimpleExamples(t *testing.T) { Expect(kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil()) }) + t.Run("run java with master", func(t *testing.T) { + RegisterTestingT(t) + Expect(kamel("run", "-n", ns, "files/Master.java").Execute()).Should(BeNil()) + Eventually(integrationPodPhase(ns, "master"), 5*time.Minute).Should(Equal(v1.PodRunning)) + Eventually(integrationLogs(ns, "master"), 1*time.Minute).Should(ContainSubstring("Magicstring!")) + Eventually(configMap(ns, "master-lock"), 10*time.Second).ShouldNot(BeNil()) + // Start a second integration with the same lock (it should not start the route) + Expect(kamel("run", "-n", ns, "files/Master.java", "--name", "second", + "-t", "master.configmap=master", "-t", "master.label-value=master").Execute()).Should(BeNil()) + Eventually(integrationPodPhase(ns, "second"), 5*time.Minute).Should(Equal(v1.PodRunning)) + Eventually(integrationLogs(ns, "second"), 1*time.Minute).Should(ContainSubstring("started in")) + Eventually(integrationLogs(ns, "second"), 30*time.Second).ShouldNot(ContainSubstring("Magicstring!")) + Expect(kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil()) + }) + t.Run("run xml", func(t *testing.T) { RegisterTestingT(t) Expect(kamel("run", "-n", ns, "files/xml.xml").Execute()).Should(BeNil()) diff --git a/e2e/test_support.go b/e2e/test_support.go index 4df31d5832..66e7a6c120 100644 --- a/e2e/test_support.go +++ b/e2e/test_support.go @@ -211,7 +211,7 @@ func integrationPod(ns string, name string) func() *corev1.Pod { lst := corev1.PodList{ TypeMeta: metav1.TypeMeta{ Kind: "Pod", - APIVersion: v1.SchemeGroupVersion.String(), + APIVersion: corev1.SchemeGroupVersion.String(), }, } err := testClient.List(testContext, &lst, @@ -229,6 +229,23 @@ func integrationPod(ns string, name string) func() *corev1.Pod { } } +func configMap(ns string, name string) func() *corev1.ConfigMap { + return func() *corev1.ConfigMap { + cm := corev1.ConfigMap{} + key := k8sclient.ObjectKey{ + Namespace: ns, + Name: name, + } + err := testClient.Get(testContext, key, &cm) + if err != nil && k8serrors.IsNotFound(err) { + return nil + } else if err != nil { + panic(err) + } + return &cm + } +} + func integrationCronJob(ns string, name string) func() *v1beta1.CronJob { return func() *v1beta1.CronJob { lst := v1beta1.CronJobList{