(t *testing.T)
| 336 | } |
| 337 | |
| 338 | func TestValidateLabelOrder(t *testing.T) { |
| 339 | cfg := new(Limits) |
| 340 | cfg.MaxLabelNameLength = 10 |
| 341 | cfg.MaxLabelNamesPerSeries = 10 |
| 342 | cfg.MaxLabelValueLength = 10 |
| 343 | reg := prometheus.NewRegistry() |
| 344 | validateMetrics := NewValidateMetrics(reg) |
| 345 | userID := "testUser" |
| 346 | |
| 347 | actual := ValidateLabels(validateMetrics, cfg, userID, []cortexpb.LabelAdapter{ |
| 348 | {Name: model.MetricNameLabel, Value: "m"}, |
| 349 | {Name: "b", Value: "b"}, |
| 350 | {Name: "a", Value: "a"}, |
| 351 | }, false, model.LegacyValidation) |
| 352 | expected := newLabelsNotSortedError([]cortexpb.LabelAdapter{ |
| 353 | {Name: model.MetricNameLabel, Value: "m"}, |
| 354 | {Name: "b", Value: "b"}, |
| 355 | {Name: "a", Value: "a"}, |
| 356 | }, "a") |
| 357 | assert.Equal(t, expected, actual) |
| 358 | |
| 359 | require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(` |
| 360 | # HELP cortex_discarded_samples_total The total number of samples that were discarded. |
| 361 | # TYPE cortex_discarded_samples_total counter |
| 362 | cortex_discarded_samples_total{reason="labels_not_sorted",user="testUser"} 1 |
| 363 | `), "cortex_discarded_samples_total")) |
| 364 | } |
| 365 | |
| 366 | func TestValidateLabelDuplication(t *testing.T) { |
| 367 | cfg := new(Limits) |
nothing calls this directly
no test coverage detected