MCPcopy
hub / github.com/perkeep/perkeep / TestFDLeak

Function TestFDLeak

pkg/index/sqlite/sqlite_test.go:140–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

138}
139
140func TestFDLeak(t *testing.T) {
141 if testing.Short() {
142 t.Skip("Skipping in short mode.")
143 }
144 fd0 := numFDs(t)
145 t.Logf("fd0 = %d", fd0)
146
147 s, clean := newSorted(t)
148 defer clean()
149
150 bm := s.BeginBatch()
151 const numRows = 150 // 3x the batchSize of 50 in sqlindex.go; to guarantee we do multiple batches
152 for i := 0; i < numRows; i++ {
153 bm.Set(fmt.Sprintf("key:%05d", i), fmt.Sprint(i))
154 }
155 if err := s.CommitBatch(bm); err != nil {
156 t.Fatal(err)
157 }
158 for i := 0; i < 5; i++ {
159 it := s.Find("key:", "key~")
160 n := 0
161 for it.Next() {
162 n++
163 }
164 if n != numRows {
165 t.Errorf("iterated over %d rows; want %d", n, numRows)
166 }
167 it.Close()
168 t.Logf("fd after iteration %d = %d", i, numFDs(t))
169 }
170}

Callers

nothing calls this directly

Calls 10

numFDsFunction · 0.85
newSortedFunction · 0.85
LogfMethod · 0.80
FatalMethod · 0.80
BeginBatchMethod · 0.65
SetMethod · 0.65
CommitBatchMethod · 0.65
FindMethod · 0.65
NextMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected