Skip to content

Commit

Permalink
[v14] fix flaky lib/auth cache-enabled tests (#36250)
Browse files Browse the repository at this point in the history
* fix flaky lib/auth cache-enabled tests

* use auth server close context for cache in tests
  • Loading branch information
GavinFrazar committed Jan 3, 2024
1 parent ac5dc3c commit d22eca1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/auth/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,12 @@ func NewTestAuthServer(cfg TestAuthServerConfig) (*TestAuthServer, error) {

if cfg.CacheEnabled {
srv.AuthServer.Cache, err = accesspoint.NewAccessCache(accesspoint.AccessCacheConfig{
Context: ctx,
Context: srv.AuthServer.CloseContext(),
Services: srv.AuthServer.Services,
Setup: cache.ForAuth,
CacheName: []string{teleport.ComponentAuth},
Events: true,
Unstarted: true,
})
if err != nil {
return nil, trace.Wrap(err)
Expand Down Expand Up @@ -432,6 +433,13 @@ func NewTestAuthServer(cfg TestAuthServerConfig) (*TestAuthServer, error) {
return nil, trace.Wrap(err)
}

// Auth initialization is done (including creation/updating of all singleton
// configuration resources) so now we can start the cache.
if c, ok := srv.AuthServer.Cache.(*cache.Cache); ok {
if err := c.Start(); err != nil {
return nil, trace.NewAggregate(err, c.Close())
}
}
return srv, nil
}

Expand Down

0 comments on commit d22eca1

Please sign in to comment.