Give control to Embedded servers whether they override global loggers

So far each instance of embed server was overriding the grpc loggers and zap.global loggers.
It's counter intutitive that last created Embedded server was 'wining' and more-over it was breaking grpc expectation to change it "only" before the grpc stack is being used.

This PR introduces explicit call: `embed.Config::SetupGlobalLoggers()`, that changes the loggers where requested. The call is used by etcd main binary.

The immediate benefit from this change is reduction of  test flakiness, as there were flakes due to not a proper logger being used across tests.
This commit is contained in:
Piotr Tabor
2021-04-14 12:16:11 +02:00
parent eafbc8c57e
commit d72f7ef5cc
6 changed files with 33 additions and 60 deletions

View File

@ -230,13 +230,13 @@ func restoreCluster(t *testing.T, clusterN int, dbPath string) (
ics := ""
for i := 0; i < clusterN; i++ {
ics += fmt.Sprintf(",%d=%s", i, pURLs[i].String())
ics += fmt.Sprintf(",m%d=%s", i, pURLs[i].String())
}
ics = ics[1:]
cfgs := make([]*embed.Config, clusterN)
for i := 0; i < clusterN; i++ {
cfg := integration.NewEmbedConfig(t, fmt.Sprintf("%d", i))
cfg := integration.NewEmbedConfig(t, fmt.Sprintf("m%d", i))
cfg.InitialClusterToken = testClusterTkn
cfg.ClusterState = "existing"
cfg.LCUrls, cfg.ACUrls = []url.URL{cURLs[i]}, []url.URL{cURLs[i]}