test(ecstore): give the read-version quorum fixture a valid part

`read_version_quorum_test_set` (#5365) writes `valid_test_fileinfo` to disk
before exercising the optimized version read. That fixture deliberately
carries a positive size with no parts so it can drive
`get_object_with_fileinfo_rejects_positive_size_without_parts`, and #5354
subsequently taught `validate_collection_contents` to reject exactly that
shape as `FileCorrupt`. #5354 fixed up the fixtures that existed when it
landed, but #5365 was developed in parallel and its new fixture was not,
so `write_metadata` now fails in the helper and both
`read_version_optimized_counts_only_valid_metadata_toward_quorum` and
`read_version_optimized_uses_current_set_drive_quorum_not_pool_set_count`
panic on `metadata should be written before quorum read: FileCorrupt`.

Neither PR could see the break on its own; it only appears once both are on
main, where it fails the Test and Lint lane deterministically for every PR.

Push a part matching the fixture's size in the helper — the same fix #5354
applied to its own on-disk fixture in `disk/local.rs` — instead of changing
`valid_test_fileinfo`, which must stay part-less for the rejection test.

Verification:
- cargo test -p rustfs-ecstore --lib set_disk::read::metadata_cache_tests
  (previously 2 failed, now 33 passed / 0 failed)
- cargo fmt --all --check and cargo clippy -p rustfs-ecstore --lib --tests clean
This commit is contained in:
overtrue
2026-07-29 00:21:27 +08:00
parent eb755e2b97
commit 10db415099
+11
View File
@@ -1971,6 +1971,17 @@ mod metadata_cache_tests {
let mut fi = valid_test_fileinfo(object);
fi.mod_time = Some(OffsetDateTime::now_utc());
fi.erasure.index = fi.erasure.distribution[disk_index];
// `valid_test_fileinfo` carries a positive size with no parts —
// the shape `validate_collection_contents` rejects as
// `FileCorrupt` — so it can drive
// `get_object_with_fileinfo_rejects_positive_size_without_parts`.
// Metadata that has to survive a write needs the matching part.
fi.parts.push(ObjectPartInfo {
number: 1,
size: 1,
actual_size: 1,
..Default::default()
});
disk.write_metadata(bucket, bucket, object, fi)
.await
.expect("metadata should be written before quorum read");