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

Function TestDB_Put_VeryLarge

bucket_test.go:207–235  ·  view source on GitHub ↗

Ensure that a database can perform multiple large appends safely.

(t *testing.T)

Source from the content-addressed store, hash-verified

205
206// Ensure that a database can perform multiple large appends safely.
207func TestDB_Put_VeryLarge(t *testing.T) {
208 if testing.Short() {
209 t.Skip("skipping test in short mode.")
210 }
211
212 n, batchN := 400000, 200000
213 ksize, vsize := 8, 500
214
215 db := btesting.MustCreateDB(t)
216
217 for i := 0; i < n; i += batchN {
218 if err := db.Update(func(tx *bolt.Tx) error {
219 b, err := tx.CreateBucketIfNotExists([]byte("widgets"))
220 if err != nil {
221 t.Fatal(err)
222 }
223 for j := 0; j < batchN; j++ {
224 k, v := make([]byte, ksize), make([]byte, vsize)
225 binary.BigEndian.PutUint32(k, uint32(i+j))
226 if err := b.Put(k, v); err != nil {
227 t.Fatal(err)
228 }
229 }
230 return nil
231 }); err != nil {
232 t.Fatal(err)
233 }
234 }
235}
236
237// Ensure that a setting a value on a key with a bucket value returns an error.
238func TestBucket_Put_IncompatibleValue(t *testing.T) {

Callers

nothing calls this directly

Calls 5

MustCreateDBFunction · 0.92
UpdateMethod · 0.80
FatalMethod · 0.65
PutMethod · 0.45

Tested by

no test coverage detected