Regression test for https://github.com/dgraph-io/dgraph/issues/5573
(t *testing.T)
| 781 | |
| 782 | // Regression test for https://github.com/dgraph-io/dgraph/issues/5573 |
| 783 | func TestDropPrefixMoveBug(t *testing.T) { |
| 784 | runBadgerTest(t, nil, func(t *testing.T, db *DB) { |
| 785 | // l1 is used to verify that drop prefix actually drops move keys from all the levels. |
| 786 | l1 := []keyValVersion{{string(append(badgerMove, "F"...)), "", 0, 0}} |
| 787 | createAndOpen(db, l1, 1) |
| 788 | |
| 789 | // Mutiple levels can have the exact same move key with version. |
| 790 | l2 := []keyValVersion{{string(append(badgerMove, "F"...)), "", 0, 0}, {"A", "", 0, 0}} |
| 791 | l21 := []keyValVersion{{"B", "", 0, 0}, {"C", "", 0, 0}} |
| 792 | l22 := []keyValVersion{{"F", "", 0, 0}, {"G", "", 0, 0}} |
| 793 | |
| 794 | // Level 2 has all the tables. |
| 795 | createAndOpen(db, l2, 2) |
| 796 | createAndOpen(db, l21, 2) |
| 797 | createAndOpen(db, l22, 2) |
| 798 | |
| 799 | require.NoError(t, db.lc.validate()) |
| 800 | require.NoError(t, db.DropPrefix([]byte("F"))) |
| 801 | |
| 802 | db.View(func(txn *Txn) error { |
| 803 | iopt := DefaultIteratorOptions |
| 804 | iopt.AllVersions = true |
| 805 | |
| 806 | it := txn.NewIterator(iopt) |
| 807 | defer it.Close() |
| 808 | |
| 809 | specialKey := []byte("F") |
| 810 | droppedPrefixes := [][]byte{specialKey, append(badgerMove, specialKey...)} |
| 811 | for it.Rewind(); it.Valid(); it.Next() { |
| 812 | key := it.Item().Key() |
| 813 | // Ensure we don't have any "F" or "!badger!move!F" left |
| 814 | require.False(t, hasAnyPrefixes(key, droppedPrefixes)) |
| 815 | } |
| 816 | return nil |
| 817 | }) |
| 818 | require.NoError(t, db.lc.validate()) |
| 819 | }) |
| 820 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…