Skip to content

Commit

Permalink
Fixes racey tests in tsh (gravitational#7416)
Browse files Browse the repository at this point in the history
Multiple routines were fighting over the global logrus `Logger`
instance, causing the race detector to trip roughly once in every 10
test runs.

This patch addresses this race condition by supplying each of the
competing processes an entirely separate logger, and ensuring that
these log instances are plumbed through to the code that would otherwise
trip the race detector.
  • Loading branch information
tcsc authored Jun 26, 2021
1 parent 90f186d commit 9b7002c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
PollingPeriod: process.Config.PollingPeriod,
FIPS: cfg.FIPS,
Emitter: streamEmitter,
Log: process.log,
})
if err != nil {
return trace.Wrap(err)
Expand Down
2 changes: 2 additions & 0 deletions tool/tsh/tsh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ func makeTestServers(t *testing.T, bootstrap ...types.Resource) (auth *service.T
cfg.Auth.Enabled = true
cfg.Auth.SSHAddr = randomLocalAddr
cfg.Proxy.Enabled = false
cfg.Log = utils.NewLoggerForTests()

auth, err = service.NewTeleport(cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -844,6 +845,7 @@ func makeTestServers(t *testing.T, bootstrap ...types.Resource) (auth *service.T
cfg.Proxy.SSHAddr = randomLocalAddr
cfg.Proxy.ReverseTunnelListenAddr = randomLocalAddr
cfg.Proxy.DisableWebInterface = true
cfg.Log = utils.NewLoggerForTests()

proxy, err = service.NewTeleport(cfg)
require.NoError(t, err)
Expand Down

0 comments on commit 9b7002c

Please sign in to comment.