(t *testing.T)
| 7264 | } |
| 7265 | |
| 7266 | func TestIngester_UpdateLabelSetMetrics(t *testing.T) { |
| 7267 | cfg := defaultIngesterTestConfig(t) |
| 7268 | cfg.BlocksStorageConfig.TSDB.BlockRanges = []time.Duration{2 * time.Hour} |
| 7269 | reg := prometheus.NewRegistry() |
| 7270 | limits := defaultLimitsTestConfig() |
| 7271 | limits.EnableNativeHistograms = true |
| 7272 | userID := "1" |
| 7273 | ctx := user.InjectOrgID(context.Background(), userID) |
| 7274 | |
| 7275 | limits.LimitsPerLabelSet = []validation.LimitsPerLabelSet{ |
| 7276 | { |
| 7277 | LabelSet: labels.FromMap(map[string]string{ |
| 7278 | "foo": "bar", |
| 7279 | }), |
| 7280 | Limits: validation.LimitsPerLabelSetEntry{ |
| 7281 | MaxSeries: 1, |
| 7282 | }, |
| 7283 | }, |
| 7284 | { |
| 7285 | LabelSet: labels.EmptyLabels(), |
| 7286 | }, |
| 7287 | } |
| 7288 | tenantLimits := newMockTenantLimits(map[string]*validation.Limits{userID: &limits}) |
| 7289 | |
| 7290 | dir := t.TempDir() |
| 7291 | chunksDir := filepath.Join(dir, "chunks") |
| 7292 | blocksDir := filepath.Join(dir, "blocks") |
| 7293 | require.NoError(t, os.Mkdir(chunksDir, os.ModePerm)) |
| 7294 | require.NoError(t, os.Mkdir(blocksDir, os.ModePerm)) |
| 7295 | |
| 7296 | i, err := prepareIngesterWithBlocksStorageAndLimits(t, cfg, limits, tenantLimits, blocksDir, reg) |
| 7297 | require.NoError(t, err) |
| 7298 | require.NoError(t, services.StartAndAwaitRunning(context.Background(), i)) |
| 7299 | defer services.StopAndAwaitTerminated(context.Background(), i) //nolint:errcheck |
| 7300 | |
| 7301 | // Wait until it's ACTIVE |
| 7302 | test.Poll(t, time.Second, ring.ACTIVE, func() any { |
| 7303 | return i.lifecycler.GetState() |
| 7304 | }) |
| 7305 | // Add user ID. |
| 7306 | wreq := &cortexpb.WriteRequest{ |
| 7307 | Timeseries: []cortexpb.PreallocTimeseries{ |
| 7308 | {TimeSeries: &cortexpb.TimeSeries{ |
| 7309 | Labels: cortexpb.FromLabelsToLabelAdapters(labels.FromMap(map[string]string{model.MetricNameLabel: "test", "foo": "bar"})), |
| 7310 | Samples: []cortexpb.Sample{{Value: 0, TimestampMs: 1}}, |
| 7311 | }}, |
| 7312 | }, |
| 7313 | } |
| 7314 | _, err = i.Push(ctx, wreq) |
| 7315 | require.NoError(t, err) |
| 7316 | |
| 7317 | // Push one more series will trigger throttle by label set. |
| 7318 | wreq = &cortexpb.WriteRequest{ |
| 7319 | Timeseries: []cortexpb.PreallocTimeseries{ |
| 7320 | {TimeSeries: &cortexpb.TimeSeries{ |
| 7321 | Labels: cortexpb.FromLabelsToLabelAdapters(labels.FromMap(map[string]string{model.MetricNameLabel: "test2", "foo": "bar"})), |
| 7322 | Samples: []cortexpb.Sample{{Value: 0, TimestampMs: 0}}, |
| 7323 | }}, |
nothing calls this directly
no test coverage detected