-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
kv: fix err check #22994
kv: fix err check #22994
Changes from 6 commits
44f00eb
1ae12d2
bc4b8b5
1da106c
7e92743
37654dc
8c8794b
4aeb557
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,8 @@ func (s testMemDBSuite) TestRandom(c *C) { | |
p1 := newMemDB() | ||
p2 := leveldb.New(comparer.DefaultComparer, 4*1024) | ||
for _, k := range keys { | ||
p1.Set(k, k) | ||
err := p1.Set(k, k) | ||
c.Assert(err, IsNil) | ||
_ = p2.Put(k, k) | ||
} | ||
|
||
|
@@ -50,11 +51,13 @@ func (s testMemDBSuite) TestRandom(c *C) { | |
op := rand.Float64() | ||
if op < 0.35 { | ||
p1.DeleteKey(k) | ||
p2.Delete(k) | ||
// to fix: delete key not found | ||
_ = p2.Delete(k) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tiancaiamao There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it does not need to be so strict, there is already |
||
} else { | ||
newValue := make([]byte, rand.Intn(19)+1) | ||
rand.Read(newValue) | ||
p1.Set(k, newValue) | ||
err := p1.Set(k, newValue) | ||
c.Assert(err, IsNil) | ||
_ = p2.Put(k, newValue) | ||
} | ||
} | ||
|
@@ -102,14 +105,16 @@ func (s testMemDBSuite) testRandomDeriveRecur(c *C, db *MemDB, golden *leveldb.D | |
h := db.Staging() | ||
opLog := make([][2][]byte, 0, len(keys)) | ||
for i := range keys { | ||
db.Set(keys[i], vals[i]) | ||
err := db.Set(keys[i], vals[i]) | ||
c.Assert(err, IsNil) | ||
old, err := golden.Get(keys[i]) | ||
if err != nil { | ||
opLog = append(opLog, [2][]byte{keys[i], nil}) | ||
} else { | ||
opLog = append(opLog, [2][]byte{keys[i], old}) | ||
} | ||
golden.Put(keys[i], vals[i]) | ||
err = golden.Put(keys[i], vals[i]) | ||
c.Assert(err, IsNil) | ||
} | ||
|
||
if depth < 2000 { | ||
|
@@ -121,9 +126,11 @@ func (s testMemDBSuite) testRandomDeriveRecur(c *C, db *MemDB, golden *leveldb.D | |
db.Cleanup(h) | ||
for i := len(opLog) - 1; i >= 0; i-- { | ||
if opLog[i][1] == nil { | ||
golden.Delete(opLog[i][0]) | ||
err := golden.Delete(opLog[i][0]) | ||
c.Assert(err, IsNil) | ||
} else { | ||
golden.Put(opLog[i][0], opLog[i][1]) | ||
err := golden.Put(opLog[i][0], opLog[i][1]) | ||
c.Assert(err, IsNil) | ||
} | ||
} | ||
opLog = nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL @tiancaiamao
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code just check the API interface, even if here returns an error, it doesn't matter.