Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Stabilize metrics rollup chunk proof

rcourtman5e9a94d37567
diff --git a/pkg/metrics/store_test.go b/pkg/metrics/store_test.go
index 716f9e2903..295116f1e2 100644
--- a/pkg/metrics/store_test.go
+++ b/pkg/metrics/store_test.go
@@ -277,9 +277,13 @@ func TestStoreRollupTierMultiResource(t *testing.T) {
func TestStoreRollupTierUsesBoundedChunkBudget(t *testing.T) {
dir := t.TempDir()
+ chunkWindow := rollupChunkWindow(time.Minute)
+ sourceWindow := time.Duration(maxRollupChunksPerRun+4) * chunkWindow
+
cfg := DefaultConfig(dir)
cfg.DBPath = filepath.Join(dir, "metrics-rollup-chunks.db")
cfg.FlushInterval = time.Hour
+ cfg.RetentionRaw = sourceWindow + 20*time.Minute
store, err := NewStore(cfg)
if err != nil {
@@ -287,8 +291,11 @@ func TestStoreRollupTierUsesBoundedChunkBudget(t *testing.T) {
}
defer store.Close()
- chunkWindow := rollupChunkWindow(time.Minute)
- base := time.Now().UTC().Add(-24 * time.Hour).Truncate(time.Minute)
+ if err := store.WaitForMaintenance(5 * time.Second); err != nil {
+ t.Fatalf("wait for startup maintenance: %v", err)
+ }
+
+ base := time.Now().UTC().Add(-sourceWindow).Truncate(time.Minute)
batch := make([]WriteMetric, 0, maxRollupChunksPerRun+1)
for i := 0; i <= maxRollupChunksPerRun; i++ {
batch = append(batch, WriteMetric{