MCPcopy
hub / github.com/benbjohnson/litestream / TestVFSFile_IndexMemoryDoesNotGrowUnbounded

Function TestVFSFile_IndexMemoryDoesNotGrowUnbounded

vfs_test.go:227–250  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func TestVFSFile_IndexMemoryDoesNotGrowUnbounded(t *testing.T) {
228 const pageLimit = 16
229 client := newMockReplicaClient()
230 client.addFixture(t, buildLTXFixture(t, 1, 'a'))
231
232 f := NewVFSFile(client, "mem.db", slog.Default())
233 if err := f.Open(); err != nil {
234 t.Fatalf("open vfs file: %v", err)
235 }
236
237 for i := 0; i < 100; i++ {
238 pgno := uint32(i%pageLimit) + 2
239 client.addFixture(t, buildLTXFixtureWithPages(t, ltx.TXID(i+2), 4096, []uint32{pgno}, byte('b'+byte(i%26))))
240 if err := f.pollReplicaClient(context.Background()); err != nil {
241 t.Fatalf("poll replica: %v", err)
242 }
243 }
244
245 f.mu.Lock()
246 defer f.mu.Unlock()
247 if l := len(f.index); l > pageLimit+1 { // +1 for initial page 1
248 t.Fatalf("index grew unexpectedly: got %d want <= %d", l, pageLimit+1)
249 }
250}
251
252func TestVFSFile_AutoVacuumShrinksCommit(t *testing.T) {
253 client := newMockReplicaClient()

Callers

nothing calls this directly

Calls 10

OpenMethod · 0.95
pollReplicaClientMethod · 0.95
newMockReplicaClientFunction · 0.85
buildLTXFixtureFunction · 0.85
NewVFSFileFunction · 0.85
buildLTXFixtureWithPagesFunction · 0.85
addFixtureMethod · 0.80
TXIDMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected