You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/10/25 08:15:20 UTC

[camel-k] 01/07: fix(e2e): stabilise TestNativeBinding

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

tsato pushed a commit to branch release-1.10.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 8bb102c988f7303951e8ba4d7cd780903a5b9f88
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Tue Oct 18 14:44:58 2022 +0900

    fix(e2e): stabilise TestNativeBinding
---
 e2e/global/common/kamelet_binding_test.go   | 16 ++++++--
 e2e/namespace/native/native_binding_test.go | 57 ++++++++++++++++++++---------
 e2e/namespace/native/native_test.go         |  5 ++-
 e2e/support/test_support.go                 |  8 ++--
 4 files changed, 60 insertions(+), 26 deletions(-)

diff --git a/e2e/global/common/kamelet_binding_test.go b/e2e/global/common/kamelet_binding_test.go
index a98854254..97aca4411 100644
--- a/e2e/global/common/kamelet_binding_test.go
+++ b/e2e/global/common/kamelet_binding_test.go
@@ -71,7 +71,10 @@ func TestKameletBinding(t *testing.T) {
 			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())
+				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"))
@@ -82,7 +85,10 @@ func TestKameletBinding(t *testing.T) {
 			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())
+				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"))
@@ -112,7 +118,11 @@ func TestKameletBinding(t *testing.T) {
 				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())
