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

Refactor KVStore/RegionPersister test #5679

Merged
merged 6 commits into from
Aug 23, 2022

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Aug 22, 2022

What problem does this PR solve?

Issue Number: ref #5170

Problem Summary:
It is hard to write unit test cases for KVStore.
And it run tests on the KVStore instance in global context, which makes it hard to test logic of restoring data from disk

What is changed and how it works?

  • Explicitly send PathPool instance to KVStore::restore by param
    • We can create a KVStore/RegionPersister instance for testing other than testing the KVStore instance in global context
    • Get a clearer order of initialization between PathPool and KVStore in Server.cpp
  • Rewrite the RegionPersisterTest
  • Use DBMS_PUBLIC_GTEST instead of friend class to write tests on RegionKVStoreTest

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 22, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CalvinNeo
  • lidezhu

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 22, 2022
Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 22, 2022
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@JaySon-Huang JaySon-Huang changed the title [WIP] Refactor kvstore test Refactor KVStore/RegionPersister test Aug 23, 2022
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 23, 2022
@JaySon-Huang JaySon-Huang self-assigned this Aug 23, 2022
@JaySon-Huang
Copy link
Contributor Author

/cc @lidezhu

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 23, 2022
Signed-off-by: JaySon-Huang <[email protected]>
@JaySon-Huang
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@JaySon-Huang: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 29e4368

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 23, 2022
Signed-off-by: JaySon-Huang <[email protected]>
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Aug 23, 2022
@JaySon-Huang
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@JaySon-Huang: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: ddf492a

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 23, 2022
@sre-bot
Copy link
Collaborator

sre-bot commented Aug 23, 2022

Coverage for changed files

Filename                                                  Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Debug/MockSSTReader.h                                           9                 6    33.33%           9                 6    33.33%           9                 6    33.33%           0                 0         -
Debug/dbgFuncMockRaftSnapshot.cpp                             174               170     2.30%          23                21     8.70%         553               532     3.80%         118               117     0.85%
Server/DTTool/DTTool.h                                          5                 5     0.00%           5                 5     0.00%          45                45     0.00%           0                 0         -
Server/tests/gtest_server_config.cpp                          241                36    85.06%          10                 0   100.00%         408                 3    99.26%          58                26    55.17%
Storages/Transaction/KVStore.cpp                              499                55    88.98%          43                 3    93.02%         685                83    87.88%         188                57    69.68%
Storages/Transaction/KVStore.h                                  5                 3    40.00%           5                 3    40.00%           5                 3    40.00%           0                 0         -
Storages/Transaction/Region.h                                  20                 2    90.00%          10                 2    80.00%          28                 2    92.86%          14                 4    71.43%
Storages/Transaction/RegionMeta.h                               1                 0   100.00%           1                 0   100.00%           7                 0   100.00%           0                 0         -
Storages/Transaction/RegionPersister.cpp                      182                95    47.80%          16                 3    81.25%         301               122    59.47%          72                35    51.39%
Storages/Transaction/TMTContext.cpp                            55                39    29.09%          33                18    45.45%         145                98    32.41%          10                 9    10.00%
Storages/Transaction/TMTContext.h                               3                 2    33.33%           3                 2    33.33%           3                 2    33.33%           0                 0         -
Storages/Transaction/tests/gtest_kvstore.cpp                  266                 7    97.37%          29                 2    93.10%        1312                34    97.41%           4                 0   100.00%
Storages/Transaction/tests/gtest_region_persister.cpp         183                53    71.04%          14                 0   100.00%         283                 4    98.59%          56                33    41.07%
TestUtils/TiFlashTestEnv.cpp                                   31                 4    87.10%           4                 0   100.00%          69                 9    86.96%          14                 6    57.14%
TestUtils/TiFlashTestEnv.h                                     27                 3    88.89%           6                 0   100.00%          51                 5    90.20%          18                 3    83.33%
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                        1701               480    71.78%         211                65    69.19%        3904               948    75.72%         552               290    47.46%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18415      8330             54.77%    212652  86002        59.56%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit 4ec074b into pingcap:master Aug 23, 2022
@JaySon-Huang JaySon-Huang deleted the refact_kvstore_test branch August 23, 2022 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants