Skip to content

Commit

Permalink
idle_test fix and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Dec 5, 2023
1 parent e920eaf commit a4ef6d7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/idle/idle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ type racyEnforcer struct {
func (ri *racyEnforcer) ExitIdleMode() error {
// Set only on the initial ExitIdleMode
if ri.started == false {
if !atomic.CompareAndSwapInt32((*int32)(ri.state), int32(stateInitial), int32(stateExitedIdle)) {
if !atomic.CompareAndSwapInt32((*int32)(ri.state), int32(stateInitial), int32(stateInitial)) {
return fmt.Errorf("idleness enforcer's first ExitIdleMode after EnterIdleMode")
}
ri.started = true
Expand Down Expand Up @@ -360,16 +360,16 @@ func (s) TestManager_IdleTimeoutRacesWithOnCallBegin(t *testing.T) {
wg.Add(1)
go func() {
defer wg.Done()
<-time.After(defaultTestIdleTimeout / 10)
<-time.After(defaultTestIdleTimeout / 50)
mgr.handleIdleTimeout()
}()
for j := 0; j < 100; j++ {
for j := 0; j < 5; j++ {
wg.Add(1)
go func() {
defer wg.Done()
// Wait for the configured idle timeout and simulate an RPC to
// race with the idle timeout timer callback.
<-time.After(defaultTestIdleTimeout / 10)
<-time.After(defaultTestIdleTimeout / 50)
if err := mgr.OnCallBegin(); err != nil {
t.Errorf("OnCallBegin() failed: %v", err)
}
Expand Down

0 comments on commit a4ef6d7

Please sign in to comment.