MCPcopy
hub / github.com/cortexlabs/cortex / TestBreakerInflight

Function TestBreakerInflight

pkg/proxy/breaker_test.go:155–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

153}
154
155func TestBreakerInflight(t *testing.T) {
156 params := BreakerParams{QueueDepth: 2, MaxConcurrency: 1, InitialCapacity: 1}
157 b := NewBreaker(params) // Breaker capacity = 2
158 reqs := newRequestor(b)
159
160 // Bring breaker to capacity. Doesn't error because queue subsumes these requests.
161 reqs.request()
162 reqs.request()
163 reqs.request()
164
165 require.Eventually(t, func() bool {
166 return b.InFlight() == int64(3)
167 }, time.Second, 10*time.Millisecond)
168 require.Equal(t, reqs.InProgress.Load(), int64(1))
169}
170
171func TestBreakerNoOverload(t *testing.T) {
172 params := BreakerParams{QueueDepth: 1, MaxConcurrency: 1, InitialCapacity: 1}

Callers

nothing calls this directly

Calls 5

InFlightMethod · 0.95
NewBreakerFunction · 0.85
newRequestorFunction · 0.85
requestMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected