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(test): refactor some ut for hummock #18534

Merged
merged 6 commits into from
Sep 14, 2024
Merged

refactor(test): refactor some ut for hummock #18534

merged 6 commits into from
Sep 14, 2024

Conversation

Li0k
Copy link
Contributor

@Li0k Li0k commented Sep 13, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

  1. fix the commit_epoch func of MockHumockMetaClient
  2. introduce table_ids for seal_and_sync_epoch (So we can then create table_state_info and compaction_group on demand via commit_epoch.)
  3. Rewrote ut with a new interface to better cover the commit_epoch logic.
  4. Removed some unreasonable test logic and hard code to make it more scalable.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Copy link
Collaborator

@hzxa21 hzxa21 left a comment

Choose a reason for hiding this comment

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

Rest LGTM!

src/meta/src/hummock/mock_hummock_meta_client.rs Outdated Show resolved Hide resolved
@@ -207,20 +215,22 @@ async fn test_hummock_compaction_task() {
StaticCompactionGroupId::StateDefault.into(),
)
.await;
commit_from_meta_node(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for cleaning this up. I just realize that there are many variants of commit epoch calls in UT and their implementations are using magic numbers.

Comment on lines 2305 to 2311
let epoch = test_epoch(1);
let table_key_l = gen_key_from_str(VirtualNode::from_index(1), "1");
let table_key_r = gen_key_from_str(VirtualNode::from_index(128), "1");
let full_key_l = FullKey::for_test(TableId::new(100), table_key_l, epoch).encode();
let full_key_r = FullKey::for_test(TableId::new(101), table_key_r, epoch).encode();
sst_1.sst_info.key_range.left = full_key_l.into();
sst_1.sst_info.key_range.right = full_key_r.into();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the reason why we modify the key range here is because gen_local_sstable_info (more accurately gen_sstable_info) is filling the key range with iterator_test_key_of_epoch(1, idx, 1), which doesn't aligh with the provided table_ids. Is it possible to change the implementation of gen_sstable_info to fill in the correct key range based on table_ids? We can have a util function similar to the logic here to generate valid full key range based on provided table_ids.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I've fixed this logic in a new commit, so let's change it step by step. I even found some uts that relied on this wrong key_range to pass check, so I'm determined to change it .....

assert_eq!(0, output_level_info.total_file_size);

// 5. get compact task
let compact_task = hummock_manager_ref
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we remove this final check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After review the test semantics, I decided that using the get compact task to determine whether the data was cleaned or not was not necessary, so I went from using a simpler test case

@Li0k Li0k added this pull request to the merge queue Sep 14, 2024
Merged via the queue into main with commit ac966f1 Sep 14, 2024
30 of 31 checks passed
@Li0k Li0k deleted the li0k/refactor_ut branch September 14, 2024 08:34
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.

2 participants