Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mvcc/*_test.go: should not use duplicate revision.Main for one key #18321

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions server/storage/mvcc/key_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestKeyIndexGet(t *testing.T) {
// modified: 16
// generations:
// {empty}
// {{14, 0}[1], {14, 1}[2], {16, 0}(t)[3]}
// {{14, 0}[1], {15, 1}[2], {16, 0}(t)[3]}
// {{8, 0}[1], {10, 0}[2], {12, 0}(t)[3]}
// {{2, 0}[1], {4, 0}[2], {6, 0}(t)[3]}
ki := newTestKeyIndex(zaptest.NewLogger(t))
Expand All @@ -45,8 +45,8 @@ func TestKeyIndexGet(t *testing.T) {
{16, Revision{}, Revision{}, 0, ErrRevisionNotFound},

// get on generation 3
{15, Revision{Main: 14, Sub: 1}, Revision{Main: 14}, 2, nil},
{14, Revision{Main: 14, Sub: 1}, Revision{Main: 14}, 2, nil},
{15, Revision{Main: 15, Sub: 1}, Revision{Main: 14}, 2, nil},
{14, Revision{Main: 14}, Revision{Main: 14}, 1, nil},

{13, Revision{}, Revision{}, 0, ErrRevisionNotFound},
{12, Revision{}, Revision{}, 0, ErrRevisionNotFound},
Expand Down Expand Up @@ -97,7 +97,8 @@ func TestKeyIndexSince(t *testing.T) {
Revision{Main: 8},
Revision{Main: 10},
Revision{Main: 12},
Revision{Main: 14, Sub: 1},
Revision{Main: 14},
Revision{Main: 15, Sub: 1},
Revision{Main: 16},
}
tests := []struct {
Expand All @@ -106,7 +107,7 @@ func TestKeyIndexSince(t *testing.T) {
wrevs []Revision
}{
{17, nil},
{16, allRevs[6:]},
{16, allRevs[7:]},
{15, allRevs[6:]},
{14, allRevs[5:]},
{13, allRevs[5:]},
Expand Down Expand Up @@ -231,7 +232,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
generations: []generation{
{created: Revision{Main: 2}, ver: 3, revs: []Revision{Revision{Main: 2}, Revision{Main: 4}, Revision{Main: 6}}},
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 8}, Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -245,7 +246,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
generations: []generation{
{created: Revision{Main: 2}, ver: 3, revs: []Revision{Revision{Main: 2}, Revision{Main: 4}, Revision{Main: 6}}},
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 8}, Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -261,7 +262,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
generations: []generation{
{created: Revision{Main: 2}, ver: 3, revs: []Revision{Revision{Main: 2}, Revision{Main: 4}, Revision{Main: 6}}},
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 8}, Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -277,7 +278,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
generations: []generation{
{created: Revision{Main: 2}, ver: 3, revs: []Revision{Revision{Main: 4}, Revision{Main: 6}}},
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 8}, Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -293,7 +294,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
generations: []generation{
{created: Revision{Main: 2}, ver: 3, revs: []Revision{Revision{Main: 4}, Revision{Main: 6}}},
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 8}, Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -308,7 +309,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 8}, Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -321,7 +322,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 8}, Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -334,7 +335,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 8}, Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -349,7 +350,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 8}, Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -364,7 +365,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -379,7 +380,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 8}, ver: 3, revs: []Revision{Revision{Main: 10}, Revision{Main: 12}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -393,7 +394,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
key: []byte("foo"),
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -405,7 +406,7 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
key: []byte("foo"),
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
Expand All @@ -417,12 +418,12 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
key: []byte("foo"),
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14}, Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
map[Revision]struct{}{
Revision{Main: 14, Sub: 1}: {},
Revision{Main: 14}: {},
},
},
{
Expand All @@ -431,12 +432,12 @@ func TestKeyIndexCompactAndKeep(t *testing.T) {
key: []byte("foo"),
modified: Revision{Main: 16},
generations: []generation{
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 14, Sub: 1}, Revision{Main: 16}}},
{created: Revision{Main: 14}, ver: 3, revs: []Revision{Revision{Main: 15, Sub: 1}, Revision{Main: 16}}},
{},
},
},
map[Revision]struct{}{
Revision{Main: 14, Sub: 1}: {},
Revision{Main: 15, Sub: 1}: {},
},
},
{
Expand Down Expand Up @@ -692,7 +693,7 @@ func newTestKeyIndex(lg *zap.Logger) *keyIndex {
// modified: 16
// generations:
// {empty}
// {{14, 0}[1], {14, 1}[2], {16, 0}(t)[3]}
// {{14, 0}[1], {15, 1}[2], {16, 0}(t)[3]}
// {{8, 0}[1], {10, 0}[2], {12, 0}(t)[3]}
// {{2, 0}[1], {4, 0}[2], {6, 0}(t)[3]}

Expand All @@ -704,7 +705,7 @@ func newTestKeyIndex(lg *zap.Logger) *keyIndex {
ki.put(lg, 10, 0)
ki.tombstone(lg, 12, 0)
ki.put(lg, 14, 0)
ki.put(lg, 14, 1)
ki.put(lg, 15, 1)
ki.tombstone(lg, 16, 0)
return ki
}
Loading