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 2026/08/11 08:38:56 UTC

(camel-k) branch main updated: chore(e2e): attempt to fix test flakiness

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

squakez 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 c7bc01764 chore(e2e): attempt to fix test flakiness
c7bc01764 is described below

commit c7bc01764f26b1e3a2ddc0f754912d9c01d60936
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Tue Aug 11 08:50:46 2026 +0200

    chore(e2e): attempt to fix test flakiness
    
    Closes #6650
    Closes #6689
    Closes #6699
---
 e2e/advanced/operator_id_filtering_test.go | 122 -----------------------------
 e2e/common/misc/scale_integration_test.go  |  10 ++-
 e2e/common/misc/structured_logs_test.go    |   8 +-
 e2e/common/traits/init_container_test.go   |   4 +-
 e2e/knative/kamelet_test.go                |  25 +++---
 5 files changed, 26 insertions(+), 143 deletions(-)

diff --git a/e2e/advanced/operator_id_filtering_test.go b/e2e/advanced/operator_id_filtering_test.go
deleted file mode 100644
index 184603d91..000000000
--- a/e2e/advanced/operator_id_filtering_test.go
+++ /dev/null
@@ -1,122 +0,0 @@
-//go:build integration
-// +build integration
-
-// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
-
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package advanced
-
-import (
-	"context"
-	"testing"
-	"time"
-
-	. "github.com/onsi/gomega"
-	corev1 "k8s.io/api/core/v1"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
-	. "github.com/apache/camel-k/v2/e2e/support"
-	v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-)
-
-func TestOperatorIDFiltering(t *testing.T) {
-	t.Parallel()
-
-	WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
-		WithNewTestNamespace(t, func(ctx context.Context, g *WithT, nsop1 string) {
-			operator1 := "operator-1"
-			InstallOperatorWithConf(t, ctx, g, nsop1, operator1, true, nil)
-
-			WithNewTestNamespace(t, func(ctx context.Context, g *WithT, nsop2 string) {
-				operator2 := "operator-2"
-				InstallOperatorWithConf(t, ctx, g, nsop2, operator2, true, nil)
-
-				t.Run("Operators ignore non-scoped integrations", func(t *testing.T) {
-					g.Expect(KamelRunWithID(t, ctx, "operator-x", ns, "files/yaml.yaml", "--name", "untouched").Execute()).To(Succeed())
-					g.Consistently(IntegrationPhase(t, ctx, ns, "untouched"), 10*time.Second).Should(BeEmpty())
-				})
-
-				t.Run("Operators run scoped integrations", func(t *testing.T) {
-					g.Expect(KamelRunWithID(t, ctx, "operator-x", ns, "files/yaml.yaml", "--name", "moving").Execute()).To(Succeed())
-					g.Expect(AssignIntegrationToOperator(t, ctx, ns, "moving", operator1)).To(Succeed())
-					g.Eventually(IntegrationPhase(t, ctx, ns, "moving"), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning))
-					g.Eventually(IntegrationPodPhase(t, ctx, ns, "moving"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-					g.Eventually(IntegrationLogs(t, ctx, ns, "moving"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-				})
-
-				t.Run("Operators can handoff scoped integrations", func(t *testing.T) {
-					g.Expect(AssignIntegrationToOperator(t, ctx, ns, "moving", operator2)).To(Succeed())
-					g.Eventually(IntegrationPhase(t, ctx, ns, "moving"), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseBuildingKit))
-					g.Eventually(IntegrationPhase(t, ctx, ns, "moving"), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning))
-					g.Eventually(IntegrationPodPhase(t, ctx, ns, "moving"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-					g.Eventually(IntegrationLogs(t, ctx, ns, "moving"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-				})
-
-				t.Run("Operators can be deactivated after completely handing off scoped integrations", func(t *testing.T) {
-					g.Expect(ScaleOperator(t, ctx, nsop1, 0)).To(Succeed())
-					g.Expect(Kamel(t, ctx, "rebuild", "-n", ns, "moving").Execute()).To(Succeed())
-					g.Eventually(IntegrationPhase(t, ctx, ns, "moving"), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning))
-					g.Eventually(IntegrationPodPhase(t, ctx, ns, "moving"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-					g.Eventually(IntegrationLogs(t, ctx, ns, "moving"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-					g.Expect(ScaleOperator(t, ctx, nsop1, 1)).To(Succeed())
-				})
-
-				t.Run("Operators can run scoped integrations with fixed image", func(t *testing.T) {
-					kitName := IntegrationKitName(t, ctx, ns, "moving")()
-					g.Expect(kitName).NotTo(BeEmpty())
-					kitImage := KitImage(t, ctx, nsop2, kitName)()
-					g.Expect(kitImage).NotTo(BeEmpty())
-					// external kit creation
-					externalKit := v1.IntegrationKit{
-						ObjectMeta: metav1.ObjectMeta{
-							Namespace: ns,
-							Name:      "external",
-							Labels: map[string]string{
-								v1.IntegrationKitTypeLabel: v1.IntegrationKitTypeExternal,
-							},
-							Annotations: map[string]string{
-								v1.OperatorIDAnnotation: operator2,
-							},
-						},
-						Spec: v1.IntegrationKitSpec{
-							Image: kitImage,
-						},
-					}
-					g.Expect(TestClient(t).Create(ctx, &externalKit)).Should(BeNil())
-					g.Expect(KamelRunWithID(t, ctx, operator2, ns, "files/yaml.yaml", "--name", "pre-built", "--kit", "external").Execute()).To(Succeed())
-					g.Consistently(IntegrationPhase(t, ctx, ns, "pre-built"), 10*time.Second).ShouldNot(Equal(v1.IntegrationPhaseBuildingKit))
-					g.Eventually(IntegrationPhase(t, ctx, ns, "pre-built"), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
-					g.Eventually(IntegrationStatusImage(t, ctx, ns, "pre-built"), TestTimeoutShort).Should(Equal(kitImage))
-					g.Eventually(IntegrationPodPhase(t, ctx, ns, "pre-built"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-					g.Eventually(IntegrationLogs(t, ctx, ns, "pre-built"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-					g.Expect(Kamel(t, ctx, "delete", "pre-built", "-n", ns).Execute()).To(Succeed())
-				})
-
-				t.Run("Operators can run scoped Pipes", func(t *testing.T) {
-					g.Expect(KamelBindWithID(t, ctx, "operator-x", ns, "timer-source?message=Hello", "log-sink", "--name", "klb").Execute()).To(Succeed())
-					g.Consistently(Integration(t, ctx, ns, "klb"), 10*time.Second).Should(BeNil())
-					g.Expect(AssignPipeToOperator(t, ctx, ns, "klb", operator1)).To(Succeed())
-					g.Eventually(Integration(t, ctx, ns, "klb"), TestTimeoutShort).ShouldNot(BeNil())
-					g.Eventually(IntegrationPhase(t, ctx, ns, "klb"), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning))
-					g.Eventually(IntegrationPodPhase(t, ctx, ns, "klb"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-				})
-			})
-		})
-	})
-}
diff --git a/e2e/common/misc/scale_integration_test.go b/e2e/common/misc/scale_integration_test.go
index 4572e0ff1..ec36d4270 100644
--- a/e2e/common/misc/scale_integration_test.go
+++ b/e2e/common/misc/scale_integration_test.go
@@ -116,14 +116,16 @@ func TestIntegrationScale(t *testing.T) {
 			// Save resources by deleting the integration
 			g.Expect(Kamel(t, ctx, "delete", name, "-n", ns).Execute()).To(Succeed())
 
-			g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", "pre-built", "-t", fmt.Sprintf("container.image=%s", image)).Execute()).To(Succeed())
+			g.Expect(KamelRun(t, ctx, ns, "files/Java.java",
+				"--name", "pre-built",
+				"-t", fmt.Sprintf("container.image=%s", image),
+			).Execute()).To(Succeed())
 			g.Eventually(IntegrationPhase(t, ctx, ns, "pre-built"), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
-			g.Eventually(IntegrationPodPhase(t, ctx, ns, "pre-built"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
 			g.Expect(ScaleIntegration(t, ctx, ns, "pre-built", 0)).To(Succeed())
-			g.Eventually(IntegrationPod(t, ctx, ns, "pre-built"), TestTimeoutMedium).Should(BeNil())
+			g.Eventually(IntegrationPod(t, ctx, ns, "pre-built")).Should(BeNil())
 			g.Expect(ScaleIntegration(t, ctx, ns, "pre-built", 1)).To(Succeed())
 			g.Eventually(IntegrationPhase(t, ctx, ns, "pre-built"), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
-			g.Eventually(IntegrationPodPhase(t, ctx, ns, "pre-built"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+			g.Eventually(IntegrationPodPhase(t, ctx, ns, "pre-built")).Should(Equal(corev1.PodRunning))
 		})
 	})
 }
diff --git a/e2e/common/misc/structured_logs_test.go b/e2e/common/misc/structured_logs_test.go
index 2af59f0b9..ba08e3bd0 100644
--- a/e2e/common/misc/structured_logs_test.go
+++ b/e2e/common/misc/structured_logs_test.go
@@ -24,7 +24,6 @@ package common
 
 import (
 	"context"
-	"fmt"
 	"testing"
 
 	. "github.com/onsi/gomega"
@@ -40,20 +39,17 @@ func TestStructuredLogs(t *testing.T) {
 	WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
 		name := RandomizedSuffixName("java")
 		g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
-		g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-		g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+		g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).
 			Should(Equal(corev1.ConditionTrue))
 
 		pod := OperatorPodGlobal(t, ctx)()
 		g.Expect(pod).NotTo(BeNil())
 
-		// pod.Namespace could be different from ns if using global operator
-		fmt.Printf("Fetching logs for operator pod %s in namespace %s", pod.Name, pod.Namespace)
 		logOptions := &corev1.PodLogOptions{
 			Container: "camel-k-operator",
 		}
 		logs, err := StructuredLogs(t, ctx, pod.Namespace, pod.Name, logOptions, false)
-		g.Expect(err).To(BeNil())
+		g.Expect(err).NotTo(HaveOccurred())
 		g.Expect(logs).NotTo(BeEmpty())
 	})
 }
diff --git a/e2e/common/traits/init_container_test.go b/e2e/common/traits/init_container_test.go
index 388ebc057..20a1d648c 100644
--- a/e2e/common/traits/init_container_test.go
+++ b/e2e/common/traits/init_container_test.go
@@ -47,7 +47,7 @@ func TestInitContainerTrait(t *testing.T) {
 				"init-containers.init-tasks=init;alpine;/bin/sh -c \"echo helloInit >> /tmp/init\"",
 				"--name",
 				name).Execute()).To(Succeed())
-			g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady)).
+			g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).
 				Should(Equal(corev1.ConditionTrue))
 			g.Eventually(IntegrationPodPhase(t, ctx, ns, name)).Should(Equal(corev1.PodRunning))
 			g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("helloInit"))
@@ -62,7 +62,7 @@ func TestInitContainerTrait(t *testing.T) {
 				"init-containers.sidecar-tasks=sidecar;alpine;/bin/sh -c \"for i in $(seq 1 10); do echo helloSidecar$i > /tmp/sidecar_$i.txt; sleep 1; done\"",
 				"--name",
 				name).Execute()).To(Succeed())
-			g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady)).
+			g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).
 				Should(Equal(corev1.ConditionTrue))
 			g.Eventually(IntegrationPodPhase(t, ctx, ns, name)).Should(Equal(corev1.PodRunning))
 			g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("helloSidecar10"))
diff --git a/e2e/knative/kamelet_test.go b/e2e/knative/kamelet_test.go
index b9dea9832..bd5a71c0f 100644
--- a/e2e/knative/kamelet_test.go
+++ b/e2e/knative/kamelet_test.go
@@ -47,15 +47,20 @@ func TestKameletChange(t *testing.T) {
 		timerSource := "my-timer-source"
 		g.Expect(CreateTimerKamelet(t, ctx, ns, timerSource)()).To(Succeed())
 		g.Expect(CreateKnativeChannel(t, ctx, ns, knChannel)()).To(Succeed())
+
 		// Consumer route that will read from the Knative channel
 		g.Expect(KamelRun(t, ctx, ns, "files/test-kamelet-display.yaml", "-w").Execute()).To(Succeed())
-		g.Eventually(IntegrationPodPhase(t, ctx, ns, "test-kamelet-display")).Should(Equal(corev1.PodRunning))
+		g.Eventually(IntegrationConditionStatus(t, ctx, ns, "test-kamelet-display", v1.IntegrationConditionReady), TestTimeoutMedium).
+			Should(Equal(corev1.ConditionTrue))
 
 		// Create the Pipe
-		g.Expect(KamelBind(t, ctx, ns, timerSource, knChannelConf, "-p", "source.message=HelloKnative!",
-			"--trait", "health.enabled=true", "--trait", "health.readiness-initial-delay=10", "--name", timerPipe).Execute()).To(Succeed())
-		g.Eventually(IntegrationPodPhase(t, ctx, ns, timerPipe)).Should(Equal(corev1.PodRunning))
-		g.Eventually(IntegrationConditionStatus(t, ctx, ns, timerPipe, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+		g.Expect(KamelBind(t, ctx, ns, timerSource, knChannelConf,
+			"-p", "source.message=HelloKnative!",
+			"--name", timerPipe,
+		).Execute()).To(Succeed())
+		g.Eventually(IntegrationConditionStatus(t, ctx, ns, timerPipe, v1.IntegrationConditionReady), TestTimeoutMedium).
+			Should(Equal(corev1.ConditionTrue))
+
 		// Consume the message
 		g.Eventually(IntegrationLogs(t, ctx, ns, "test-kamelet-display"), TestTimeoutShort).Should(ContainSubstring("HelloKnative!"))
 
@@ -66,11 +71,13 @@ func TestKameletChange(t *testing.T) {
 		))
 
 		// Update the Pipe
-		g.Expect(KamelBind(t, ctx, ns, timerSource, knChannelConf, "-p", "source.message=message is Hi",
-			"--trait", "health.enabled=true", "--trait", "health.readiness-initial-delay=10", "--name", timerPipe).Execute()).To(Succeed())
+		g.Expect(KamelBind(t, ctx, ns, timerSource, knChannelConf,
+			"-p", "source.message=message is Hi",
+			"--name", timerPipe,
+		).Execute()).To(Succeed())
 
-		g.Eventually(IntegrationPodPhase(t, ctx, ns, timerPipe), TestTimeoutLong).Should(Equal(corev1.PodRunning))
-		g.Eventually(IntegrationConditionStatus(t, ctx, ns, timerPipe, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+		g.Eventually(IntegrationConditionStatus(t, ctx, ns, timerPipe, v1.IntegrationConditionReady), TestTimeoutMedium).
+			Should(Equal(corev1.ConditionTrue))
 		g.Eventually(IntegrationLogs(t, ctx, ns, "test-kamelet-display"), TestTimeoutShort).Should(ContainSubstring("message is Hi"))
 
 		g.Eventually(PipeCondition(t, ctx, ns, timerPipe, v1.PipeConditionReady), TestTimeoutMedium).