From 6ffdb13d2a2bc5dc8e935abe931fad6cedbe9f75 Mon Sep 17 00:00:00 2001 From: Brian Joerger Date: Wed, 8 Jan 2025 11:26:11 -0800 Subject: [PATCH] Fix flaky test `TestIntegrations/X11Forwarding` (#50852) * Stagger outer eventually loop to ensure the inner eventually loop has time to complete, avoid racing on the display channel. * Use select case. --- integration/integration_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/integration/integration_test.go b/integration/integration_test.go index 43f2a358e51b8..0b48c90b46f39 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -4853,12 +4853,15 @@ func testX11Forwarding(t *testing.T, suite *integrationTestSuite) { assert.Eventually(t, func() bool { output, err := os.ReadFile(tmpFile.Name()) if err == nil && len(output) != 0 { - display <- strings.TrimSpace(string(output)) + select { + case display <- strings.TrimSpace(string(output)): + default: + } return true } return false }, time.Second, 100*time.Millisecond, "failed to read display") - }, 10*time.Second, time.Second) + }, 10*time.Second, 1*time.Second) // Make a new connection to the XServer proxy to confirm that forwarding is working. serverDisplay, err := x11.ParseDisplay(<-display)