MCPcopy
hub / github.com/prometheus/prometheus / TestShutdown

Function TestShutdown

storage/remote/queue_manager_test.go:445–482  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

443}
444
445func TestShutdown(t *testing.T) {
446 t.Parallel()
447 for _, protoMsg := range []remoteapi.WriteMessageType{remoteapi.WriteV1MessageType, remoteapi.WriteV2MessageType} {
448 t.Run(fmt.Sprint(protoMsg), func(t *testing.T) {
449 synctest.Test(t, func(t *testing.T) {
450 deadline := 15 * time.Second
451 c := NewTestBlockedWriteClient()
452
453 cfg := config.DefaultQueueConfig
454 mcfg := config.DefaultMetadataConfig
455
456 m := newTestQueueManager(t, cfg, mcfg, deadline, c, protoMsg)
457 // Send 2x batch size, so we know it will need at least two sends.
458 n := 2 * config.DefaultQueueConfig.MaxSamplesPerSend
459 recs := testwal.GenerateRecords(recCase{
460 NoST: protoMsg == remoteapi.WriteV1MessageType, // RW1 does not support ST.
461 Series: n / 1000, SamplesPerSeries: 1000,
462 })
463 m.StoreSeries(recs.Series, 0)
464 m.Start()
465
466 // Append blocks to guarantee delivery, so we do it in the background.
467 go func() {
468 m.Append(recs.Samples)
469 }()
470 synctest.Wait()
471
472 // Test to ensure that Stop doesn't block.
473 start := time.Now()
474 m.Stop()
475 // The samples will never be delivered, so duration should
476 // be at least equal to deadline, otherwise the flush deadline
477 // was not respected.
478 require.Equal(t, time.Since(start), deadline)
479 })
480 })
481 }
482}
483
484func TestSeriesReset(t *testing.T) {
485 for _, protoMsg := range []remoteapi.WriteMessageType{remoteapi.WriteV1MessageType, remoteapi.WriteV2MessageType} {

Callers

nothing calls this directly

Calls 8

GenerateRecordsFunction · 0.92
newTestQueueManagerFunction · 0.85
RunMethod · 0.65
StoreSeriesMethod · 0.65
AppendMethod · 0.65
StartMethod · 0.45
StopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…