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 <[email protected]>
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)
 }

Reply via email to