add mockstore and rawkv tests#2
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.
It seems the validation has already been checked outside of this function except
client-go/mockstore/mocktikv/mvcc_leveldb.go
Line 545 in 7a23d6e
There was a problem hiding this comment.
Copied from tidb directly. /cc @tiancaiamao Do you have any ideas?
There was a problem hiding this comment.
There is a valid field here
client-go/mockstore/mocktikv/mvcc_leveldb.go
Line 125 in 7a23d6e
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.
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 { |
mockstore/mocktikv/cluster.go
Outdated
| defer c.RUnlock() | ||
|
|
||
| r := c.regions[regionID] | ||
| if r == nil { |
There was a problem hiding this comment.
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.
peerIDs. BTW, is this a good panic message?
| @@ -0,0 +1,51 @@ | |||
| // Copyright 2016 PingCAP, Inc. | |||
There was a problem hiding this comment.
should change all licenses to 2019?
There was a problem hiding this comment.
No need to. The file is copied from tidb.
There was a problem hiding this comment.
Sadly, I have done the changes already in mock-tikv...
There was a problem hiding this comment.
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