MCPcopy
hub / github.com/etcd-io/bbolt / TestMlock_DbCanGrow_Big

Function TestMlock_DbCanGrow_Big

unix_test.go:49–75  ·  unix_test.go::TestMlock_DbCanGrow_Big

Test crossing of 16MB (AllocSize) of db size

(t *testing.T)

Source from the content-addressed store, hash-verified

47
48// Test crossing of 16MB (AllocSize) of db size
49func TestMlock_DbCanGrow_Big(t *testing.T) {
50 if testing.Short() {
51 t.Skip("skipping test in short mode")
52 }
53
54 // 32MB
55 skipOnMemlockLimitBelow(t, 32*1024*1024)
56
57 chunksBefore := 64
58 chunksAfter := 64
59
60 db := btesting.MustCreateDBWithOption(t, &bolt.Options{Mlock: true})
61
62 for chunk := 0; chunk < chunksBefore; chunk++ {
63 insertChunk(t, db, chunk)
64 }
65 dbSize := fileSize(db.Path())
66
67 for chunk := 0; chunk < chunksAfter; chunk++ {
68 insertChunk(t, db, chunksBefore+chunk)
69 }
70 newDbSize := fileSize(db.Path())
71
72 if newDbSize <= dbSize {
73 t.Errorf("db didn't grow: %v <= %v", newDbSize, dbSize)
74 }
75}
76
77func insertChunk(t *testing.T, db *btesting.DB, chunkId int) {
78 chunkSize := 1024

Callers

nothing calls this directly

Calls 6

MustCreateDBWithOptionFunction · 0.92
skipOnMemlockLimitBelowFunction · 0.85
insertChunkFunction · 0.85
fileSizeFunction · 0.85
ErrorfMethod · 0.65
PathMethod · 0.45

Tested by

no test coverage detected