Merge pull request #118994 from pohly/test-integration-race-detection-grpc-logger
integration testing: configure gRPC logging during init
This commit is contained in:
		@@ -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)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user