You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/03/28 12:52:49 UTC
[camel-k] branch release-1.12.x updated (0677728de -> 3280f320a)
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a change to branch release-1.12.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
from 0677728de chore: changelog automatic update
new a654320ea fix(builder): native from source should rebuild
new 3120c4070 chore(test): improve testing
new feac6ab92 fix(e2e): proper condition for checking kits
new 3280f320a fix(e2e): route class name
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../native/files/{Java.java => Java2.java} | 4 +-
.../native/files/yaml2.yaml} | 2 +-
e2e/namespace/native/native_test.go | 39 +++++----
e2e/namespace/native/native_with_sources_test.go | 32 ++++++-
pkg/controller/integration/kits.go | 25 ++++++
pkg/controller/integration/kits_test.go | 97 ++++++++++++++++++++++
pkg/resources/resources.go | 17 ++++
7 files changed, 192 insertions(+), 24 deletions(-)
copy e2e/namespace/native/files/{Java.java => Java2.java} (91%)
copy e2e/{local/files/yaml.yaml => namespace/native/files/yaml2.yaml} (96%)
[camel-k] 02/04: chore(test): improve testing
Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch release-1.12.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 3120c407077d25b054e83e9b81f7a218193adffc
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Mar 23 13:05:59 2023 +0100
chore(test): improve testing
---
e2e/namespace/native/native_with_sources_test.go | 59 ++++++++++++------------
pkg/controller/integration/kits.go | 6 ++-
pkg/controller/integration/kits_test.go | 50 +++++++++++++++++++-
3 files changed, 82 insertions(+), 33 deletions(-)
diff --git a/e2e/namespace/native/native_with_sources_test.go b/e2e/namespace/native/native_with_sources_test.go
index fc3c73242..055f23bab 100644
--- a/e2e/namespace/native/native_with_sources_test.go
+++ b/e2e/namespace/native/native_with_sources_test.go
@@ -55,37 +55,38 @@ func TestNativeHighMemoryIntegrations(t *testing.T) {
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magicstring!"))
- })
- t.Run("java native same should not rebuild", func(t *testing.T) {
- name := "java-native-clone"
- Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
- "-t", "quarkus.package-type=native",
- ).Execute()).To(Succeed())
+ t.Run("java native same should not rebuild", func(t *testing.T) {
+ name := "java-native-clone"
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
+ "-t", "quarkus.package-type=native",
+ ).Execute()).To(Succeed())
+
+ // This one should run quickly as it suppose to reuse an IntegrationKit
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPod(ns, name), TestTimeoutShort).
+ Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magicstring!"))
+ Expect(IntegrationKit(ns, "java-native")).Should(Equal(IntegrationKit(ns, "java-native-clone")))
+ })
+
+ t.Run("java native should rebuild", func(t *testing.T) {
+ name := "java-native-2"
+ Expect(KamelRunWithID(operatorID, ns, "files/Java2.java", "--name", name,
+ "-t", "quarkus.package-type=native",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutVeryLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPod(ns, name), TestTimeoutShort).
+ Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magic2string!"))
+ Expect(IntegrationKit(ns, "java-native-2")).ShouldNot(Equal(IntegrationKit(ns, "java-native")))
+ })
- // This one should run quickly as it suppose to reuse an IntegrationKit
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPod(ns, name), TestTimeoutShort).
- Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magicstring!"))
- Expect(IntegrationKit(ns, "java-native")).Should(Equal(IntegrationKit(ns, "java-native-clone")))
- })
-
- t.Run("java native should rebuild", func(t *testing.T) {
- name := "java-native-2"
- Expect(KamelRunWithID(operatorID, ns, "files/Java2.java", "--name", name,
- "-t", "quarkus.package-type=native",
- ).Execute()).To(Succeed())
-
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutVeryLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationPod(ns, name), TestTimeoutShort).
- Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magic2string!"))
- Expect(IntegrationKit(ns, "java-native-2")).ShouldNot(Equal(IntegrationKit(ns, "java-native")))
// Clean up
Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
})
diff --git a/pkg/controller/integration/kits.go b/pkg/controller/integration/kits.go
index 4dfc4c74d..ad48350c6 100644
--- a/pkg/controller/integration/kits.go
+++ b/pkg/controller/integration/kits.go
@@ -259,14 +259,16 @@ func matchesTrait(it map[string]interface{}, kt map[string]interface{}) bool {
func hasMatchingSources(it *v1.Integration, kit *v1.IntegrationKit) bool {
for _, itSource := range it.Sources() {
+ found := false
for _, ikSource := range kit.Spec.Sources {
if itSource.Content == ikSource.Content {
- // found, let's move to the next one
+ found = true
break
}
+ }
+ if !found {
return false
}
-
}
return true
}
diff --git a/pkg/controller/integration/kits_test.go b/pkg/controller/integration/kits_test.go
index 3abc0ef47..312e69b7a 100644
--- a/pkg/controller/integration/kits_test.go
+++ b/pkg/controller/integration/kits_test.go
@@ -356,8 +356,54 @@ func TestHasMatchingSources(t *testing.T) {
},
}
- hasMatchingSources := hasMatchingSources(integration, kit)
- assert.True(t, hasMatchingSources)
+ hms := hasMatchingSources(integration, kit)
+ assert.True(t, hms)
+
+ kit2 := &v1.IntegrationKit{
+ Spec: v1.IntegrationKitSpec{
+ Sources: []v1.SourceSpec{
+ v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ },
+ },
+ }
+
+ hms2 := hasMatchingSources(integration, kit2)
+ assert.True(t, hms2)
+}
+
+func TestHasMatchingMultipleSources(t *testing.T) {
+ integration := &v1.Integration{
+ Spec: v1.IntegrationSpec{
+ Sources: []v1.SourceSpec{
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaShell),
+ },
+ },
+ }
+
+ kit := &v1.IntegrationKit{
+ Spec: v1.IntegrationKitSpec{
+ Sources: []v1.SourceSpec{
+ v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaShell),
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ },
+ },
+ }
+
+ hms := hasMatchingSources(integration, kit)
+ assert.True(t, hms)
+
+ integration2 := &v1.Integration{
+ Spec: v1.IntegrationSpec{
+ Sources: []v1.SourceSpec{
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ },
+ },
+ }
+
+ hms2 := hasMatchingSources(integration2, kit)
+ assert.True(t, hms2)
}
func TestHasNotMatchingSources(t *testing.T) {
[camel-k] 03/04: fix(e2e): proper condition for checking kits
Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch release-1.12.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit feac6ab92759c71e5e4f5c98042a03b2f1b0e49e
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Mar 23 17:19:49 2023 +0100
fix(e2e): proper condition for checking kits
---
e2e/namespace/native/native_test.go | 4 +++-
e2e/namespace/native/native_with_sources_test.go | 4 ++--
pkg/controller/integration/kits.go | 3 +++
pkg/controller/integration/kits_test.go | 17 +++++++++++++----
4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/e2e/namespace/native/native_test.go b/e2e/namespace/native/native_test.go
index e1cf1995a..51c10604d 100644
--- a/e2e/namespace/native/native_test.go
+++ b/e2e/namespace/native/native_test.go
@@ -76,6 +76,8 @@ func TestNativeIntegrations(t *testing.T) {
})
t.Run("automatic rollout deployment from fast-jar to native kit", func(t *testing.T) {
+ // Let's make sure we start from a clean state
+ Expect(DeleteKits(ns)).To(Succeed())
name := "yaml-native"
Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name,
"-t", "quarkus.package-type=fast-jar",
@@ -140,7 +142,7 @@ func TestNativeIntegrations(t *testing.T) {
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!2"))
- Expect(IntegrationKit(ns, "yaml-native")).Should(Equal(IntegrationKit(ns, "yaml-native-2")))
+ Eventually(IntegrationKit(ns, "yaml-native-2")).Should(Equal(IntegrationKit(ns, "yaml-native")()))
})
// Clean up
diff --git a/e2e/namespace/native/native_with_sources_test.go b/e2e/namespace/native/native_with_sources_test.go
index 055f23bab..61aff527b 100644
--- a/e2e/namespace/native/native_with_sources_test.go
+++ b/e2e/namespace/native/native_with_sources_test.go
@@ -69,7 +69,7 @@ func TestNativeHighMemoryIntegrations(t *testing.T) {
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magicstring!"))
- Expect(IntegrationKit(ns, "java-native")).Should(Equal(IntegrationKit(ns, "java-native-clone")))
+ Eventually(IntegrationKit(ns, "java-native-clone")).Should(Equal(IntegrationKit(ns, "java-native")()))
})
t.Run("java native should rebuild", func(t *testing.T) {
@@ -84,7 +84,7 @@ func TestNativeHighMemoryIntegrations(t *testing.T) {
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magic2string!"))
- Expect(IntegrationKit(ns, "java-native-2")).ShouldNot(Equal(IntegrationKit(ns, "java-native")))
+ Eventually(IntegrationKit(ns, "java-native-2")).ShouldNot(Equal(IntegrationKit(ns, "java-native")()))
})
// Clean up
diff --git a/pkg/controller/integration/kits.go b/pkg/controller/integration/kits.go
index ad48350c6..5b464677d 100644
--- a/pkg/controller/integration/kits.go
+++ b/pkg/controller/integration/kits.go
@@ -258,6 +258,9 @@ func matchesTrait(it map[string]interface{}, kt map[string]interface{}) bool {
}
func hasMatchingSources(it *v1.Integration, kit *v1.IntegrationKit) bool {
+ if len(it.Sources()) != len(kit.Spec.Sources) {
+ return false
+ }
for _, itSource := range it.Sources() {
found := false
for _, ikSource := range kit.Spec.Sources {
diff --git a/pkg/controller/integration/kits_test.go b/pkg/controller/integration/kits_test.go
index 312e69b7a..72bfab91b 100644
--- a/pkg/controller/integration/kits_test.go
+++ b/pkg/controller/integration/kits_test.go
@@ -369,7 +369,7 @@ func TestHasMatchingSources(t *testing.T) {
}
hms2 := hasMatchingSources(integration, kit2)
- assert.True(t, hms2)
+ assert.False(t, hms2)
}
func TestHasMatchingMultipleSources(t *testing.T) {
@@ -403,7 +403,7 @@ func TestHasMatchingMultipleSources(t *testing.T) {
}
hms2 := hasMatchingSources(integration2, kit)
- assert.True(t, hms2)
+ assert.False(t, hms2)
}
func TestHasNotMatchingSources(t *testing.T) {
@@ -423,6 +423,15 @@ func TestHasNotMatchingSources(t *testing.T) {
},
}
- hasMatchingSources := hasMatchingSources(integration, kit)
- assert.False(t, hasMatchingSources)
+ hsm := hasMatchingSources(integration, kit)
+ assert.False(t, hsm)
+
+ kit2 := &v1.IntegrationKit{
+ Spec: v1.IntegrationKitSpec{
+ Sources: []v1.SourceSpec{},
+ },
+ }
+
+ hsm2 := hasMatchingSources(integration, kit2)
+ assert.False(t, hsm2)
}
[camel-k] 01/04: fix(builder): native from source should rebuild
Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch release-1.12.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit a654320ead27a4f17689314323a1fb1a89e6a789
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Mar 23 12:03:54 2023 +0100
fix(builder): native from source should rebuild
Closes #4126
---
e2e/namespace/native/files/Java2.java | 28 ++++++++++++++++
e2e/namespace/native/files/yaml2.yaml | 28 ++++++++++++++++
e2e/namespace/native/native_test.go | 37 ++++++++++-----------
e2e/namespace/native/native_with_sources_test.go | 29 ++++++++++++++++
pkg/controller/integration/kits.go | 20 +++++++++++
pkg/controller/integration/kits_test.go | 42 ++++++++++++++++++++++++
pkg/resources/resources.go | 17 ++++++++++
7 files changed, 181 insertions(+), 20 deletions(-)
diff --git a/e2e/namespace/native/files/Java2.java b/e2e/namespace/native/files/Java2.java
new file mode 100644
index 000000000..73b29ab99
--- /dev/null
+++ b/e2e/namespace/native/files/Java2.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("Magic2${header.m}")
+ .log("Java ${body}");
+ }
+ }
diff --git a/e2e/namespace/native/files/yaml2.yaml b/e2e/namespace/native/files/yaml2.yaml
new file mode 100644
index 000000000..d717e5da6
--- /dev/null
+++ b/e2e/namespace/native/files/yaml2.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:
+ - set-header:
+ name: "m"
+ constant: "string!"
+ - set-body:
+ simple: "Magic${header.m}2"
+ - to: "log:info"
diff --git a/e2e/namespace/native/native_test.go b/e2e/namespace/native/native_test.go
index f1686f737..e1cf1995a 100644
--- a/e2e/namespace/native/native_test.go
+++ b/e2e/namespace/native/native_test.go
@@ -75,24 +75,8 @@ func TestNativeIntegrations(t *testing.T) {
Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
})
- t.Run("warm up before native build testing", func(t *testing.T) {
- // The following native build test is under tight time constraints, so here it runs
- // a warm up testing to make sure necessary jars are already downloaded.
- name := "warm-up-yaml"
- 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))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- // Clean up
- Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Expect(DeleteKits(ns)).To(Succeed())
- })
-
t.Run("automatic rollout deployment from fast-jar to native kit", func(t *testing.T) {
- name := "jvm-to-native"
+ name := "yaml-native"
Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name,
"-t", "quarkus.package-type=fast-jar",
"-t", "quarkus.package-type=native",
@@ -143,11 +127,24 @@ func TestNativeIntegrations(t *testing.T) {
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ t.Run("yaml native should not rebuild", func(t *testing.T) {
+ name := "yaml-native-2"
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml2.yaml", "--name", name,
+ "-t", "quarkus.package-type=native",
+ ).Execute()).To(Succeed())
+
+ // This one should run quickly as it suppose to reuse an IntegrationKit
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPod(ns, name), TestTimeoutShort).
+ Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!2"))
+ Expect(IntegrationKit(ns, "yaml-native")).Should(Equal(IntegrationKit(ns, "yaml-native-2")))
+ })
+
// Clean up
Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
})
-
- // Clean up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
}
diff --git a/e2e/namespace/native/native_with_sources_test.go b/e2e/namespace/native/native_with_sources_test.go
index fc39ace54..fc3c73242 100644
--- a/e2e/namespace/native/native_with_sources_test.go
+++ b/e2e/namespace/native/native_with_sources_test.go
@@ -54,9 +54,38 @@ func TestNativeHighMemoryIntegrations(t *testing.T) {
Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magicstring!"))
+ })
+
+ t.Run("java native same should not rebuild", func(t *testing.T) {
+ name := "java-native-clone"
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
+ "-t", "quarkus.package-type=native",
+ ).Execute()).To(Succeed())
+ // This one should run quickly as it suppose to reuse an IntegrationKit
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPod(ns, name), TestTimeoutShort).
+ Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magicstring!"))
+ Expect(IntegrationKit(ns, "java-native")).Should(Equal(IntegrationKit(ns, "java-native-clone")))
+ })
+ t.Run("java native should rebuild", func(t *testing.T) {
+ name := "java-native-2"
+ Expect(KamelRunWithID(operatorID, ns, "files/Java2.java", "--name", name,
+ "-t", "quarkus.package-type=native",
+ ).Execute()).To(Succeed())
+
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutVeryLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPod(ns, name), TestTimeoutShort).
+ Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Java Magic2string!"))
+ Expect(IntegrationKit(ns, "java-native-2")).ShouldNot(Equal(IntegrationKit(ns, "java-native")))
// Clean up
Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
})
diff --git a/pkg/controller/integration/kits.go b/pkg/controller/integration/kits.go
index 433d96180..4dfc4c74d 100644
--- a/pkg/controller/integration/kits.go
+++ b/pkg/controller/integration/kits.go
@@ -131,6 +131,12 @@ func integrationMatches(integration *v1.Integration, kit *v1.IntegrationKit) (bo
ilog.Debug("Integration and integration-kit dependencies do not match", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
return false, nil
}
+ // If IntegrationKit has any source, we must verify that it corresponds with the one in the Integration.
+ // This is important in case of Native builds as we need to rebuild when language requires a source during build.
+ if (kit.Spec.Sources != nil && len(kit.Spec.Sources) > 0) && !hasMatchingSources(integration, kit) {
+ ilog.Debug("Integration and integration-kit sources do not match", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
+ return false, nil
+ }
ilog.Debug("Matched Integration and integration-kit", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
return true, nil
@@ -250,3 +256,17 @@ func matchesTrait(it map[string]interface{}, kt map[string]interface{}) bool {
// perform exact match on the two trait maps
return reflect.DeepEqual(it, kt)
}
+
+func hasMatchingSources(it *v1.Integration, kit *v1.IntegrationKit) bool {
+ for _, itSource := range it.Sources() {
+ for _, ikSource := range kit.Spec.Sources {
+ if itSource.Content == ikSource.Content {
+ // found, let's move to the next one
+ break
+ }
+ return false
+ }
+
+ }
+ return true
+}
diff --git a/pkg/controller/integration/kits_test.go b/pkg/controller/integration/kits_test.go
index 694be1521..3abc0ef47 100644
--- a/pkg/controller/integration/kits_test.go
+++ b/pkg/controller/integration/kits_test.go
@@ -338,3 +338,45 @@ func TestHasMatchingTraits_KitSameTraitShouldBePicked(t *testing.T) {
assert.Nil(t, err)
assert.True(t, ok)
}
+
+func TestHasMatchingSources(t *testing.T) {
+ integration := &v1.Integration{
+ Spec: v1.IntegrationSpec{
+ Sources: []v1.SourceSpec{
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ },
+ },
+ }
+
+ kit := &v1.IntegrationKit{
+ Spec: v1.IntegrationKitSpec{
+ Sources: []v1.SourceSpec{
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ },
+ },
+ }
+
+ hasMatchingSources := hasMatchingSources(integration, kit)
+ assert.True(t, hasMatchingSources)
+}
+
+func TestHasNotMatchingSources(t *testing.T) {
+ integration := &v1.Integration{
+ Spec: v1.IntegrationSpec{
+ Sources: []v1.SourceSpec{
+ v1.NewSourceSpec("test", "some content", v1.LanguageJavaShell),
+ },
+ },
+ }
+
+ kit := &v1.IntegrationKit{
+ Spec: v1.IntegrationKitSpec{
+ Sources: []v1.SourceSpec{
+ v1.NewSourceSpec("test", "some content 2", v1.LanguageJavaShell),
+ },
+ },
+ }
+
+ hasMatchingSources := hasMatchingSources(integration, kit)
+ assert.False(t, hasMatchingSources)
+}
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 23b682afd..0511f9dd1 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -167,6 +167,18 @@ var assets = func() http.FileSystem {
name: "manager",
modTime: time.Time{},
},
+ "/manager/bundle": &vfsgen۰DirInfo{
+ name: "bundle",
+ modTime: time.Time{},
+ },
+ "/manager/bundle/manifests": &vfsgen۰DirInfo{
+ name: "manifests",
+ modTime: time.Time{},
+ },
+ "/manager/bundle/metadata": &vfsgen۰DirInfo{
+ name: "metadata",
+ modTime: time.Time{},
+ },
"/manager/operator-deployment.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-deployment.yaml",
modTime: time.Time{},
@@ -657,6 +669,7 @@ var assets = func() http.FileSystem {
fs["/crd/bases/camel.apache.org_kamelets.yaml"].(os.FileInfo),
}
fs["/manager"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
+ fs["/manager/bundle"].(os.FileInfo),
fs["/manager/operator-deployment.yaml"].(os.FileInfo),
fs["/manager/operator-service-account.yaml"].(os.FileInfo),
fs["/manager/patch-image-pull-policy-always.yaml"].(os.FileInfo),
@@ -668,6 +681,10 @@ var assets = func() http.FileSystem {
fs["/manager/patch-toleration.yaml"].(os.FileInfo),
fs["/manager/patch-watch-namespace-global.yaml"].(os.FileInfo),
}
+ fs["/manager/bundle"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
+ fs["/manager/bundle/manifests"].(os.FileInfo),
+ fs["/manager/bundle/metadata"].(os.FileInfo),
+ }
fs["/prometheus"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
fs["/prometheus/operator-pod-monitor.yaml"].(os.FileInfo),
fs["/prometheus/operator-prometheus-rule.yaml"].(os.FileInfo),
[camel-k] 04/04: fix(e2e): route class name
Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch release-1.12.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 3280f320a6b5294e2fbdace876addb2956c6ed27
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Mar 24 16:54:19 2023 +0100
fix(e2e): route class name
---
e2e/namespace/native/files/Java2.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/e2e/namespace/native/files/Java2.java b/e2e/namespace/native/files/Java2.java
index 73b29ab99..8a3f7ad4a 100644
--- a/e2e/namespace/native/files/Java2.java
+++ b/e2e/namespace/native/files/Java2.java
@@ -17,7 +17,7 @@
import org.apache.camel.builder.RouteBuilder;
- public class Java extends RouteBuilder {
+ public class Java2 extends RouteBuilder {
@Override
public void configure() throws Exception {
from("timer:tick")