From 7e932aa7f80420450abc7ef1fd9f5233962425df Mon Sep 17 00:00:00 2001 From: Marco Hofstetter Date: Tue, 25 Mar 2025 17:38:24 +0100 Subject: [PATCH] conformance-tests: fix flake in ExpectMirroredRequest Currently the Conformance Tests for request mirroring is flaky because the mirrored request can sometimes not be found in the log of the Pod. ``` Test: TestConformance/HTTPRouteRequestMultipleMirrors/1_request_to_'/multi-mirror-and-modify-request-headers'_with_headers_should_go_to_infra-backend-v1 Messages: Couldn't find mirrored request in "gateway-conformance-infra/infra-backend-v3" logs ``` The issue is that the logic that fetches the Pod log (`ExpectMirroredRequest`) uses the current time (`time.Now()`) on every assertion-attempt as the `sinceTime` parameter. As a consequence, the assertion can miss messages from the Pods that have been logged between the assertion attempts. This commit fixes the issue by using the start time of the "check" when fetching the logs (the same way it's already handled in `testMirroredRequestsDistribution`). --- conformance/utils/http/mirror.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conformance/utils/http/mirror.go b/conformance/utils/http/mirror.go index 99d0621d26..0ac85ec5ae 100644 --- a/conformance/utils/http/mirror.go +++ b/conformance/utils/http/mirror.go @@ -41,6 +41,8 @@ func ExpectMirroredRequest(t *testing.T, client client.Client, clientset clients var wg sync.WaitGroup wg.Add(len(mirrorPods)) + assertionStart := time.Now() + for _, mirrorPod := range mirrorPods { go func(mirrorPod MirroredBackend) { defer wg.Done() @@ -50,7 +52,7 @@ func ExpectMirroredRequest(t *testing.T, client client.Client, clientset clients tlog.Log(t, "Searching for the mirrored request log") tlog.Logf(t, `Reading "%s/%s" logs`, mirrorPod.Namespace, mirrorPod.Name) - logs, err := kubernetes.DumpEchoLogs(mirrorPod.Namespace, mirrorPod.Name, client, clientset, time.Now()) + logs, err := kubernetes.DumpEchoLogs(mirrorPod.Namespace, mirrorPod.Name, client, clientset, assertionStart) if err != nil { tlog.Logf(t, `Couldn't read "%s/%s" logs: %v`, mirrorPod.Namespace, mirrorPod.Name, err) return false