(t *testing.T)
| 2644 | } |
| 2645 | |
| 2646 | func 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 | |
| 2682 | func BenchmarkIngesterPush(b *testing.B) { |
| 2683 | limits := defaultLimitsTestConfig() |
nothing calls this directly
no test coverage detected