fix(metrics): stabilize cpu and power sampling

This commit is contained in:
Mikhail Chusavitin
2026-04-01 09:40:42 +03:00
parent 4e4debd4da
commit c95bbff23b
5 changed files with 145 additions and 11 deletions

View File

@@ -89,6 +89,19 @@ func TestChartDataFromSamplesUsesFullHistory(t *testing.T) {
}
}
func TestNormalizePowerSeriesHoldsLastPositive(t *testing.T) {
got := normalizePowerSeries([]float64{0, 480, 0, 0, 510, 0})
want := []float64{0, 480, 480, 480, 510, 510}
if len(got) != len(want) {
t.Fatalf("len=%d want %d", len(got), len(want))
}
for i := range want {
if got[i] != want[i] {
t.Fatalf("got[%d]=%v want %v", i, got[i], want[i])
}
}
}
func TestRootRendersDashboard(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "audit.json")