MCPcopy
hub / github.com/grafana/tempo / TestOneWorker

Function TestOneWorker

tempodb/pool/pool_test.go:184–213  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

182}
183
184func TestOneWorker(t *testing.T) {
185 prePoolOpts := goleak.IgnoreCurrent()
186
187 p := NewPool(&Config{
188 MaxWorkers: 1,
189 QueueDepth: 10,
190 })
191 opts := goleak.IgnoreCurrent()
192
193 ret := []byte{0x01, 0x02, 0x03}
194 fn := func(_ context.Context, payload interface{}) (interface{}, error) {
195 i := payload.(int)
196
197 if i == 3 {
198 return ret, nil
199 }
200 return nil, nil
201 }
202 payloads := []interface{}{1, 2, 3, 4, 5}
203
204 msg, funcErrs, err := p.RunJobs(context.Background(), payloads, fn)
205 assert.NoError(t, err)
206 assert.Nil(t, funcErrs)
207 require.Len(t, msg, 1)
208 assert.Equal(t, ret, msg[0])
209 goleak.VerifyNone(t, opts)
210
211 p.Shutdown()
212 goleak.VerifyNone(t, prePoolOpts)
213}
214
215func TestGoingHam(t *testing.T) {
216 prePoolOpts := goleak.IgnoreCurrent()

Callers

nothing calls this directly

Calls 5

RunJobsMethod · 0.95
ShutdownMethod · 0.95
NewPoolFunction · 0.70
LenMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected