MCPcopy
hub / github.com/prometheus/prometheus / TestMetadataDelivery

Function TestMetadataDelivery

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

Source from the content-addressed store, hash-verified

319}
320
321func TestMetadataDelivery(t *testing.T) {
322 c, m := newTestClientAndQueueManager(t, defaultFlushDeadline, remoteapi.WriteV1MessageType)
323 m.Start()
324 defer m.Stop()
325
326 metadata := []scrape.MetricMetadata{}
327 numMetadata := 1532
328 for i := range numMetadata {
329 metadata = append(metadata, scrape.MetricMetadata{
330 MetricFamily: "prometheus_remote_storage_sent_metadata_bytes_" + strconv.Itoa(i),
331 Type: model.MetricTypeCounter,
332 Help: "a nice help text",
333 Unit: "",
334 })
335 }
336
337 m.AppendWatcherMetadata(context.Background(), metadata)
338
339 require.Equal(t, 0.0, client_testutil.ToFloat64(m.metrics.failedMetadataTotal))
340 require.Len(t, c.receivedMetadata, numMetadata)
341 // One more write than the rounded quotient should be performed in order to get samples that didn't
342 // fit into MaxSamplesPerSend.
343 require.Equal(t, numMetadata/config.DefaultMetadataConfig.MaxSamplesPerSend+1, c.writesReceived)
344 // Make sure the last samples were sent.
345 require.Equal(t, c.receivedMetadata[metadata[len(metadata)-1].MetricFamily][0].MetricFamilyName, metadata[len(metadata)-1].MetricFamily)
346}
347
348func TestWALMetadataDelivery(t *testing.T) {
349 dir := t.TempDir()

Callers

nothing calls this directly

Calls 5

AppendWatcherMetadataMethod · 0.65
LenMethod · 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…