From 5bc29ab74d743659fd182a849ff550edc9c82d40 Mon Sep 17 00:00:00 2001 From: Brian Joerger Date: Wed, 8 Jan 2025 15:41:19 -0800 Subject: [PATCH] [v16] Fix flaky test `TestIntegrations/X11Forwarding` (#50886) * 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 8d7b86995073f..4b3eae8c89001 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -4775,12 +4775,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)