cc-metric-store/archive_test.go

34 lines
836 B
Go
Raw Normal View History

package main
import (
2023-08-22 15:33:19 +02:00
"bufio"
2023-08-22 15:27:52 +02:00
"log"
2023-08-22 15:33:19 +02:00
"os"
"testing"
"time"
)
2023-08-22 15:27:52 +02:00
func TestFromCheckpoint(t *testing.T) {
m := NewMemoryStore(map[string]MetricConfig{
"cpi": {Frequency: 5, Aggregation: AvgAggregation},
"flops_any": {Frequency: 5, Aggregation: SumAggregation},
"flops_dp": {Frequency: 5, Aggregation: SumAggregation},
"flops_sp": {Frequency: 5, Aggregation: SumAggregation},
})
2023-08-22 15:27:52 +02:00
startupTime := time.Now()
files, err := m.FromCheckpoint("./testdata/checkpoints", 1692628930)
loadedData := m.SizeInBytes() / 1024 / 1024 // In MB
if err != nil {
2023-08-22 15:27:52 +02:00
t.Fatal(err)
} else {
log.Printf("Checkpoints loaded (%d files, %d MB, that took %fs)\n", files, loadedData, time.Since(startupTime).Seconds())
}
2023-08-22 15:33:19 +02:00
m.DebugDump(bufio.NewWriter(os.Stdout), nil)
2023-08-22 15:27:52 +02:00
if files != 2 {
t.Errorf("expected: %d, got: %d\n", 2, files)
}
}