-
Notifications
You must be signed in to change notification settings - Fork 118
Description
Feature Request
The code coverage of client-java is insufficient. Planty of code logic can be only covered by the internal integration tests without more granular unit tests. There is a pull request: #518 on the way that is trying to increase the coverage of the retry logic of RawKVClient. However, this is not enough, we still get plenty of TODOs.
Including:
- UT for
AbstractRegionStoreClient - UT for
RegionErrorHandler - UT for
Backoffer
These may introduce us a more important problem: build a scalable mock server for TiKV and PD:
- Refactor the
KVMockServerandPDMockServer, make it more easy to use and cover more errors.- Mock long request relay.
- Mock returning specific region errors.
- Mock region scheduling.
For now, PDMockServer is partially refactored by #518. It supports registering callbacks for gRPC service methods. Just like:
leader.addGetRegionListener(
request ->
GrpcUtils.makeGetRegionResponse(
leader.getClusterId(),
GrpcUtils.makeRegion(
1,
ByteString.copyFrom(startKey),
ByteString.copyFrom(endKey),
GrpcUtils.makeRegionEpoch(confVer, ver),
GrpcUtils.makePeer(1, 10),
GrpcUtils.makePeer(2, 20))));When a getRegion RPC is made, the callback will be triggered.
This design might make it more flexible to mock everything the test caller need but may result in more repeat some "server"'s code in the tests. We might need to discuss if this design could fit our needs. If it does, the same refactoring could be applied to KVMockServer.