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

[to #439] introduce MockThreeStoresTest to onStoreUnreachable #518

Merged
merged 19 commits into from
Feb 21, 2022

Conversation

iosmanthus
Copy link
Member

@iosmanthus iosmanthus commented Feb 14, 2022

Signed-off-by: iosmanthus myosmanthustree@gmail.com

What problem does this PR solve?

Issue Number: close #439

This pull request tries to mock a TiKV grpc server and cover the error handling logic of client-java, mostly, the logic of seekLeaderStore and seekProxyStore in handleRequestError.

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@iosmanthus iosmanthus changed the title [to #439] [WIP] introduce MockThreeStoresTest to test seek leader store [to #439] introduce MockThreeStoresTest to test seek leader store Feb 16, 2022
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@@ -166,6 +178,10 @@ private static VersionInfo getVersionInfo() {
}

private synchronized void warmUp() {
if (conf.isTest()) {
logger.info("skip warm up in test mode");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why skip warmup in test mode?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. PDMockServerTest is the base class of MockServerTest.
  2. TiSession is initialized in PDMockServerTest, and it calls warmup.
  3. warmup calls getAllStores and rawGet.

This results in a dependent hell. We should ignore this anti-pattern warmup operation in TiSession, otherwise, we could not launch MockServerTest propperly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignored warmup by setEnableWarmup(false)

@@ -97,7 +124,7 @@ private void verifyContext(Context context) throws Exception {
if (context.getRegionId() != region.getId()
|| !context.getRegionEpoch().equals(region.getRegionEpoch())
|| !context.getPeer().equals(region.getLeader())) {
throw new Exception();
throw new Exception("context doesn't match");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to specifically point out the mismatched field in context.

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
src/test/java/org/tikv/common/MockThreeStoresTest.java Outdated Show resolved Hide resolved
@@ -40,6 +40,7 @@
import org.tikv.kvproto.Metapb.Region;

public class TiRegion implements Serializable {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do code format in another PR

import org.tikv.kvproto.Metapb;
import org.tikv.kvproto.Pdpb;

public class MockThreeStoresTest extends PDMockServerTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename MockThreeStoresTest to MockTiKVClusterTest?
The store number can be config?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to keep it simple enough, for now, refactoring will be introduced in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create an issue to describe this refactoring?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could I just add some comments to this class?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@iosmanthus iosmanthus mentioned this pull request Feb 17, 2022
7 tasks
@iosmanthus iosmanthus linked an issue Feb 17, 2022 that may be closed by this pull request
7 tasks
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@iosmanthus iosmanthus changed the title [to #439] introduce MockThreeStoresTest to test seek leader store [to #439] introduce MockThreeStoresTest to onStoreUnreachable Feb 17, 2022
iosmanthus and others added 6 commits February 17, 2022 19:41
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #518 (fe21429) into master (2ac49bb) will increase coverage by 0.95%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #518      +/-   ##
============================================
+ Coverage     30.94%   31.90%   +0.95%     
- Complexity     1282     1311      +29     
============================================
  Files           278      278              
  Lines         17343    17344       +1     
  Branches       1975     1975              
============================================
+ Hits           5367     5533     +166     
+ Misses        11387    11192     -195     
- Partials        589      619      +30     
Impacted Files Coverage Δ
src/main/java/org/tikv/common/TiSession.java 71.15% <ø> (+0.48%) ⬆️
src/main/java/org/tikv/common/region/TiRegion.java 60.34% <ø> (+9.48%) ⬆️
.../tikv/common/region/AbstractRegionStoreClient.java 78.04% <100.00%> (+62.36%) ⬆️
.../java/org/tikv/common/exception/GrpcException.java 33.33% <0.00%> (-33.34%) ⬇️
.../java/org/tikv/common/exception/TiKVException.java 66.66% <0.00%> (-33.34%) ⬇️
...ty/handler/codec/http2/Http2ConnectionHandler.java 51.10% <0.00%> (-3.92%) ⬇️
.../main/java/org/tikv/common/policy/RetryPolicy.java 85.18% <0.00%> (-3.71%) ⬇️
.../codec/http2/DefaultHttp2RemoteFlowController.java 59.31% <0.00%> (-0.39%) ⬇️
src/main/java/org/tikv/common/PDClient.java 59.56% <0.00%> (ø)
src/main/java/org/tikv/common/TiConfiguration.java 65.98% <0.00%> (+0.20%) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ac49bb...fe21429. Read the comment docs.

Copy link
Collaborator

@marsishandsome marsishandsome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason zz-jason merged commit d24b8e9 into tikv:master Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mock server plan Using MockTiKV to do unit test
4 participants