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

Function TestBreakerOverload

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

Source from the content-addressed store, hash-verified

118}
119
120func TestBreakerOverload(t *testing.T) {
121 params := BreakerParams{QueueDepth: 1, MaxConcurrency: 1, InitialCapacity: 1}
122 b := NewBreaker(params) // Breaker capacity = 2
123 reqs := newRequestor(b)
124
125 // Bring breaker to capacity.
126 reqs.request()
127 reqs.request()
128
129 // Overshoot by one.
130 reqs.request()
131 reqs.expectFailure(t)
132
133 // The remainer should succeed.
134 reqs.processSuccessfully(t)
135 reqs.processSuccessfully(t)
136}
137
138func TestBreakerQueueing(t *testing.T) {
139 params := BreakerParams{QueueDepth: 2, MaxConcurrency: 1, InitialCapacity: 0}

Callers

nothing calls this directly

Calls 5

NewBreakerFunction · 0.85
newRequestorFunction · 0.85
requestMethod · 0.80
expectFailureMethod · 0.80
processSuccessfullyMethod · 0.80

Tested by

no test coverage detected