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 2022/08/08 09:48:25 UTC

[camel-k] branch main updated (900ecac59 -> c66a382e1)

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

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


    from 900ecac59 Updated CHANGELOG.md
     new 735f0161f fix(trait): camel to use a single properties file
     new f107f5b91 fix(e2e): integration test refactoring
     new c66a382e1 chore(e2e): replace createTimerKamelet func

The 3 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:
 e2e/global/common/integration_fail_test.go |  19 ++---
 e2e/global/common/kamelet_binding_test.go  | 125 ++++++++++++++++++-----------
 pkg/trait/camel.go                         |  50 ++----------
 3 files changed, 91 insertions(+), 103 deletions(-)


[camel-k] 01/03: fix(trait): camel to use a single properties file

Posted by pc...@apache.org.
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 735f0161f05e2324776527ef7c0562208bfecf07
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Wed Jul 27 11:59:38 2022 +0200

    fix(trait): camel to use a single properties file
    
    Closes #3458
---
 e2e/global/common/kamelet_binding_test.go | 151 ++++++++++++++++++++----------
 pkg/trait/camel.go                        |  50 ++--------
 2 files changed, 111 insertions(+), 90 deletions(-)

diff --git a/e2e/global/common/kamelet_binding_test.go b/e2e/global/common/kamelet_binding_test.go
index 2c88d4e2c..ab290295b 100644
--- a/e2e/global/common/kamelet_binding_test.go
+++ b/e2e/global/common/kamelet_binding_test.go
@@ -33,62 +33,91 @@ import (
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 )
 
