MCPcopy
hub / github.com/dgraph-io/badger / TestExistsMore

Function TestExistsMore

db_test.go:584–658  ·  view source on GitHub ↗

Put a lot of data to move some data to disk. WARNING: This test might take a while but it should pass!

(t *testing.T)

Source from the content-addressed store, hash-verified

582// Put a lot of data to move some data to disk.
583// WARNING: This test might take a while but it should pass!
584func TestExistsMore(t *testing.T) {
585 test := func(t *testing.T, db *DB) {
586 // n := 500000
587 n := 10000
588 m := 45
589 for i := 0; i < n; i += m {
590 if (i % 1000) == 0 {
591 t.Logf("Putting i=%d\n", i)
592 }
593 txn := db.NewTransaction(true)
594 for j := i; j < i+m && j < n; j++ {
595 require.NoError(t, txn.SetEntry(NewEntry([]byte(fmt.Sprintf("%09d", j)),
596 []byte(fmt.Sprintf("%09d", j)))))
597 }
598 require.NoError(t, txn.Commit())
599 }
600 db.validate()
601
602 for i := 0; i < n; i++ {
603 if (i % 1000) == 0 {
604 fmt.Printf("Testing i=%d\n", i)
605 }
606 k := fmt.Sprintf("%09d", i)
607 require.NoError(t, db.View(func(txn *Txn) error {
608 _, err := txn.Get([]byte(k))
609 require.NoError(t, err)
610 return nil
611 }))
612 }
613 require.NoError(t, db.View(func(txn *Txn) error {
614 _, err := txn.Get([]byte("non-exists"))
615 require.Error(t, err)
616 return nil
617 }))
618
619 // "Delete" key.
620 for i := 0; i < n; i += m {
621 if (i % 1000) == 0 {
622 fmt.Printf("Deleting i=%d\n", i)
623 }
624 txn := db.NewTransaction(true)
625 for j := i; j < i+m && j < n; j++ {
626 require.NoError(t, txn.Delete([]byte(fmt.Sprintf("%09d", j))))
627 }
628 require.NoError(t, txn.Commit())
629 }
630 db.validate()
631 for i := 0; i < n; i++ {
632 if (i % 10000) == 0 {
633 // Display some progress. Right now, it's not very fast with no caching.
634 fmt.Printf("Testing i=%d\n", i)
635 }
636 k := fmt.Sprintf("%09d", i)
637
638 require.NoError(t, db.View(func(txn *Txn) error {
639 _, err := txn.Get([]byte(k))
640 require.Error(t, err)
641 return nil

Callers

nothing calls this directly

Calls 15

NewEntryFunction · 0.85
runBadgerTestFunction · 0.85
DefaultOptionsFunction · 0.85
OpenFunction · 0.85
NewTransactionMethod · 0.80
CommitMethod · 0.80
PrintfMethod · 0.80
ViewMethod · 0.80
WithInMemoryMethod · 0.80
CloseMethod · 0.65
SetEntryMethod · 0.45
validateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…