mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-18 18:46:17 +00:00
test(1306): pin usage serialization, snapshot cache invalidation, and listing send classification (#5000)
test(1306): pin Some(0) usage serialization, snapshot cache invalidation, and listing send classification Follow-up test hardening for the merged admin-usage-snapshot work (#4979/#4980/#4981/#4982, rustfs/backlog#1306). Tests only; no production behavior change. - B-1 madmin: pin that a scanned-but-empty bucket (Some(0)) serializes usage stats as zeros, staying distinct from the no-snapshot (None) omitted case. - B-2 gating: revert detector proving save_data_usage_in_backend invalidates the 30s snapshot cache so a fresh save is visible to the next cached read. - A-1 list_objects: pin that a successful gather_results send is never misclassified as ConsumerGone (correct state + err sentinel delivered), and document the wrapper Err arm invariant. A full wrapper-level producer-error integration test is deferred as it needs the fake-disk list harness.
This commit is contained in:
@@ -771,6 +771,33 @@ mod tests {
|
||||
assert_eq!(value["object_versions_histogram"]["SINGLE_VERSION"], 7);
|
||||
}
|
||||
|
||||
/// Wire pin (rustfs/backlog#1306): a scanned-but-empty bucket carries
|
||||
/// Some(0) usage stats that must serialize as zeros, staying distinct from
|
||||
/// the no-snapshot (None) case that is omitted. Guards against replacing
|
||||
/// `Option::is_none` with a predicate that also skips zero values.
|
||||
#[test]
|
||||
fn bucket_access_info_serializes_zero_usage_stats() {
|
||||
let info = BucketAccessInfo {
|
||||
name: "empty-snapshot".to_string(),
|
||||
size: Some(0),
|
||||
objects: Some(0),
|
||||
object_sizes_histogram: Some(HashMap::new()),
|
||||
object_versions_histogram: Some(HashMap::new()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let value = serde_json::to_value(&info).unwrap();
|
||||
let obj = value.as_object().unwrap();
|
||||
assert!(obj.contains_key("size"));
|
||||
assert!(obj.contains_key("objects"));
|
||||
assert!(obj.contains_key("object_sizes_histogram"));
|
||||
assert!(obj.contains_key("object_versions_histogram"));
|
||||
assert_eq!(value.get("size"), Some(&serde_json::json!(0)));
|
||||
assert_eq!(value["objects"], 0);
|
||||
assert_eq!(value["object_sizes_histogram"], serde_json::json!({}));
|
||||
assert_eq!(value["object_versions_histogram"], serde_json::json!({}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_account_status_try_from_invalid() {
|
||||
let result = AccountStatus::try_from("invalid");
|
||||
|
||||
Reference in New Issue
Block a user