-
Notifications
You must be signed in to change notification settings - Fork 253
add mockstore and rawkv tests #2
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
Conversation
Signed-off-by: disksing <i@disksing.com>
|
Please take a look if you have spare time. @sunxiaoguang |
Thanks, it's a good start for me to have better knowledge of it. |
|
|
||
| // valueDecoder decodes a mvcc value if iter key is expectKey. | ||
| func (dec *valueDecoder) Decode(iter *Iterator) (bool, error) { | ||
| if iter.Error() != nil || !iter.Valid() { |
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.
It seems the validation has already been checked outside of this function except
client-go/mockstore/mocktikv/mvcc_leveldb.go
Line 545 in 7a23d6e
| ok, err = dec1.Decode(iter) |
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.
Copied from tidb directly. /cc @tiancaiamao Do you have any ideas?
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.
There is a valid field here
client-go/mockstore/mocktikv/mvcc_leveldb.go
Line 125 in 7a23d6e
| valid bool |
If iter.valid is false, the Decode function should return as soon as possible. @rleungx
The code is copied, I recommend not to modify it in this PR, if any bug is found, use a separate one to fix it.
b.t.w, tikv/client will be moved from tidb to this repo later? @disksing
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.
Yes. That's exactly I'm working on.
Signed-off-by: disksing <i@disksing.com>
| // GetAllRegions gets all the regions in the cluster. | ||
| func (c *Cluster) GetAllRegions() []*Region { | ||
| regions := make([]*Region, 0, len(c.regions)) | ||
| for _, region := range c.regions { |
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.
Do we need RLock here?
mockstore/mocktikv/cluster.go
Outdated
| defer c.RUnlock() | ||
|
|
||
| r := c.regions[regionID] | ||
| if r == 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.
Maybe using if r, ok := c.regions[regionID]; !ok is better?
mockstore/mocktikv/cluster.go
Outdated
|
|
||
| func newRegion(regionID uint64, storeIDs, peerIDs []uint64, leaderPeerID uint64) *Region { | ||
| if len(storeIDs) != len(peerIDs) { | ||
| panic("len(storeIDs) != len(peerIds)") |
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.
peerIDs. BTW, is this a good panic message?
| @@ -0,0 +1,51 @@ | |||
| // Copyright 2016 PingCAP, Inc. | |||
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.
should change all licenses to 2019?
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.
No need to. The file is copied from tidb.
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.
Sadly, I have done the changes already in mock-tikv...
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.
I think it does not matter to change it or not to :)
|
Maybe is it better to port and merge at first, then do the improvement later? |
Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
* add mockstore and rawkv tests Signed-off-by: disksing <i@disksing.com>
*: init tenant cost client
* implement resolve lock Signed-off-by: you06 <you1474600@gmail.com> * remote comment code Signed-off-by: you06 <you1474600@gmail.com> * add license Signed-off-by: you06 <you1474600@gmail.com> * add test for gc shared lock Signed-off-by: you06 <you1474600@gmail.com> * address comment Signed-off-by: you06 <you1474600@gmail.com> --------- Signed-off-by: you06 <you1474600@gmail.com>
* *: add basic support for shared lock Signed-off-by: zyguan <zhongyangguan@gmail.com> * update kvproto Signed-off-by: zyguan <zhongyangguan@gmail.com> * make some minor updates Signed-off-by: zyguan <zhongyangguan@gmail.com> * add basic tests for LockKeys Signed-off-by: zyguan <zhongyangguan@gmail.com> * bump kvproto Signed-off-by: zyguan <zhongyangguan@gmail.com> * shared lock: support rollback/resolve, add tests (#2) * implement resolve lock Signed-off-by: you06 <you1474600@gmail.com> * remote comment code Signed-off-by: you06 <you1474600@gmail.com> * add license Signed-off-by: you06 <you1474600@gmail.com> * add test for gc shared lock Signed-off-by: you06 <you1474600@gmail.com> * address comment Signed-off-by: you06 <you1474600@gmail.com> --------- Signed-off-by: you06 <you1474600@gmail.com> * fix test (#3) Signed-off-by: you06 <you1474600@gmail.com> * txnkv: prevent shared locks from being resolved by accidently Signed-off-by: zyguan <zhongyangguan@gmail.com> --------- Signed-off-by: zyguan <zhongyangguan@gmail.com> Signed-off-by: you06 <you1474600@gmail.com> Co-authored-by: you06 <you1474600@gmail.com>
* *: add basic support for shared lock Signed-off-by: zyguan <zhongyangguan@gmail.com> * update kvproto Signed-off-by: zyguan <zhongyangguan@gmail.com> * make some minor updates Signed-off-by: zyguan <zhongyangguan@gmail.com> * add basic tests for LockKeys Signed-off-by: zyguan <zhongyangguan@gmail.com> * bump kvproto Signed-off-by: zyguan <zhongyangguan@gmail.com> * shared lock: support rollback/resolve, add tests (tikv#2) * implement resolve lock Signed-off-by: you06 <you1474600@gmail.com> * remote comment code Signed-off-by: you06 <you1474600@gmail.com> * add license Signed-off-by: you06 <you1474600@gmail.com> * add test for gc shared lock Signed-off-by: you06 <you1474600@gmail.com> * address comment Signed-off-by: you06 <you1474600@gmail.com> --------- Signed-off-by: you06 <you1474600@gmail.com> * fix test (tikv#3) Signed-off-by: you06 <you1474600@gmail.com> * txnkv: prevent shared locks from being resolved by accidently Signed-off-by: zyguan <zhongyangguan@gmail.com> --------- Signed-off-by: zyguan <zhongyangguan@gmail.com> Signed-off-by: you06 <you1474600@gmail.com> Co-authored-by: you06 <you1474600@gmail.com>
Signed-off-by: disksing i@disksing.com