-func TestErrorHandler(t *testing.T) {
+func TestKameletBinding(t *testing.T) {
 	WithNewTestNamespace(t, func(ns string) {
-		operatorID := "camel-k-kamelet-errorhandler"
+		operatorID := "camel-k-kameletbinding"
 		Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
 
-		Expect(createErrorProducerKamelet(ns, "my-own-error-producer-source")()).To(Succeed())
-		Expect(createLogKamelet(ns, "my-own-log-sink")()).To(Succeed())
-		from := corev1.ObjectReference{
-			Kind:       "Kamelet",
-			Name:       "my-own-error-producer-source",
-			APIVersion: v1alpha1.SchemeGroupVersion.String(),
-		}
-
-		to := corev1.ObjectReference{
-			Kind:       "Kamelet",
-			Name:       "my-own-log-sink",
-			APIVersion: v1alpha1.SchemeGroupVersion.String(),
-		}
-
-		errorHandler := map[string]interface{}{
-			"sink": map[string]interface{}{
-				"endpoint": map[string]interface{}{
-					"ref": map[string]string{
-						"kind":       "Kamelet",
-						"apiVersion": v1alpha1.SchemeGroupVersion.String(),
-						"name":       "my-own-log-sink",
-					},
-					"properties": map[string]string{
-						"loggerName": "kameletErrorHandler",
-					},
-				}}}
-
-		t.Run("throw error test", func(t *testing.T) {
+		// Error Handler testing
+		t.Run("test error handler", func(t *testing.T) {
 			RegisterTestingT(t)
-
-			Expect(BindKameletToWithErrorHandler(ns, "throw-error-binding", map[string]string{}, from, to, map[string]string{"message": "throw Error"}, map[string]string{"loggerName": "integrationLogger"}, errorHandler)()).To(Succeed())
-
-			Eventually(IntegrationPodPhase(ns, "throw-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-			Eventually(IntegrationLogs(ns, "throw-error-binding"), TestTimeoutShort).Should(ContainSubstring("kameletErrorHandler"))
-			Eventually(IntegrationLogs(ns, "throw-error-binding"), TestTimeoutShort).ShouldNot(ContainSubstring("integrationLogger"))
-
+			Expect(createErrorProducerKamelet(ns, "my-own-error-producer-source")()).To(Succeed())
+			Expect(createLogKamelet(ns, "my-own-log-sink")()).To(Succeed())
+			from := corev1.ObjectReference{
+				Kind:       "Kamelet",
+				Name:       "my-own-error-producer-source",
+				APIVersion: v1alpha1.SchemeGroupVersion.String(),
+			}
+
+			to := corev1.ObjectReference{
+				Kind:       "Kamelet",
+				Name:       "my-own-log-sink",
+				APIVersion: v1alpha1.SchemeGroupVersion.String(),
+			}
+
+			errorHandler := map[string]interface{}{
+				"sink": map[string]interface{}{
+					"endpoint": map[string]interface{}{
+						"ref": map[string]string{
+							"kind":       "Kamelet",
+							"apiVersion": v1alpha1.SchemeGroupVersion.String(),
+							"name":       "my-own-log-sink",
+						},
+						"properties": map[string]string{
+							"loggerName": "kameletErrorHandler",
+						},
+					}}}
+
+			t.Run("throw error test", func(t *testing.T) {
+				RegisterTestingT(t)
+
+				Expect(BindKameletToWithErrorHandler(ns, "throw-error-binding", map[string]string{}, from, to, map[string]string{"message": "throw Error"}, map[string]string{"loggerName": "integrationLogger"}, errorHandler)()).To(Succeed())
+
+				Eventually(IntegrationPodPhase(ns, "throw-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+				Eventually(IntegrationLogs(ns, "throw-error-binding"), TestTimeoutShort).Should(ContainSubstring("kameletErrorHandler"))
+				Eventually(IntegrationLogs(ns, "throw-error-binding"), TestTimeoutShort).ShouldNot(ContainSubstring("integrationLogger"))
+
+			})
+
+			t.Run("don't throw error test", func(t *testing.T) {
+				RegisterTestingT(t)
+
+				Expect(BindKameletToWithErrorHandler(ns, "no-error-binding", map[string]string{}, from, to, map[string]string{"message": "true"}, map[string]string{"loggerName": "integrationLogger"}, errorHandler)()).To(Succeed())
+
+				Eventually(IntegrationPodPhase(ns, "no-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+				Eventually(IntegrationLogs(ns, "no-error-binding"), TestTimeoutShort).ShouldNot(ContainSubstring("kameletErrorHandler"))
+				Eventually(IntegrationLogs(ns, "no-error-binding"), TestTimeoutShort).Should(ContainSubstring("integrationLogger"))
+
+			})
+
+			// Cleanup
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
 		})
 
-		t.Run("don't throw error test", func(t *testing.T) {
+		// Kamelet binding with traits testing
+		t.Run("test kamelet binding with trait", func(t *testing.T) {
 			RegisterTestingT(t)
-
-			Expect(BindKameletToWithErrorHandler(ns, "no-error-binding", map[string]string{}, from, to, map[string]string{"message": "true"}, map[string]string{"loggerName": "integrationLogger"}, errorHandler)()).To(Succeed())
-
-			Eventually(IntegrationPodPhase(ns, "no-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-			Eventually(IntegrationLogs(ns, "no-error-binding"), TestTimeoutShort).ShouldNot(ContainSubstring("kameletErrorHandler"))
-			Eventually(IntegrationLogs(ns, "no-error-binding"), TestTimeoutShort).Should(ContainSubstring("integrationLogger"))
-
+			Expect(createTimerKamelet(ns, "my-own-timer-source")()).To(Succeed())
+			// Log sink kamelet exists from previous test
+
+			from := corev1.ObjectReference{
+				Kind:       "Kamelet",
+				Name:       "my-own-timer-source",
+				APIVersion: v1alpha1.SchemeGroupVersion.String(),
+			}
+
+			to := corev1.ObjectReference{
+				Kind:       "Kamelet",
+				Name:       "my-own-log-sink",
+				APIVersion: v1alpha1.SchemeGroupVersion.String(),
+			}
+
+			Expect(BindKameletTo(ns, "kb-with-traits", map[string]string{"trait.camel.apache.org/camel.properties": "[\"camel.prop1=a\",\"camel.prop2=b\"]"}, from, to, map[string]string{"message": "hello from test"}, map[string]string{"loggerName": "integrationLogger"})()).To(Succeed())
+
+			Eventually(IntegrationPodPhase(ns, "kb-with-traits"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+			Eventually(IntegrationLogs(ns, "kb-with-traits"), TestTimeoutShort).Should(ContainSubstring("hello from test"))
+			Eventually(IntegrationLogs(ns, "kb-with-traits"), TestTimeoutShort).Should(ContainSubstring("integrationLogger"))
 		})
-
-		// Cleanup
-		Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
 	})
 }
 
@@ -143,3 +172,29 @@ func createErrorProducerKamelet(ns string, name string) func() error {
 
 	return CreateKamelet(ns, name, flow, props, nil)
 }
+
+func createTimerKamelet(ns string, name string) func() error {
+	props := map[string]v1alpha1.JSONSchemaProp{
+		"message": {
+			Type: "string",
+		},
+	}
+
+	flow := map[string]interface{}{
+		"from": map[string]interface{}{
+			"uri": "timer:tick",
+			"steps": []map[string]interface{}{
+				{
+					"set-body": map[string]interface{}{
+						"constant": "{{message}}",
+					},
+				},
+				{
+					"to": "kamelet:sink",
+				},
+			},
+		},
+	}
+
+	return CreateKamelet(ns, name, flow, props, nil)
+}
diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go
index 671cee6ba..17f847560 100644
--- a/pkg/trait/camel.go
+++ b/pkg/trait/camel.go
@@ -79,10 +79,6 @@ func (t *camelTrait) Apply(e *Environment) error {
 	if e.IntegrationKitInPhase(v1.IntegrationKitPhaseReady) && e.IntegrationInRunningPhases() {
 		// Get all resources
 		maps := t.computeConfigMaps(e)
-		if t.Properties != nil {
-			// Only user.properties
-			maps = append(maps, t.computeUserProperties(e)...)
-		}
 		e.Resources.AddAll(maps)
 	}
 
@@ -179,6 +175,14 @@ func (t *camelTrait) computeConfigMaps(e *Environment) []ctrl.Object {
 		userProperties += fmt.Sprintf("%s=%s\n", prop.Name, prop.Value)
 	}
 
+	if t.Properties != nil {
+		// Merge with properties set in the trait
+		for _, prop := range t.Properties {
+			k, v := property.SplitPropertyFileEntry(prop)
+			userProperties += fmt.Sprintf("%s=%s\n", k, v)
+		}
+	}
+
 	if userProperties != "" {
 		maps = append(
 			maps,
@@ -283,41 +287,3 @@ func (t *camelTrait) computeConfigMaps(e *Environment) []ctrl.Object {
 
 	return maps
 }
-
-func (t *camelTrait) computeUserProperties(e *Environment) []ctrl.Object {
-	maps := make([]ctrl.Object, 0)
-
-	// combine properties of integration with kit, integration
-	// properties have the priority
-	userProperties := ""
-
-	for _, prop := range t.Properties {
-		k, v := property.SplitPropertyFileEntry(prop)
-		userProperties += fmt.Sprintf("%s=%s\n", k, v)
-	}
-
-	if userProperties != "" {
-		maps = append(
-			maps,
-			&corev1.ConfigMap{
-				TypeMeta: metav1.TypeMeta{
-					Kind:       "ConfigMap",
-					APIVersion: "v1",
-				},
-				ObjectMeta: metav1.ObjectMeta{
-					Name:      e.Integration.Name + "-user-properties",
-					Namespace: e.Integration.Namespace,
-					Labels: map[string]string{
-						v1.IntegrationLabel:                e.Integration.Name,
-						"camel.apache.org/properties.type": "user",
-					},
-				},
-				Data: map[string]string{
-					"application.properties": userProperties,
-				},
-			},
-		)
-	}
-
-	return maps
-}


[camel-k] 02/03: fix(e2e): integration test refactoring

Posted by pc...@apache.org.
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 f107f5b913da4dc03aab46fe2eb8eaf287c0e67f
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Wed Jul 27 12:00:57 2022 +0200

    fix(e2e): integration test refactoring
    
    Ref #3487
---
 e2e/global/common/integration_fail_test.go | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/e2e/global/common/integration_fail_test.go b/e2e/global/common/integration_fail_test.go
index ec41bdd6a..c95b691b1 100644
--- a/e2e/global/common/integration_fail_test.go
+++ b/e2e/global/common/integration_fail_test.go
@@ -55,17 +55,10 @@ func TestBadRouteIntegration(t *testing.T) {
 				Should(gstruct.PointTo(BeNumerically("==", 2)))
 			// Check the Integration stays in error phase
 			Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
-		})
 
-		// Clean up
-		Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
-	})
-}
-
-func TestMissingDependencyIntegration(t *testing.T) {
-	WithNewTestNamespace(t, func(ns string) {
-		operatorID := "camel-k-missing-dependencies"
-		Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+			// Clean up
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
 
 		t.Run("run missing dependency java route", func(t *testing.T) {
 			RegisterTestingT(t)
@@ -80,9 +73,9 @@ func TestMissingDependencyIntegration(t *testing.T) {
 			build := Build(ns, kitName)()
 			Eventually(build.Status.Phase, TestTimeoutShort).Should(Equal(v1.BuildPhaseError))
 			Eventually(build.Status.Failure.Recovery.Attempt, TestTimeoutShort).Should(Equal(5))
-		})
 
-		// Clean up
-		Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+			// Clean up
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
 	})
 }


[camel-k] 03/03: chore(e2e): replace createTimerKamelet func

Posted by pc...@apache.org.
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 c66a382e1f4d33107e8ea3647a59ee5627019664
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Mon Aug 8 09:12:15 2022 +0200

    chore(e2e): replace createTimerKamelet func
---
 e2e/global/common/kamelet_binding_test.go | 28 +---------------------------
 1 file changed, 1 insertion(+), 27 deletions(-)

diff --git a/e2e/global/common/kamelet_binding_test.go b/e2e/global/common/kamelet_binding_test.go
index ab290295b..a98854254 100644
--- a/e2e/global/common/kamelet_binding_test.go
+++ b/e2e/global/common/kamelet_binding_test.go
@@ -97,7 +97,7 @@ func TestKameletBinding(t *testing.T) {
 		// Kamelet binding with traits testing
 		t.Run("test kamelet binding with trait", func(t *testing.T) {
 			RegisterTestingT(t)
-			Expect(createTimerKamelet(ns, "my-own-timer-source")()).To(Succeed())
+			Expect(CreateTimerKamelet(ns, "my-own-timer-source")()).To(Succeed())
 			// Log sink kamelet exists from previous test
 
 			from := corev1.ObjectReference{
@@ -172,29 +172,3 @@ func createErrorProducerKamelet(ns string, name string) func() error {
 
 	return CreateKamelet(ns, name, flow, props, nil)
 }
-
-func createTimerKamelet(ns string, name string) func() error {
-	props := map[string]v1alpha1.JSONSchemaProp{
-		"message": {
-			Type: "string",
-		},
-	}
-
-	flow := map[string]interface{}{
-		"from": map[string]interface{}{
-			"uri": "timer:tick",
-			"steps": []map[string]interface{}{
-				{
-					"set-body": map[string]interface{}{
-						"constant": "{{message}}",
-					},
-				},
-				{
-					"to": "kamelet:sink",
-				},
-			},
-		},
-	}
-
-	return CreateKamelet(ns, name, flow, props, nil)
-}