mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-27 11:19:12 +00:00
Deflake ThrottledLogger test
Kubernetes-commit: c84df5d66ea8d949374b67c5205b9869b984ea84
This commit is contained in:
parent
66db254099
commit
61471be615
@ -2228,14 +2228,18 @@ func TestRequestPreflightCheck(t *testing.T) {
|
||||
|
||||
func TestThrottledLogger(t *testing.T) {
|
||||
now := time.Now()
|
||||
oldClock := globalThrottledLogger.clock
|
||||
defer func() {
|
||||
globalThrottledLogger.clock = oldClock
|
||||
}()
|
||||
clock := clock.NewFakeClock(now)
|
||||
globalThrottledLogger.clock = clock
|
||||
|
||||
logMessages := 0
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(100)
|
||||
for j := 0; j < 100; j++ {
|
||||
wg.Add(10)
|
||||
for j := 0; j < 10; j++ {
|
||||
go func() {
|
||||
if _, ok := globalThrottledLogger.attemptToLog(); ok {
|
||||
logMessages++
|
||||
@ -2248,7 +2252,7 @@ func TestThrottledLogger(t *testing.T) {
|
||||
clock.SetTime(now)
|
||||
}
|
||||
|
||||
if a, e := logMessages, 1000; a != e {
|
||||
if a, e := logMessages, 100; a != e {
|
||||
t.Fatalf("expected %v log messages, but got %v", e, a)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user