Skip to content

Commit

Permalink
*: fix unstable test TestPoolTuneScaleUpAndDown (#42744)
Browse files Browse the repository at this point in the history
close #42163
  • Loading branch information
hawkingrei authored Apr 3, 2023
1 parent 326568b commit 5f87e88
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions resourcemanager/pool/spool/spool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,11 @@ func TestPoolTuneScaleUpAndDown(t *testing.T) {
for i := 0; i < 6; i++ {
c <- struct{}{}
}
time.Sleep(200 * time.Millisecond)
require.Equal(t, int32(2), p.Running())
require.Eventually(t, func() bool { return p.Running() == 2 }, 1*time.Second, 200*time.Millisecond)
for i := 0; i < 2; i++ {
c <- struct{}{}
}
time.Sleep(100 * time.Millisecond)
require.Equal(t, int32(0), p.Running())
require.Eventually(t, func() bool { return p.Running() == 0 }, 1*time.Second, 200*time.Millisecond)

// test with RunWithConcurrency
var cnt atomic.Int32
Expand All @@ -125,12 +123,10 @@ func TestPoolTuneScaleUpAndDown(t *testing.T) {
for i := 0; i < 10; i++ {
fnChan <- workerFn
}
time.Sleep(100 * time.Millisecond)
require.Equal(t, int32(10), cnt.Load())
require.Eventually(t, func() bool { return cnt.Load() == 10 }, 1*time.Second, 200*time.Millisecond)
require.Equal(t, int32(2), p.Running())
close(fnChan)
time.Sleep(100 * time.Microsecond)
require.Equal(t, int32(0), p.Running())
require.Eventually(t, func() bool { return p.Running() == 0 }, 1*time.Second, 200*time.Millisecond)
p.ReleaseAndWait()
}

Expand Down

0 comments on commit 5f87e88

Please sign in to comment.