Skip to content

Improve diskann-disk test coverage#1193

Open
arrayka wants to merge 7 commits into
mainfrom
u/arrayka/diskann-disk-tests3
Open

Improve diskann-disk test coverage#1193
arrayka wants to merge 7 commits into
mainfrom
u/arrayka/diskann-disk-tests3

Conversation

@arrayka

@arrayka arrayka commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Adds 18 targeted unit tests to the diskann-disk crate covering previously
untested error paths, control flow branches, and pure functions.

Files with missing lines
Coverage Δ
.../checkpoint/checkpoint_record_manager_with_file.rs
96.20% <100.00%> (+1.81%)
diskann-disk/src/search/pq/pq_scratch.rs
100.00% <100.00%> (+10.00%)
...kann-disk/src/search/provider/disk_sector_graph.rs
97.70% <100.00%> (+0.75%)
diskann-disk/src/storage/quant/generator.rs
94.31% <100.00%> (+1.64%)
diskann-disk/src/utils/kmeans.rs
96.61% <100.00%> (+5.62%)
diskann-disk/src/utils/partition.rs
92.85% <100.00%> (+0.34%)
...kann-disk/src/build/chunking/continuation/utils.rs
93.90% <97.87%> (+3.61%)

Add 18 targeted unit tests covering previously untested error paths,
control flow branches, and pure functions across 7 files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.31741% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.86%. Comparing base (999fa5d) to head (f62eb83).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...kann-disk/src/build/chunking/continuation/utils.rs 97.87% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1193      +/-   ##
==========================================
- Coverage   89.95%   89.86%   -0.09%     
==========================================
  Files         489      488       -1     
  Lines       93127    93602     +475     
==========================================
+ Hits        83772    84118     +346     
- Misses       9355     9484     +129     
Flag Coverage Δ
miri 89.86% <99.31%> (-0.09%) ⬇️
unittests 89.52% <99.31%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../checkpoint/checkpoint_record_manager_with_file.rs 96.20% <100.00%> (+1.81%) ⬆️
diskann-disk/src/search/pq/pq_scratch.rs 100.00% <100.00%> (+10.00%) ⬆️
...kann-disk/src/search/provider/disk_sector_graph.rs 97.70% <100.00%> (+0.75%) ⬆️
diskann-disk/src/storage/quant/generator.rs 94.33% <100.00%> (+1.65%) ⬆️
diskann-disk/src/utils/kmeans.rs 96.61% <100.00%> (+5.62%) ⬆️
diskann-disk/src/utils/partition.rs 92.85% <100.00%> (+0.34%) ⬆️
...kann-disk/src/build/chunking/continuation/utils.rs 93.90% <97.87%> (+3.61%) ⬆️

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@arrayka arrayka marked this pull request as ready for review June 20, 2026 01:09
@arrayka arrayka requested review from a team and Copilot June 20, 2026 01:09
@arrayka arrayka enabled auto-merge (squash) June 20, 2026 01:09
@arrayka arrayka changed the title Improve diskann-disk test coverage: 94.4% → 95.0% Improve diskann-disk test coverage Jun 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR increases unit test coverage in the diskann-disk crate by adding targeted tests for previously untested branches and error paths across utilities, PQ scratch handling, sector graph reconfiguration, quantization generator validation, continuation helpers, and checkpoint record management.

Changes:

  • Add unit tests for partition-count estimation edge cases (clamping, odd rounding, k_base multiplier).
  • Add tests covering error-path and basic-success behavior in k-means clustering, PQScratch query validation, quant generator parameter validation, sector graph reconfiguration/defaulting, continuation processing behavior, and checkpoint invalidation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
diskann-disk/src/utils/partition.rs Adds tests for estimate_initial_partition_count edge cases.
diskann-disk/src/utils/kmeans.rs Adds tests for successful clustering output shape and cancellation error path.
diskann-disk/src/storage/quant/generator.rs Adds test for missing compressed-file validation when resuming with offset.
diskann-disk/src/search/provider/disk_sector_graph.rs Adds tests for reconfigure growth/no-op and block-size defaulting.
diskann-disk/src/search/pq/pq_scratch.rs Adds tests for rejecting undersized queries and accepting oversized queries.
diskann-disk/src/build/chunking/continuation/utils.rs Adds tests for early stop, yield-then-continue, and error propagation (sync/async).
diskann-disk/src/build/chunking/checkpoint/checkpoint_record_manager_with_file.rs Adds tests for fresh-state behavior, missing-file completion state, and invalidation semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread diskann-disk/src/search/pq/pq_scratch.rs
Comment thread diskann-disk/src/storage/quant/generator.rs Outdated
Comment thread diskann-disk/src/build/chunking/continuation/utils.rs
Comment thread diskann-disk/src/search/pq/pq_scratch.rs

@arkrishn94 arkrishn94 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks Alex! Looks good to me.

manager_b.get_resumption_point(WorkStage::Start)?
);
// A different identifier should be independent
let manager_c = CheckpointRecordManagerWithFileStorage::new(&index_prefix, 99);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's unclear to me how this asserts independence from a and b like the comment states.

.to_str()
.unwrap()
.to_string();
let manager = CheckpointRecordManagerWithFileStorage::new(&index_prefix, 999);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This appears to be the identical test to the last thing above?

Some(0)
);

clean_checkpoint_file(&index_prefix, identifier);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's not a big deal, but part of point of tempdir() is that the object returned cleans up after itself on drop. This kind of clean is only really needed if you were doing multiple things in the same tempdir and wanted to clean in between.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Box::new(tracker),
);

assert!(result.is_ok());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line is redundant with the next one. If you match on result.unwrap() it will already panic if it's not ok.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

assert!(result.is_ok());
match result.unwrap() {
Progress::Processed(idx) => {
assert_eq!(idx, 3); // stopped before processing item at index 3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this comment correct? Processed(3) means processed to 3, or processed until 3? I really hope it is the former.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. it is the former. fixed.

);

assert!(result.is_ok());
match result.unwrap() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is probably better written as an if let Progress::processed(idx) = result.unwrap() { } else { panic!(); }. I'm surprised clippy didn't warn on this; it is usually not happy with single arm match statements.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Even removed panic!() to increase code coverage number.

Box::new(tracker),
);

assert!(result.is_ok());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same comments from above apply here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

)
.await;

assert!(result.is_ok());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And same here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants