(t *testing.T)
| 5607 | } |
| 5608 | |
| 5609 | func TestIngesterCompactAndCloseIdleTSDB(t *testing.T) { |
| 5610 | cfg := defaultIngesterTestConfig(t) |
| 5611 | cfg.LifecyclerConfig.JoinAfter = 0 |
| 5612 | cfg.BlocksStorageConfig.TSDB.ShipInterval = 1 * time.Second // Required to enable shipping. |
| 5613 | cfg.BlocksStorageConfig.TSDB.ShipConcurrency = 1 |
| 5614 | cfg.BlocksStorageConfig.TSDB.HeadCompactionInterval = 1 * time.Second |
| 5615 | cfg.BlocksStorageConfig.TSDB.HeadCompactionIdleTimeout = 1 * time.Second |
| 5616 | cfg.BlocksStorageConfig.TSDB.CloseIdleTSDBTimeout = 1 * time.Second |
| 5617 | cfg.BlocksStorageConfig.TSDB.CloseIdleTSDBInterval = 100 * time.Millisecond |
| 5618 | |
| 5619 | r := prometheus.NewRegistry() |
| 5620 | |
| 5621 | // Create ingester |
| 5622 | i, err := prepareIngesterWithBlocksStorage(t, cfg, r) |
| 5623 | require.NoError(t, err) |
| 5624 | |
| 5625 | require.NoError(t, services.StartAndAwaitRunning(context.Background(), i)) |
| 5626 | t.Cleanup(func() { |
| 5627 | require.NoError(t, services.StopAndAwaitTerminated(context.Background(), i)) |
| 5628 | }) |
| 5629 | |
| 5630 | // Wait until it's ACTIVE |
| 5631 | test.Poll(t, 1*time.Second, ring.ACTIVE, func() any { |
| 5632 | return i.lifecycler.GetState() |
| 5633 | }) |
| 5634 | |
| 5635 | pushSingleSampleWithMetadata(t, i) |
| 5636 | i.updateActiveSeries(context.Background()) |
| 5637 | |
| 5638 | require.Equal(t, int64(1), i.TSDBState.seriesCount.Load()) |
| 5639 | |
| 5640 | userMetrics := []string{memSeriesCreatedTotalName, memSeriesRemovedTotalName, "cortex_ingester_active_series"} |
| 5641 | |
| 5642 | globalMetrics := []string{"cortex_ingester_memory_users", "cortex_ingester_memory_metadata"} |
| 5643 | metricsToCheck := append(userMetrics, globalMetrics...) |
| 5644 | |
| 5645 | require.NoError(t, testutil.GatherAndCompare(r, strings.NewReader(` |
| 5646 | # HELP cortex_ingester_memory_series_created_total The total number of series that were created per user. |
| 5647 | # TYPE cortex_ingester_memory_series_created_total counter |
| 5648 | cortex_ingester_memory_series_created_total{user="1"} 1 |
| 5649 | |
| 5650 | # HELP cortex_ingester_memory_series_removed_total The total number of series that were removed per user. |
| 5651 | # TYPE cortex_ingester_memory_series_removed_total counter |
| 5652 | cortex_ingester_memory_series_removed_total{user="1"} 0 |
| 5653 | |
| 5654 | # HELP cortex_ingester_memory_users The current number of users in memory. |
| 5655 | # TYPE cortex_ingester_memory_users gauge |
| 5656 | cortex_ingester_memory_users 1 |
| 5657 | |
| 5658 | # HELP cortex_ingester_active_series Number of currently active series per user. |
| 5659 | # TYPE cortex_ingester_active_series gauge |
| 5660 | cortex_ingester_active_series{user="1"} 1 |
| 5661 | |
| 5662 | # HELP cortex_ingester_memory_metadata The current number of metadata in memory. |
| 5663 | # TYPE cortex_ingester_memory_metadata gauge |
| 5664 | cortex_ingester_memory_metadata 1 |
| 5665 | |
| 5666 | # HELP cortex_ingester_memory_metadata_created_total The total number of metadata that were created per user |
nothing calls this directly
no test coverage detected