MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestIngester_Push_OutOfOrderLabels

Function TestIngester_Push_OutOfOrderLabels

pkg/ingester/ingester_test.go:2646–2680  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2644}
2645
2646func TestIngester_Push_OutOfOrderLabels(t *testing.T) {
2647 // Create ingester
2648 cfg := defaultIngesterTestConfig(t)
2649 r := prometheus.NewRegistry()
2650 i, err := prepareIngesterWithBlocksStorage(t, cfg, r)
2651 require.NoError(t, err)
2652 require.NoError(t, services.StartAndAwaitRunning(context.Background(), i))
2653 defer services.StopAndAwaitTerminated(context.Background(), i) //nolint:errcheck
2654
2655 // Wait until it's ACTIVE
2656 test.Poll(t, time.Second, ring.ACTIVE, func() any {
2657 return i.lifecycler.GetState()
2658 })
2659
2660 ctx := user.InjectOrgID(context.Background(), "test-user")
2661
2662 outOfOrderLabels := []cortexpb.LabelAdapter{
2663 {Name: labels.MetricName, Value: "test_metric"},
2664 {Name: "c", Value: "3"},
2665 {Name: "a", Value: "1"},
2666 }
2667
2668 req, _ := mockWriteRequest(t, cortexpb.FromLabelAdaptersToLabels(outOfOrderLabels), 1, 2)
2669 _, err = i.Push(ctx, req)
2670 require.Error(t, err)
2671 require.Contains(t, err.Error(), "out-of-order label set found")
2672
2673 metric := `
2674 # HELP cortex_ingester_out_of_order_labels_total The total number of out of order label found per user.
2675 # TYPE cortex_ingester_out_of_order_labels_total counter
2676 cortex_ingester_out_of_order_labels_total{user="test-user"} 1
2677`
2678 err = testutil.GatherAndCompare(r, bytes.NewBufferString(metric), "cortex_ingester_out_of_order_labels_total")
2679 require.NoError(t, err)
2680}
2681
2682func BenchmarkIngesterPush(b *testing.B) {
2683 limits := defaultLimitsTestConfig()

Callers

nothing calls this directly

Calls 10

StartAndAwaitRunningFunction · 0.92
StopAndAwaitTerminatedFunction · 0.92
PollFunction · 0.92
mockWriteRequestFunction · 0.70
PushMethod · 0.65
GetStateMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected