From a206ff3858e00d575103e4afffdb04d4b5c99f5a Mon Sep 17 00:00:00 2001 From: James Rasell Date: Thu, 18 Sep 2025 13:56:17 +0100 Subject: [PATCH] test: Fix test flake in client get registration token (#26796) The test was incorrectly writing to state that registration had been finished before writing the node identity token. This is the opposite of what happens in the client code and caused a timing issue which meant we read registration as completed before we had the identity available and therefore returned the secret ID. --- client/client_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index f3cba229d..c56270fd1 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -1515,14 +1515,16 @@ func TestClient_getRegistrationToken(t *testing.T) { }) t.Cleanup(func() { _ = testClientCleanup() }) + // Ensure the identity is written to state before marking as registered, + // as would happen in a real client. + must.NoError(t, testClient.stateDB.PutNodeIdentity("my-identity-token")) + must.NoError(t, testClient.stateDB.PutNodeRegistration( &cstructs.NodeRegistration{ HasRegistered: true, }, )) - must.NoError(t, testClient.stateDB.PutNodeIdentity("my-identity-token")) - must.Eq(t, "my-identity-token", testClient.getRegistrationToken()) }) }