+			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"))
diff --git a/e2e/namespace/native/native_binding_test.go b/e2e/namespace/native/native_binding_test.go
index f2af7d681..18063d100 100644
--- a/e2e/namespace/native/native_binding_test.go
+++ b/e2e/namespace/native/native_binding_test.go
@@ -23,9 +23,10 @@ limitations under the License.
 package native
 
 import (
-	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"testing"
 
+	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+
 	. "github.com/onsi/gomega"
 
 	corev1 "k8s.io/api/core/v1"
@@ -38,27 +39,46 @@ func TestNativeBinding(t *testing.T) {
 	WithNewTestNamespace(t, func(ns string) {
 		operatorID := "camel-k-native-binding"
 		Expect(KamelInstallWithID(operatorID, ns,
-			"--build-timeout", "15m0s",
-			"--operator-resources", "limits.memory=4Gi",
+			"--build-timeout", "40m0s",
+			"--operator-resources", "limits.memory=4.5Gi",
+			"--maven-cli-option", "-Dquarkus.native.native-image-xmx=3g",
 		).Execute()).To(Succeed())
 		Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
 
-		t.Run("kamelet binding with native build", func(t *testing.T) {
-			from := corev1.ObjectReference{
-				Kind:       "Kamelet",
-				Name:       "timer-source",
-				APIVersion: v1alpha1.SchemeGroupVersion.String(),
-			}
-
-			to := corev1.ObjectReference{
-				Kind:       "Kamelet",
-				Name:       "log-sink",
-				APIVersion: v1alpha1.SchemeGroupVersion.String(),
-			}
+		from := corev1.ObjectReference{
+			Kind:       "Kamelet",
+			Name:       "timer-source",
+			APIVersion: v1alpha1.SchemeGroupVersion.String(),
+		}
+		to := corev1.ObjectReference{
+			Kind:       "Kamelet",
+			Name:       "log-sink",
+			APIVersion: v1alpha1.SchemeGroupVersion.String(),
+		}
+		message := "Magicstring!"
+
+		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.
+			bindingName := "warm-up-binding"
+			Expect(BindKameletTo(ns, bindingName, map[string]string{},
+				from, to,
+				map[string]string{"message": message}, map[string]string{})()).To(Succeed())
+
+			Eventually(IntegrationPodPhase(ns, bindingName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+			Eventually(IntegrationLogs(ns, bindingName), TestTimeoutShort).Should(ContainSubstring(message))
+
+			// Clean up
+			Expect(Kamel("delete", bindingName, "-n", ns).Execute()).To(Succeed())
+			Expect(DeleteKits(ns)).To(Succeed())
+		})
 
+		t.Run("kamelet binding with native build", func(t *testing.T) {
 			bindingName := "native-binding"
-			message := "Magicstring!"
-			Expect(BindKameletTo(ns, bindingName, map[string]string{"trait.camel.apache.org/quarkus.package-type": "native"}, from, to, map[string]string{"message": message}, map[string]string{})()).To(Succeed())
+			Expect(BindKameletTo(ns, bindingName,
+				map[string]string{"trait.camel.apache.org/quarkus.package-type": "native"},
+				from, to,
+				map[string]string{"message": message}, map[string]string{})()).To(Succeed())
 
 			Eventually(Kits(ns, withNativeLayout, KitWithPhase(v1.IntegrationKitPhaseReady)),
 				TestTimeoutVeryLong).Should(HaveLen(1))
@@ -69,7 +89,8 @@ func TestNativeBinding(t *testing.T) {
 			Eventually(IntegrationLogs(ns, bindingName), TestTimeoutShort).Should(ContainSubstring(message))
 
 			Eventually(IntegrationPod(ns, bindingName), TestTimeoutShort).
-				Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
+				Should(WithTransform(getContainerCommand(),
+					MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))
 
 			// Clean up
 			Expect(Kamel("delete", bindingName, "-n", ns).Execute()).To(Succeed())
diff --git a/e2e/namespace/native/native_test.go b/e2e/namespace/native/native_test.go
index 74e2b8375..f8d5fec91 100644
--- a/e2e/namespace/native/native_test.go
+++ b/e2e/namespace/native/native_test.go
@@ -43,8 +43,9 @@ func TestNativeIntegrations(t *testing.T) {
 	WithNewTestNamespace(t, func(ns string) {
 		operatorID := "camel-k-quarkus-native"
 		Expect(KamelInstallWithID(operatorID, ns,
-			"--build-timeout", "15m0s",
-			"--operator-resources", "limits.memory=4Gi",
+			"--build-timeout", "40m0s",
+			"--operator-resources", "limits.memory=4.5Gi",
+			"--maven-cli-option", "-Dquarkus.native.native-image-xmx=3g",
 		).Execute()).To(Succeed())
 		Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
 
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 7860c8bc6..59d064fa1 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -94,7 +94,7 @@ var TestTimeoutMedium = 5 * time.Minute
 var TestTimeoutLong = 10 * time.Minute
 
 // TestTimeoutVeryLong should be used only for testing native builds.
-var TestTimeoutVeryLong = 30 * time.Minute
+var TestTimeoutVeryLong = 40 * time.Minute
 
 var NoOlmOperatorImage string
 
@@ -1843,11 +1843,13 @@ func CreateTimerKamelet(ns string, name string) func() error {
 	return CreateKamelet(ns, name, flow, props, nil)
 }
 
-func BindKameletTo(ns string, name string, annotations map[string]string, from corev1.ObjectReference, to corev1.ObjectReference, sourceProperties map[string]string, sinkProperties map[string]string) func() error {
+func BindKameletTo(ns, name string, annotations map[string]string, from, to corev1.ObjectReference,
+	sourceProperties, sinkProperties map[string]string) func() error {
 	return BindKameletToWithErrorHandler(ns, name, annotations, from, to, sourceProperties, sinkProperties, nil)
 }
 
-func BindKameletToWithErrorHandler(ns string, name string, annotations map[string]string, from corev1.ObjectReference, to corev1.ObjectReference, sourceProperties map[string]string, sinkProperties map[string]string, errorHandler map[string]interface{}) func() error {
+func BindKameletToWithErrorHandler(ns, name string, annotations map[string]string, from, to corev1.ObjectReference,
+	sourceProperties, sinkProperties map[string]string, errorHandler map[string]interface{}) func() error {
 	return func() error {
 		kb := v1alpha1.NewKameletBinding(ns, name)
 		kb.Annotations = annotations