Conversation
📝 WalkthroughWalkthroughAdds a new test Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
lib/shard/src/segment_holder/tests.rs (4)
6-6: Nit: avoid mixing fully-qualified and importedonly_default_vectorusage in the same fileThe new import brings
only_default_vectorinto scope, but most existing tests in this file still call it via the fully-qualified path. Consider unifying on one style for consistency (either keep the import and migrate older call sites later, or drop the import and use the fully-qualified path here).If you prefer to keep the existing style in this file, apply the following edits:
- use segment::data_types::vectors::{DEFAULT_VECTOR_NAME, VectorInternal, only_default_vector}; + use segment::data_types::vectors::{DEFAULT_VECTOR_NAME, VectorInternal};And in the new test (see suggested edit below in the relevant hunk), call
segment::data_types::vectors::only_default_vector(...)instead of the unqualified name.
613-621: Guard against accidental empty/extra proxies before indexingWe index
inner_proxies[0]directly. While the setup creates exactly one segment today, an explicit assertion improves failure diagnostics and prevents a panic if the setup changes.// check inner proxy contains points + assert_eq!(inner_proxies.len(), 1, "expected exactly one inner proxy"); let points = inner_proxies[0] .1 .get() .read() .read_range(Some(1.into()), None);
633-645: Minor clarity: use[0.0; 4]for vector construction (matches the rest of the file)Elsewhere in this file tests use the
[0.0; 4]shorthand. Using it here keeps the style consistent.Also see previous comment if you opt to keep fully-qualified calls to
only_default_vector.- .upsert_point( + .upsert_point( 100, 1.into(), - only_default_vector(&[0.0, 0.0, 0.0, 0.0]), + only_default_vector(&[0.0; 4]), &hw_counter, )If you choose the fully-qualified form for consistency with the rest of the file:
- only_default_vector(&[0.0; 4]), + segment::data_types::vectors::only_default_vector(&[0.0; 4]),
660-667: Strengthen the postcondition: verify the upserted point resides in the new segment onlyAsserting the presence of the newly appended segment is good. To make the test more robust (and closer to the bug’s behavioral contract), assert that:
- the new segment contains point
1, and- the original segment no longer contains point
1(deleted via the inner proxy and not reintroduced there).// Check that we have one new segment let diff: HashSet<_> = after_segment_ids.difference(&before_segment_ids).collect(); assert_eq!( diff.len(), 1, "There should be one new segment after unproxying" ); + + // Additionally, ensure point `1` moved to the new temp segment and is absent from the original + let &new_sid = diff.iter().next().expect("new segment id must exist"); + let &old_sid = before_segment_ids.iter().next().expect("original segment id must exist"); + let new_seg_read = holder.get(*new_sid).unwrap().get().read(); + assert!(new_seg_read.has_point(1.into()), "new segment should contain point 1 after upsert"); + drop(new_seg_read); + let old_seg_read = holder.get(old_sid).unwrap().get().read(); + assert!( + !old_seg_read.has_point(1.into()), + "original segment should not contain point 1 after delete" + );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
lib/shard/src/segment_holder/tests.rs(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-11T11:35:21.549Z
Learnt from: generall
PR: qdrant/qdrant#6854
File: lib/segment/src/index/query_estimator.rs:320-327
Timestamp: 2025-07-11T11:35:21.549Z
Learning: In test code for Qdrant's query estimator (lib/segment/src/index/query_estimator.rs), simplified ID resolution logic using `id.to_string().parse().unwrap()` is acceptable for testing purposes and doesn't need to match production code's `id_tracker.internal_id()` approach. Test code can use mock implementations that serve the testing goals.
Applied to files:
lib/shard/src/segment_holder/tests.rs
🧬 Code graph analysis (1)
lib/shard/src/segment_holder/tests.rs (3)
lib/segment/src/data_types/vectors.rs (1)
only_default_vector(471-473)lib/common/common/src/save_on_disk.rs (1)
load_or_init_default(38-43)lib/shard/src/segment_holder/mod.rs (3)
proxy_all_segments(1063-1139)unproxy_all_segments(1200-1264)len(99-101)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: rust-tests (windows-latest)
- GitHub Check: integration-tests-consensus
🔇 Additional comments (1)
lib/shard/src/segment_holder/tests.rs (1)
579-667: LGTM: solid regression test for nested proxy/unproxy with a single temp-segment appendThe scenario is clear: inner proxy receives a delete, outer proxy receives an upsert, then double unproxy asserts exactly one new segment ID. This should prevent regressions like the one fixed in #7109.
This test was used to detect the bug fixed by #7109
This PR proposes to keep the test to avoid regressions in the future.