From c858c286cb03307263401a2190ea4be18856a9cc Mon Sep 17 00:00:00 2001 From: Violet Hynes Date: Tue, 9 Apr 2024 10:08:15 -0400 Subject: [PATCH] Attempt to address TestAutoAuthSelfHealing_TokenFileAuth_SinkOutput flakiness (#26318) * Attempt to address TestAutoAuthSelfHealing_TokenFileAuth_SinkOutput flakiness * Address test flakiness --- command/agent/agent_auto_auth_self_heal_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/command/agent/agent_auto_auth_self_heal_test.go b/command/agent/agent_auto_auth_self_heal_test.go index dc5f8b30ef..d790af9dfe 100644 --- a/command/agent/agent_auto_auth_self_heal_test.go +++ b/command/agent/agent_auto_auth_self_heal_test.go @@ -172,6 +172,9 @@ func TestAutoAuthSelfHealing_TokenFileAuth_SinkOutput(t *testing.T) { fileInfo, err := waitForFiles(t, pathTokenFile, preTriggerTime) require.NoError(t, err) + templateFileInfo, err := waitForFiles(t, pathLookupSelf, preTriggerTime) + require.NoError(t, err) + tokenInSink, err := os.ReadFile(pathTokenFile) require.NoError(t, err) require.Equal(t, token, string(tokenInSink)) @@ -194,7 +197,7 @@ func TestAutoAuthSelfHealing_TokenFileAuth_SinkOutput(t *testing.T) { require.NoError(t, err) // Wait for auto-auth to complete - updatedFileInfo, err := waitForFiles(t, pathTokenFile, fileInfo.ModTime()) + _, err = waitForFiles(t, pathTokenFile, fileInfo.ModTime()) require.NoError(t, err) // Verify the new token has been written to a file sink after re-authenticating using lookup-self @@ -202,8 +205,8 @@ func TestAutoAuthSelfHealing_TokenFileAuth_SinkOutput(t *testing.T) { require.NoError(t, err) require.Equal(t, newToken, string(tokenInSink)) - // Wait for the lookup-self file to be updated (again) - _, err = waitForFiles(t, pathLookupSelf, updatedFileInfo.ModTime()) + // Wait for the template file to have re-rendered + _, err = waitForFiles(t, pathLookupSelf, templateFileInfo.ModTime()) require.NoError(t, err) // Verify the template has now been correctly rendered with the new token