(t *testing.T)
| 361 | } |
| 362 | |
| 363 | func Test_counter_demandDecay(t *testing.T) { |
| 364 | c := newCounter("my_counter", noopLimiter, map[string]string{}, 15*time.Minute) |
| 365 | |
| 366 | // Add series |
| 367 | for i := 0; i < 40; i++ { |
| 368 | lbls := buildTestLabels([]string{"label"}, []string{fmt.Sprintf("value-%d", i)}) |
| 369 | c.Inc(lbls, 1.0) |
| 370 | } |
| 371 | |
| 372 | initialDemand := c.countSeriesDemand() |
| 373 | assert.Greater(t, initialDemand, 0) |
| 374 | |
| 375 | // Advance the cardinality tracker enough times to clear the window |
| 376 | for i := 0; i < 5; i++ { |
| 377 | c.removeStaleSeries(time.Now().UnixMilli()) |
| 378 | } |
| 379 | |
| 380 | // Demand should have decreased or be zero |
| 381 | finalDemand := c.countSeriesDemand() |
| 382 | assert.LessOrEqual(t, finalDemand, initialDemand/2, "demand should significantly decay") |
| 383 | } |
| 384 | |
| 385 | func Test_counter_onUpdate(t *testing.T) { |
| 386 | var seriesUpdated int |
nothing calls this directly
no test coverage detected