Fixing test race condition

Signed-off-by: Matthias Hanel <mh@synadia.com>
This commit is contained in:
Matthias Hanel
2020-09-29 14:34:37 -04:00
parent f3e6cd12ec
commit 4e055d7b72
2 changed files with 14 additions and 2 deletions

View File

@@ -3053,9 +3053,8 @@ func (dr *DirAccResolver) Fetch(name string) (string, error) {
dr.Unlock()
if srv == nil {
return "", err
} else {
return srv.fetch(dr, name) // lookup from other server
}
return srv.fetch(dr, name) // lookup from other server
}
}

View File

@@ -3531,6 +3531,19 @@ func TestAccountNATSResolverFetch(t *testing.T) {
// It is not expected to be hit. When hit the administrator is supposed to take action.
passCnt = updateJwt(t, sA.ClientURL(), sysCreds, dpub, djwt1, 3)
require_True(t, passCnt == 1) // Only Server C updated
for _, srv := range []*Server{sA, sB, sC} {
if a, ok := srv.accounts.Load(syspub); ok {
acc := a.(*Account)
checkFor(t, time.Second, 20*time.Millisecond, func() error {
acc.mu.Lock()
defer acc.mu.Unlock()
if acc.ctmr != nil {
return fmt.Errorf("Timer still exists")
}
return nil
})
}
}
}
func TestAccountNATSResolverCrossClusterFetch(t *testing.T) {