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

Fix broken unit test for --gtest_filter='*StorageDeltaMergeTest*:*RegionKVStoreTest*' #4903

Merged
merged 3 commits into from
May 30, 2022

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented May 16, 2022

What problem does this PR solve?

Issue Number: close #4904

Problem Summary:

RegionKVStoreTest will try to decode data for table id == 1. But the schema of tests in RegionKVStoreTest does not match that we created in StorageDeltaMergeTest.ReadExtraPhysicalTableID.

./gtests_dbms --gtest_filter='*StorageDeltaMergeTest*:*RegionKVStoreTest*'

Note: Google Test filter = *StorageDeltaMergeTest*:*RegionKVStoreTest*
[==========] Running 6 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 5 tests from StorageDeltaMergeTest
[ RUN      ] StorageDeltaMergeTest.ReadWriteCase1
...
[       OK ] StorageDeltaMergeTest.RestoreAfterClearData (624 ms)
[----------] 5 tests from StorageDeltaMergeTest (835 ms total)

[----------] 1 test from RegionKVStoreTest
[ RUN      ] RegionKVStoreTest.run
...
[2022/05/16 17:35:35.065 +08:00] [INFO] [Region.cpp:189] ["Region:[region 1] split into [region 7, index 5, table 1, ver 7, conf_ver 0, state Normal, peer ] [region 1, index 20, table 1, ver 7, conf_ver 0, state Normal, peer id: 2]"] [thread_id=1]
[2022/05/16 17:35:35.065 +08:00] [INFO] [RegionTable.cpp:44] ["RegionTable:get new table 1"] [thread_id=1]
[2022/05/16 17:35:35.065 +08:00] [TRACE] [RegionTable.cpp:122] ["RegionTable:table 1, [region 7] original 79 bytes"] [thread_id=1]
[2022/05/16 17:35:35.065 +08:00] [TRACE] [PartitionStreams.cpp:121] ["RegionTable:writeRegionDataToStorage begin to decode table 1, region 7"] [thread_id=1]
unknown file: Failure
C++ exception with description "unordered_map::at: key not found" thrown in the test body.
[  FAILED  ] RegionKVStoreTest.run (39 ms)
[----------] 1 test from RegionKVStoreTest (39 ms total)

[----------] Global test environment tear-down
[==========] 6 tests from 2 test cases ran. (874 ms total)
[  PASSED  ] 5 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] RegionKVStoreTest.run

What is changed and how it works?

  • Remove some useless configs for running mock tests / fullstack tests
  • Calling storage->removeFromTMTContext() after being dropped as we do in InterpreterDropQuery
    /// Clear storage data first, and if tiflash crash in the middle of `clearData`,
    /// this table can still be restored, and can call `clearData` again.
    table.first->clearData();
    /// Delete table metdata and table itself from memory
    database->removeTable(context, current_table_name);
    SCOPE_EXIT({
    // Once the storage's metadata removed from disk, we should ensure that it is removed from TMTStorages
    if (auto storage = std::dynamic_pointer_cast<IManageableStorage>(table.first); storage)
    storage->removeFromTMTContext();
    });
    FAIL_POINT_TRIGGER_EXCEPTION(FailPoints::exception_between_drop_meta_and_data);
    /// Delete table data
    table.first->drop();
    table.first->is_dropped = true;

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 May 16, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • hehechen
  • 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 release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels May 16, 2022
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@JaySon-Huang JaySon-Huang changed the title Fix broken unit test for --gtest_filter='*StorageDeltaMergeTest*:RegionKVStoreTest.KVStore' Fix broken unit test for --gtest_filter='*StorageDeltaMergeTest*:*RegionKVStoreTest*' May 16, 2022
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 16, 2022
@sre-bot
Copy link
Collaborator

sre-bot commented May 16, 2022

Coverage for changed files

Filename                                              Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DeltaMerge/tests/gtest_dm_storage_delta_merge.cpp        1770               351    80.17%          18                 0   100.00%         729                12    98.35%         564               267    52.66%
Transaction/tests/gtest_kvstore.cpp                      3753               730    80.55%          27                 2    92.59%        1240                30    97.58%        1114               589    47.13%
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                    5523              1081    80.43%          45                 2    95.56%        1969                42    97.87%        1678               856    48.99%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18153      9790             46.07%    202800  98064        51.64%

full coverage report (for internal network access only)

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented May 30, 2022

Coverage for changed files

Filename                                              Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DeltaMerge/tests/gtest_dm_storage_delta_merge.cpp        1770               351    80.17%          18                 0   100.00%         734                12    98.37%         564               267    52.66%
Transaction/tests/gtest_kvstore.cpp                      3753               730    80.55%          27                 2    92.59%        1240                30    97.58%        1114               589    47.13%
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                    5523              1081    80.43%          45                 2    95.56%        1974                42    97.87%        1678               856    48.99%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18294      9795             46.46%    204949  98174        52.10%

full coverage report (for internal network access only)

Copy link
Contributor

@lidezhu lidezhu 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 status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 30, 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: 4988be5

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

sre-bot commented May 30, 2022

Coverage for changed files

Filename                                              Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DeltaMerge/tests/gtest_dm_storage_delta_merge.cpp        1770               351    80.17%          18                 0   100.00%         734                12    98.37%         564               267    52.66%
Transaction/tests/gtest_kvstore.cpp                      3753               730    80.55%          27                 2    92.59%        1240                30    97.58%        1114               589    47.13%
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                    5523              1081    80.43%          45                 2    95.56%        1974                42    97.87%        1678               856    48.99%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18294      9796             46.45%    204949  98224        52.07%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit 580821a into pingcap:master May 30, 2022
@JaySon-Huang JaySon-Huang deleted the fix_ut branch May 31, 2022 03:09
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/L Denotes a PR that changes 100-499 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.

The unit test fail when we run with --gtest_filter='*StorageDeltaMergeTest*:*RegionKVStoreTest*'
5 participants