Merge pull request #118994 from pohly/test-integration-race-detection-grpc-logger

integration testing: configure gRPC logging during init
This commit is contained in:
Kubernetes Prow Robot 2023-07-05 02:58:55 -07:00 committed by GitHub
commit a9a7a3730e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,6 @@ import (
"os"
"os/exec"
"strings"
"sync"
"syscall"
"testing"
"time"
@ -84,7 +83,15 @@ func startEtcd(output io.Writer) (func(), error) {
return stop, nil
}
var initGRPCOnce sync.Once
func init() {
// Quiet etcd logs for integration tests
// Comment out to get verbose logs if desired.
// This has to be done before there are any goroutines
// active which use gRPC. During init is safe, albeit
// then also affects tests which don't use RunCustomEtcd
// (the place this was done before).
grpclog.SetLoggerV2(grpclog.NewLoggerV2(io.Discard, io.Discard, os.Stderr))
}
// RunCustomEtcd starts a custom etcd instance for test purposes.
func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url string, stopFn func(), err error) {
@ -151,12 +158,6 @@ func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url
}
}
// Quiet etcd logs for integration tests
// Comment out to get verbose logs if desired
initGRPCOnce.Do(func() {
grpclog.SetLoggerV2(grpclog.NewLoggerV2(io.Discard, io.Discard, os.Stderr))
})
if err := cmd.Start(); err != nil {
return "", nil, fmt.Errorf("failed to run etcd: %v", err)
}