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/24 08:13:16 UTC

[camel-k] 04/04: fix(e2e): proper condition for checking kits

This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 630dd58c9a1cc07e0688c43bf9b9d7fc8f9947e8
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Mar 23 17:19:49 2023 +0100

    fix(e2e): proper condition for checking kits
---
 e2e/common/config/config_test.go        |  2 +-
 e2e/native/native_test.go               |  4 +++-
 e2e/native/native_with_sources_test.go  |  4 ++--
 pkg/controller/integration/kits.go      |  3 +++
 pkg/controller/integration/kits_test.go | 17 +++++++++++++----
 5 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/e2e/common/config/config_test.go b/e2e/common/config/config_test.go
index 07b239632..f3362b343 100644
--- a/e2e/common/config/config_test.go
+++ b/e2e/common/config/config_test.go
@@ -283,7 +283,7 @@ func TestRunConfigExamples(t *testing.T) {
 		Eventually(IntegrationConditionStatus(ns, "build-property-route-updated", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
 		Eventually(IntegrationLogs(ns, "build-property-route-updated"), TestTimeoutShort).Should(ContainSubstring("my-super-application-updated"))
 		// Verify the integration kits are different
-		Expect(IntegrationKit(ns, "build-property-route")).ShouldNot(Equal(IntegrationKit(ns, "build-property-route-updated")))
+		Eventually(IntegrationKit(ns, "build-property-route-updated")).ShouldNot(Equal(IntegrationKit(ns, "build-property-route")()))
 		Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
 	})
 
diff --git a/e2e/native/native_test.go b/e2e/native/native_test.go
index e523067fe..d7c7c2ba5 100644
--- a/e2e/native/native_test.go
+++ b/e2e/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/native/native_with_sources_test.go b/e2e/native/native_with_sources_test.go
index fd7c58276..b5128ab95 100644
--- a/e2e/native/native_with_sources_test.go
+++ b/e2e/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 f96ea10e0..8c8cebd1e 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 c4b017c5c..4e316bace 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)
 }