Merge pull request #117109 from pohly/test-integration-race-detection-framework-grpclog

test/integration/framework: avoid race around grpclog.SetLoggerV2
This commit is contained in:
Kubernetes Prow Robot 2023-04-11 20:21:31 -07:00 committed by GitHub
commit 730d811036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
"sync"
"syscall" "syscall"
"testing" "testing"
"time" "time"
@ -83,6 +84,8 @@ func startEtcd(output io.Writer) (func(), error) {
return stop, nil return stop, nil
} }
var initGRPCOnce sync.Once
// RunCustomEtcd starts a custom etcd instance for test purposes. // RunCustomEtcd starts a custom etcd instance for test purposes.
func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url string, stopFn func(), err error) { func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url string, stopFn func(), err error) {
// TODO: Check for valid etcd version. // TODO: Check for valid etcd version.
@ -150,7 +153,9 @@ func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url
// Quiet etcd logs for integration tests // Quiet etcd logs for integration tests
// Comment out to get verbose logs if desired // Comment out to get verbose logs if desired
grpclog.SetLoggerV2(grpclog.NewLoggerV2(io.Discard, io.Discard, os.Stderr)) initGRPCOnce.Do(func() {
grpclog.SetLoggerV2(grpclog.NewLoggerV2(io.Discard, io.Discard, os.Stderr))
})
if err := cmd.Start(); err != nil { if err := cmd.Start(); err != nil {
return "", nil, fmt.Errorf("failed to run etcd: %v", err) return "", nil, fmt.Errorf("failed to run etcd: %v", err)