tests: Add unittest about tagging under disagg arch#10759
tests: Add unittest about tagging under disagg arch#10759JaySon-Huang wants to merge 2 commits intopingcap:masterfrom
Conversation
Signed-off-by: JaySon-Huang <tshent@qq.com>
|
Review Complete Findings: 1 issues ℹ️ Learn more details on Pantheon AI. |
📝 WalkthroughWalkthroughMultiple test files now conditionally delete S3 buckets only when a mocked S3 client is present. A new S3 object tagging utility function is introduced alongside a corresponding test case. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can disable the changed files summary in the walkthrough.Disable the |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
dbms/src/Storages/S3/S3Common.cpp (1)
829-844: Implementation is correct.The function properly follows the error handling pattern used by other S3 helper functions.
For consistency with other S3 operations in this file (e.g.,
rewriteObjectWithTagging,headObject), consider adding metrics/observability if this function will be used in production paths. Currently, since it's only used in tests, this is optional.♻️ Optional: Add observability for production use
Aws::S3::Model::GetObjectTaggingResult getObjectTagging(const TiFlashS3Client & client, const String & key) { + Stopwatch sw; Aws::S3::Model::GetObjectTaggingRequest req; client.setBucketAndKeyWithRoot(req, key); auto outcome = client.GetObjectTagging(req); if (!outcome.IsSuccess()) { throw fromS3Error( outcome.GetError(), "S3 GetObjectTagging failed, bucket={} root={} key={}", client.bucket(), client.root(), key); } + GET_METRIC(tiflash_storage_s3_request_seconds, type_get_object_tagging).Observe(sw.elapsedSeconds()); return outcome.GetResult(); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dbms/src/Storages/S3/S3Common.cpp` around lines 829 - 844, getObjectTagging is implemented correctly but lacks observability; wrap the Aws::S3::Model::GetObjectTaggingRequest call in the same metrics pattern used by other S3 helpers (e.g., record latency and increment success/failure counters), instrument around client.GetObjectTagging in getObjectTagging, label metrics with client.bucket(), client.root() and key, and ensure failures still throw via fromS3Error while emitting the failure metric.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@dbms/src/Storages/S3/S3Common.cpp`:
- Around line 829-844: getObjectTagging is implemented correctly but lacks
observability; wrap the Aws::S3::Model::GetObjectTaggingRequest call in the same
metrics pattern used by other S3 helpers (e.g., record latency and increment
success/failure counters), instrument around client.GetObjectTagging in
getObjectTagging, label metrics with client.bucket(), client.root() and key, and
ensure failures still throw via fromS3Error while emitting the failure metric.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e33f4aac-a190-4a79-9b47-c6e5ededd60b
📒 Files selected for processing (14)
dbms/src/IO/Encryption/tests/gtest_keyspaces_key_manager.cppdbms/src/Storages/DeltaMerge/File/tests/gtest_dm_meta_version.cppdbms/src/Storages/DeltaMerge/Index/InvertedIndex/tests/gtest_dm_inverted_index.cppdbms/src/Storages/DeltaMerge/Index/VectorIndex/tests/gtest_dm_vector_index.cppdbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_fast_add_peer.cppdbms/src/Storages/DeltaMerge/tests/gtest_dm_segment_s3.cppdbms/src/Storages/DeltaMerge/tests/gtest_segment_replace_stable_data.cppdbms/src/Storages/KVStore/tests/gtest_kvstore_fast_add_peer.cppdbms/src/Storages/Page/V3/Universal/tests/gtest_lock_local_mgr.cppdbms/src/Storages/Page/V3/Universal/tests/gtest_remote_read.cppdbms/src/Storages/S3/S3Common.cppdbms/src/Storages/S3/S3Common.hdbms/src/Storages/S3/tests/gtest_s3client.cppdbms/src/Storages/S3/tests/gtest_s3gcmanager.cpp
| @@ -314,8 +320,11 @@ try | |||
|
|
|||
| auto timepoint = Aws::Utils::DateTime("2023-02-01T08:00:00Z", Aws::Utils::DateFormat::ISO_8601); | |||
| auto clear_bucket = [&] { | |||
There was a problem hiding this comment.
[P2] Test becomes incorrect when running with real S3 (MOCK_S3=false)
Why: The introduced change makes clear_bucket() a no-op in non-mocked mode, so test subcases deterministically reuse prior S3 state and can fail/flake.
Evidence: At line 322, clear_bucket only deletes/recreates the bucket when isMockedS3Client() is true. Later, the same test has subcases that assert delmark created (line 342) then assert delmark not created (line 357) using the same key, causing the second assertion to fail when state carries over from the first subcase.
Fix: Either skip these multi-scenario tests when !isMockedS3Client() using GTEST_SKIP(), or implement non-destructive per-key/prefix cleanup so clear_bucket() resets state without requiring DeleteBucket.
What problem does this PR solve?
Issue Number: ref #6233
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note
Summary by CodeRabbit
Release Notes
New Features
Tests