mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-30 08:49:26 +00:00
fix(storage): keep storage info RPC map encoded (#2942)
Co-authored-by: cxymds <Cxymds@qq.com>
This commit is contained in:
@@ -422,7 +422,7 @@ impl LocalDisk {
|
|||||||
total: info.total,
|
total: info.total,
|
||||||
free: info.free,
|
free: info.free,
|
||||||
used: info.used,
|
used: info.used,
|
||||||
used_inodes: info.files - info.ffree,
|
used_inodes: info.files.saturating_sub(info.ffree),
|
||||||
free_inodes: info.ffree,
|
free_inodes: info.ffree,
|
||||||
major: info.major,
|
major: info.major,
|
||||||
minor: info.minor,
|
minor: info.minor,
|
||||||
|
|||||||
@@ -236,3 +236,30 @@ impl NodeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn local_storage_info_rpc_payload_uses_msgpack_map_encoding() {
|
||||||
|
let info = rustfs_madmin::StorageInfo {
|
||||||
|
disks: Vec::new(),
|
||||||
|
backend: rustfs_madmin::BackendInfo {
|
||||||
|
backend_type: rustfs_madmin::BackendByte::Erasure,
|
||||||
|
standard_sc_data: vec![2, 2],
|
||||||
|
total_sets: vec![1, 1],
|
||||||
|
drives_per_set: vec![4, 4],
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let encoded = encode_msgpack_map(&info).expect("storage info should serialize");
|
||||||
|
assert_eq!(encoded.first().copied(), Some(0x82));
|
||||||
|
|
||||||
|
let mut decoder = Deserializer::new(Cursor::new(encoded));
|
||||||
|
let decoded: rustfs_madmin::StorageInfo = Deserialize::deserialize(&mut decoder).expect("storage info should decode");
|
||||||
|
assert_eq!(decoded.backend.drives_per_set, vec![4, 4]);
|
||||||
|
assert_eq!(decoded.backend.total_sets, vec![1, 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user