MCPcopy
hub / github.com/grpc/grpc-go / TestManager_Enabled_TimerFires

Method TestManager_Enabled_TimerFires

internal/idle/idle_test.go:131–152  ·  view source on GitHub ↗

TestManager_Enabled_TimerFires tests the case where the idle manager is enabled. Ensures that when there are no RPCs, the timer callback is invoked and the EnterIdleMode() method is invoked on the enforcer.

(t *testing.T)

Source from the content-addressed store, hash-verified

129// is enabled. Ensures that when there are no RPCs, the timer callback is
130// invoked and the EnterIdleMode() method is invoked on the enforcer.
131func (s) TestManager_Enabled_TimerFires(t *testing.T) {
132 callbackCh := overrideNewTimer(t)
133
134 enforcer := newTestEnforcer()
135 mgr := NewManager(enforcer, time.Duration(defaultTestIdleTimeout))
136 defer mgr.Close()
137 mgr.ExitIdleMode()
138
139 // Ensure that the timer callback fires within an appropriate amount of time.
140 select {
141 case <-callbackCh:
142 case <-time.After(2 * defaultTestIdleTimeout):
143 t.Fatal("Timeout waiting for idle timer callback to fire")
144 }
145
146 // Ensure that the channel moves to idle mode eventually.
147 select {
148 case <-enforcer.enterIdleCh:
149 case <-time.After(defaultTestTimeout):
150 t.Fatal("Timeout waiting for channel to move to idle")
151 }
152}
153
154// TestManager_Enabled_OngoingCall tests the case where the idle manager
155// is enabled. Ensures that when there is an ongoing RPC, the channel does not

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
ExitIdleModeMethod · 0.95
overrideNewTimerFunction · 0.85
newTestEnforcerFunction · 0.85
NewManagerFunction · 0.85
FatalMethod · 0.65

Tested by

no test coverage detected