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

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


The following commit(s) were added to refs/heads/main by this push:
     new 54524c02d fix(e2e): stabilise TestNativeBinding
54524c02d is described below

commit 54524c02d36f0f48c93ca202ca8f0a7e45b362f1
Author: Tadayoshi Sato <[email protected]>
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 | 54 ++++++++++++++++++++---------
 e2e/namespace/native/native_test.go         |  2 +-
 e2e/support/test_support.go                 |  8 +++--
 4 files changed, 56 insertions(+), 24 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 47a2bf6d5..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,28 +39,46 @@ func TestNativeBinding(t *testing.T) {
        WithNewTestNamespace(t, func(ns string) {
                operatorID := "camel-k-native-binding"
                Expect(KamelInstallWithID(operatorID, ns,
-                       "--build-timeout", "30m0s",
+                       "--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))
@@ -70,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 d13a03136..1cf0096d4 100644
--- a/e2e/namespace/native/native_test.go
+++ b/e2e/namespace/native/native_test.go
@@ -43,7 +43,7 @@ func TestNativeIntegrations(t *testing.T) {
        WithNewTestNamespace(t, func(ns string) {
                operatorID := "camel-k-quarkus-native"
                Expect(KamelInstallWithID(operatorID, ns,
-                       "--build-timeout", "30m0s",
+                       "--build-timeout", "40m0s",
                        "--operator-resources", "limits.memory=4.5Gi",
                        "--maven-cli-option", 
"-Dquarkus.native.native-image-xmx=3g",
                ).Execute()).To(Succeed())
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 4edd2968d..d6e8f85b2 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -95,7 +95,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
 
@@ -1978,11 +1978,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

Reply via email to