mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
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.
This commit is contained in:
@@ -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())
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user