Skip to content

Commit

Permalink
idle: speed up test by 5x even while running 2x more iterations (#6555)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley authored Aug 15, 2023
1 parent 7d3996f commit ebf0b4e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions idle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (ri *racyIdlenessEnforcer) enterIdleMode() error {
// mode.
func (s) TestIdlenessManager_IdleTimeoutRacesWithOnCallBegin(t *testing.T) {
// Run multiple iterations to simulate different possibilities.
for i := 0; i < 10; i++ {
for i := 0; i < 20; i++ {
t.Run(fmt.Sprintf("iteration=%d", i), func(t *testing.T) {
var idlenessState racyIdlenessState
enforcer := &racyIdlenessEnforcer{state: &idlenessState}
Expand All @@ -337,7 +337,7 @@ func (s) TestIdlenessManager_IdleTimeoutRacesWithOnCallBegin(t *testing.T) {
go func() {
defer wg.Done()
m := mgr.(interface{ handleIdleTimeout() })
<-time.After(defaultTestIdleTimeout)
<-time.After(defaultTestIdleTimeout / 10)
m.handleIdleTimeout()
}()
for j := 0; j < 100; j++ {
Expand All @@ -346,7 +346,7 @@ func (s) TestIdlenessManager_IdleTimeoutRacesWithOnCallBegin(t *testing.T) {
defer wg.Done()
// Wait for the configured idle timeout and simulate an RPC to
// race with the idle timeout timer callback.
<-time.After(defaultTestIdleTimeout)
<-time.After(defaultTestIdleTimeout / 10)
if err := mgr.onCallBegin(); err != nil {
t.Errorf("onCallBegin() failed: %v", err)
}
Expand Down

0 comments on commit ebf0b4e

Please sign in to comment.