diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 14:21:30 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 14:21:30 +0200 |
| commit | aa4f638206b9b79de267f9a1daab7ec6698b241d (patch) | |
| tree | 44c913b6be46460c184eac580d26a11973a6e283 /internal/flamegraph/livetrie_test.go | |
| parent | ef12ce837176bd21deb455eb50a6c839af02b510 (diff) | |
Fix real live flamegraph key handling and startup viewport sync
Diffstat (limited to 'internal/flamegraph/livetrie_test.go')
| -rw-r--r-- | internal/flamegraph/livetrie_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/flamegraph/livetrie_test.go b/internal/flamegraph/livetrie_test.go index 632f668..c5ed32c 100644 --- a/internal/flamegraph/livetrie_test.go +++ b/internal/flamegraph/livetrie_test.go @@ -221,6 +221,41 @@ func TestLiveTrieSnapshotJSONPrunesTinyNodes(t *testing.T) { } } +func TestLiveTrieSnapshotJSONKeepsFallbackChildrenWhenAllAreTinyAtRoot(t *testing.T) { + lt := NewLiveTrie([]string{"comm"}, "count") + const total = 6000 + for i := 0; i < total; i++ { + comm := fmt.Sprintf("svc-%04d", i) + lt.Ingest(newTestPair(comm, 42, uint32(100000+i), "/tmp/a", 1, 1, 1)) + } + + snap := decodeLiveSnapshot(t, lt) + if len(snap.Children) == 0 { + t.Fatalf("expected fallback root children when pruning would hide every branch") + } + if got, want := len(snap.Children), liveTrieMinVisibleChildrenWhenPruned; got != want { + t.Fatalf("expected fallback to keep %d root children, got %d", want, got) + } +} + +func TestLiveTrieSnapshotJSONKeepsFallbackChildrenAtDepthOne(t *testing.T) { + lt := NewLiveTrie([]string{"comm", "pid"}, "count") + const total = 6000 + for i := 0; i < total; i++ { + pid := uint32(100000 + i) + lt.Ingest(newTestPair("svc", pid, pid, "/tmp/a", 1, 1, 1)) + } + + snap := decodeLiveSnapshot(t, lt) + commNode := findSnapshotPath(t, &snap, "svc") + if len(commNode.Children) == 0 { + t.Fatalf("expected fallback depth-one children for pid branches") + } + if got, want := len(commNode.Children), liveTrieMinVisibleChildrenWhenPruned; got != want { + t.Fatalf("expected fallback to keep %d depth-one children, got %d", want, got) + } +} + func TestLiveTrieConcurrentIngestAndSnapshot(t *testing.T) { lt := NewLiveTrie([]string{"comm", "pid"}, "count") |
