MCPcopy
hub / github.com/cloudflare/ebpf_exporter / TestDecoderSetConcurrency

Function TestDecoderSetConcurrency

decoder/decoder_test.go:294–352  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

292}
293
294func TestDecoderSetConcurrency(t *testing.T) {
295 in := append([]byte{0x8, 0x0, 0x0, 0x0}, zeroPaddedString("bananas", 32)...)
296
297 labels := []config.Label{
298 {
299 Name: "number",
300 Size: 4,
301 Decoders: []config.Decoder{
302 {
303 Name: "uint",
304 },
305 },
306 },
307 {
308 Name: "fruit",
309 Size: 32,
310 Decoders: []config.Decoder{
311 {
312 Name: "string",
313 },
314 {
315 Name: "regexp",
316 Regexps: []string{
317 "^bananas$",
318 "$is-banana-even-fruit$",
319 },
320 },
321 },
322 },
323 }
324
325 s, err := NewSet(0, nil)
326 if err != nil {
327 t.Fatal(err)
328 }
329
330 count := 1000
331
332 wg := sync.WaitGroup{}
333 wg.Add(count)
334
335 for range count {
336 go func() {
337 defer wg.Done()
338
339 _, err := s.DecodeLabelsForMetrics(in, "concurrency", labels)
340 if err != nil {
341 t.Error(err)
342 }
343
344 _, err = s.DecodeLabelsForTracing(in, labels)
345 if err != nil {
346 t.Error(err)
347 }
348 }()
349 }
350
351 wg.Wait()

Callers

nothing calls this directly

Calls 4

zeroPaddedStringFunction · 0.85
NewSetFunction · 0.85

Tested by

no test coverage detected