mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
De-flake TestJetStreamClusterAccountPurge by waiting for account to exist
Signed-off-by: Neil Twigg <neil@nats.io>
This commit is contained in:
@@ -3738,6 +3738,8 @@ func TestJetStreamClusterAccountPurge(t *testing.T) {
|
||||
updateJwt(t, c.randomServer().ClientURL(), sysCreds, sysJwt, 3)
|
||||
updateJwt(t, c.randomServer().ClientURL(), sysCreds, accJwt, 3)
|
||||
|
||||
c.waitOnAccount(accpub)
|
||||
|
||||
createTestData := func(t *testing.T) {
|
||||
nc, js := jsClientConnect(t, c.randomNonLeader(), nats.UserCredentials(accCreds))
|
||||
defer nc.Close()
|
||||
|
||||
@@ -1435,6 +1435,25 @@ func (c *cluster) waitOnLeader() {
|
||||
c.t.Fatalf("Expected a cluster leader, got none")
|
||||
}
|
||||
|
||||
func (c *cluster) waitOnAccount(account string) {
|
||||
c.t.Helper()
|
||||
expires := time.Now().Add(40 * time.Second)
|
||||
for time.Now().Before(expires) {
|
||||
found := true
|
||||
for _, s := range c.servers {
|
||||
acc, err := s.fetchAccount(account)
|
||||
found = found && err == nil && acc != nil
|
||||
}
|
||||
if found {
|
||||
return
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
|
||||
c.t.Fatalf("Expected account %q to exist but didn't", account)
|
||||
}
|
||||
|
||||
// Helper function to check that a cluster is formed
|
||||
func (c *cluster) waitOnClusterReady() {
|
||||
c.t.Helper()
|
||||
|
||||
Reference in New Issue
Block a user