You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/12/07 13:23:53 UTC

[camel-k] 04/04: chore: Update Kamelet update e2e test

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

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

commit cc924ded5198f141b349b2a69b137e5b3dc37cbb
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Tue Dec 7 09:28:51 2021 +0100

    chore: Update Kamelet update e2e test
---
 ...elet_upgrade_test.go => kamelet_update_test.go} | 24 +++++++++++-----------
 e2e/support/test_support.go                        | 14 ++++---------
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/e2e/common/kamelet_upgrade_test.go b/e2e/common/kamelet_update_test.go
similarity index 67%
rename from e2e/common/kamelet_upgrade_test.go
rename to e2e/common/kamelet_update_test.go
index a426f46..c39a981 100644
--- a/e2e/common/kamelet_upgrade_test.go
+++ b/e2e/common/kamelet_update_test.go
@@ -32,26 +32,26 @@ import (
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 )
 
-const preExistingKameletMarker = "pre-existing-kamelet"
-
-func TestKameletUpgrade(t *testing.T) {
+const customLabel = "custom-label"
 
+func TestBundleKameletUpdate(t *testing.T) {
 	WithNewTestNamespace(t, func(ns string) {
-		Expect(createOperatorManagedKamelet(ns, "http-sink")()).To(Succeed()) // Going to be replaced
-		Expect(createUserManagedKamelet(ns, "ftp-sink")()).To(Succeed())      // Left intact by the operator
-		// Leverages the fact that the default kamelet catalog contains embedded "http-sink" and "ftp-sink"
+		Expect(createBundleKamelet(ns, "http-sink")()).To(Succeed()) // Going to be replaced
+		Expect(createUserKamelet(ns, "user-sink")()).To(Succeed())   // Left intact by the operator
 
 		Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
 
-		Eventually(KameletHasLabel("http-sink", ns, preExistingKameletMarker)).Should(BeFalse())
-		Consistently(KameletHasLabel("ftp-sink", ns, preExistingKameletMarker), 5*time.Second, 1*time.Second).Should(BeTrue())
+		Eventually(Kamelet("http-sink", ns)).
+			Should(WithTransform(KameletLabels, HaveKeyWithValue(customLabel, "true")))
+		Consistently(Kamelet("user-sink", ns), 5*time.Second, 1*time.Second).
+			Should(WithTransform(KameletLabels, HaveKeyWithValue(customLabel, "true")))
 
 		// Cleanup
 		Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
 	})
 }
 
-func createOperatorManagedKamelet(ns string, name string) func() error {
+func createBundleKamelet(ns string, name string) func() error {
 	flow := map[string]interface{}{
 		"from": map[string]interface{}{
 			"uri": "kamelet:source",
@@ -59,13 +59,13 @@ func createOperatorManagedKamelet(ns string, name string) func() error {
 	}
 
 	labels := map[string]string{
-		preExistingKameletMarker:     "true",
+		customLabel:                  "true",
 		v1alpha1.KameletBundledLabel: "true",
 	}
 	return CreateKamelet(ns, name, flow, nil, labels)
 }
 
-func createUserManagedKamelet(ns string, name string) func() error {
+func createUserKamelet(ns string, name string) func() error {
 	flow := map[string]interface{}{
 		"from": map[string]interface{}{
 			"uri": "kamelet:source",
@@ -73,7 +73,7 @@ func createUserManagedKamelet(ns string, name string) func() error {
 	}
 
 	labels := map[string]string{
-		preExistingKameletMarker: "true",
+		customLabel: "true",
 	}
 	return CreateKamelet(ns, name, flow, nil, labels)
 }
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 9147233..8d3ab96 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -1367,17 +1367,11 @@ func Kamelet(name string, ns string) func() *v1alpha1.Kamelet {
 	}
 }
 
-func KameletHasLabel(name string, ns string, label string) func() bool {
-	return func() bool {
-		k := Kamelet(name, ns)()
-		if k == nil {
-			return false
-		}
-		if _, ok := k.Labels[label]; ok {
-			return true
-		}
-		return false
+func KameletLabels(kamelet *v1alpha1.Kamelet) map[string]string {
+	if kamelet == nil {
+		return map[string]string{}
 	}
+	return kamelet.GetLabels()
 }
 
 func ClusterDomainName() (string, error) {