mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	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"
 | 
				
			||||||
	"os/exec"
 | 
						"os/exec"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
					 | 
				
			||||||
	"syscall"
 | 
						"syscall"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
@@ -84,7 +83,15 @@ func startEtcd(output io.Writer) (func(), error) {
 | 
				
			|||||||
	return stop, nil
 | 
						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.
 | 
					// 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) {
 | 
				
			||||||
@@ -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 {
 | 
						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)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user