diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-27 18:52:23 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-27 18:52:23 +0200 |
| commit | 5f23af510bd9031c515f2a3cc495bd996c795e69 (patch) | |
| tree | 151d94f6ffacf7446b72481d51f8f8925d5dee8d /internal/flamegraph/livetrie_test.go | |
| parent | 3783d23b8d608c3bf4a2dedd6b4bfb9165439bed (diff) | |
flamegraph: add live baseline reset hotkey
Diffstat (limited to 'internal/flamegraph/livetrie_test.go')
| -rw-r--r-- | internal/flamegraph/livetrie_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/flamegraph/livetrie_test.go b/internal/flamegraph/livetrie_test.go index 5d32209..9bd16c2 100644 --- a/internal/flamegraph/livetrie_test.go +++ b/internal/flamegraph/livetrie_test.go @@ -60,6 +60,33 @@ func TestLiveTrieVersionIncrementsPerIngest(t *testing.T) { } } +func TestLiveTrieResetClearsDataAndAdvancesVersion(t *testing.T) { + lt := NewLiveTrie([]string{"comm"}, "count") + lt.Ingest(newTestPair("svc", 42, 1001, "/tmp/a", 1, 1, 1)) + lt.Ingest(newTestPair("svc", 42, 1002, "/tmp/b", 1, 1, 1)) + + before := lt.Version() + if before == 0 { + t.Fatalf("expected non-zero version before reset") + } + + lt.Reset() + if got := lt.Version(); got != before+1 { + t.Fatalf("version after reset = %d, want %d", got, before+1) + } + + snap := decodeLiveSnapshot(t, lt) + if snap.Total != 0 { + t.Fatalf("snapshot total after reset = %d, want 0", snap.Total) + } + + lt.Ingest(newTestPair("svc", 42, 1003, "/tmp/c", 1, 1, 1)) + next := decodeLiveSnapshot(t, lt) + if next.Total != 1 { + t.Fatalf("snapshot total after new baseline ingest = %d, want 1", next.Total) + } +} + func TestLiveTrieSnapshotJSONCaching(t *testing.T) { lt := NewLiveTrie([]string{"comm"}, "count") lt.Ingest(newTestPair("svc", 42, 1001, "/tmp/a", 1, 1, 1)) |
