Merge pull request #108193 from utkarsh348/myfeature

Fixed race condition in test manager shutdown
This commit is contained in:
Kubernetes Prow Robot 2022-03-27 05:55:21 -07:00 committed by GitHub
commit d796dd7d0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -617,6 +617,23 @@ func Test_groupByPriority(t *testing.T) {
}
}
type buffer struct {
b bytes.Buffer
rw sync.RWMutex
}
func (b *buffer) String() string {
b.rw.RLock()
defer b.rw.RUnlock()
return b.b.String()
}
func (b *buffer) Write(p []byte) (n int, err error) {
b.rw.Lock()
defer b.rw.Unlock()
return b.b.Write(p)
}
func Test_managerImpl_processShutdownEvent(t *testing.T) {
var (
probeManager = probetest.FakeManager{}
@ -684,7 +701,7 @@ func Test_managerImpl_processShutdownEvent(t *testing.T) {
l := klog.Level(1)
l.Set("1")
// hijack the klog output
tmpWriteBuffer := bytes.NewBuffer(nil)
tmpWriteBuffer := new(buffer)
klog.SetOutput(tmpWriteBuffer)
klog.LogToStderr(false)