test(ecstore): cover SetDisks storage contracts (#4033)

This commit is contained in:
Zhengchao An
2026-06-29 10:01:42 +08:00
committed by GitHub
parent ea88f5b67b
commit 1e6f20912a
3 changed files with 63 additions and 12 deletions
@@ -20,10 +20,10 @@ use rustfs_lock::NamespaceLockWrapper;
use rustfs_madmin::heal_commands::HealResultItem; use rustfs_madmin::heal_commands::HealResultItem;
use storage_api::contract_compat::{ use storage_api::contract_compat::{
CompletePart, DeletedObject, DiskStore, ECStore, Error, GetObjectReader, HTTPRangeSpec, ListMultipartsInfo, ListPartsInfo, CompletePart, DeletedObject, DiskStore, ECStore, Error, GetObjectReader, HTTPRangeSpec, ListMultipartsInfo, ListPartsInfo,
MultipartInfo, MultipartUploadResult, ObjectInfo, ObjectOptions, ObjectToDelete, PartInfo, PutObjReader, StorageAdminApi, MultipartInfo, MultipartUploadResult, ObjectInfo, ObjectOptions, ObjectToDelete, PartInfo, PutObjReader, SetDisks,
StorageHealOperations, StorageListObjectVersionsInfo, StorageListObjectsV2Info, StorageListOperations, StorageAdminApi, StorageBucketOperations, StorageHealOperations, StorageListObjectVersionsInfo, StorageListObjectsV2Info,
StorageMultipartOperations, StorageNamespaceLocking, StorageObjectIO, StorageObjectInfoOrErr, StorageObjectOperations, StorageListOperations, StorageMultipartOperations, StorageNamespaceLocking, StorageObjectIO, StorageObjectInfoOrErr,
StorageWalkOptions, StorageObjectOperations, StorageWalkOptions,
}; };
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
@@ -66,6 +66,13 @@ where
std::any::type_name::<T>() std::any::type_name::<T>()
} }
fn storage_bucket_operations_type_name<T>() -> &'static str
where
T: StorageBucketOperations<Error = Error>,
{
std::any::type_name::<T>()
}
fn storage_object_operations_type_name<T>() -> &'static str fn storage_object_operations_type_name<T>() -> &'static str
where where
T: StorageObjectOperations< T: StorageObjectOperations<
@@ -135,6 +142,11 @@ fn ecstore_implements_storage_object_io_contract() {
assert!(storage_object_io_type_name::<ECStore>().ends_with("::ECStore")); assert!(storage_object_io_type_name::<ECStore>().ends_with("::ECStore"));
} }
#[test]
fn ecstore_implements_storage_bucket_operations_contract() {
assert!(storage_bucket_operations_type_name::<ECStore>().ends_with("::ECStore"));
}
#[test] #[test]
fn ecstore_implements_storage_object_operations_contract() { fn ecstore_implements_storage_object_operations_contract() {
assert!(storage_object_operations_type_name::<ECStore>().ends_with("::ECStore")); assert!(storage_object_operations_type_name::<ECStore>().ends_with("::ECStore"));
@@ -154,3 +166,38 @@ fn ecstore_implements_storage_multipart_operations_contract() {
fn ecstore_implements_storage_heal_operations_contract() { fn ecstore_implements_storage_heal_operations_contract() {
assert!(storage_heal_operations_type_name::<ECStore>().ends_with("::ECStore")); assert!(storage_heal_operations_type_name::<ECStore>().ends_with("::ECStore"));
} }
#[test]
fn set_disks_implements_storage_namespace_locking_contract() {
assert!(storage_namespace_locking_type_name::<SetDisks>().ends_with("::SetDisks"));
}
#[test]
fn set_disks_implements_storage_object_io_contract() {
assert!(storage_object_io_type_name::<SetDisks>().ends_with("::SetDisks"));
}
#[test]
fn set_disks_implements_storage_bucket_operations_contract() {
assert!(storage_bucket_operations_type_name::<SetDisks>().ends_with("::SetDisks"));
}
#[test]
fn set_disks_implements_storage_object_operations_contract() {
assert!(storage_object_operations_type_name::<SetDisks>().ends_with("::SetDisks"));
}
#[test]
fn set_disks_implements_storage_list_operations_contract() {
assert!(storage_list_operations_type_name::<SetDisks>().ends_with("::SetDisks"));
}
#[test]
fn set_disks_implements_storage_multipart_operations_contract() {
assert!(storage_multipart_operations_type_name::<SetDisks>().ends_with("::SetDisks"));
}
#[test]
fn set_disks_implements_storage_heal_operations_contract() {
assert!(storage_heal_operations_type_name::<SetDisks>().ends_with("::SetDisks"));
}
+8 -8
View File
@@ -4,20 +4,20 @@ pub(crate) use rustfs_ecstore::api::bitrot::create_bitrot_reader;
pub(crate) use rustfs_ecstore::api::disk::{DiskAPI, DiskOption, DiskStore, STORAGE_FORMAT_FILE, endpoint::Endpoint, new_disk}; pub(crate) use rustfs_ecstore::api::disk::{DiskAPI, DiskOption, DiskStore, STORAGE_FORMAT_FILE, endpoint::Endpoint, new_disk};
pub(crate) use rustfs_ecstore::api::erasure::Erasure; pub(crate) use rustfs_ecstore::api::erasure::Erasure;
pub(crate) use rustfs_ecstore::api::object::{GetObjectReader, ObjectInfo, ObjectOptions, PutObjReader}; pub(crate) use rustfs_ecstore::api::object::{GetObjectReader, ObjectInfo, ObjectOptions, PutObjReader};
pub(crate) use rustfs_ecstore::api::{error::Error, storage::ECStore}; pub(crate) use rustfs_ecstore::api::{error::Error, set_disk::SetDisks, storage::ECStore};
use rustfs_storage_api as storage_contracts; use rustfs_storage_api as storage_contracts;
pub(crate) mod contract_compat { pub(crate) mod contract_compat {
pub(crate) use super::storage_contracts::{ pub(crate) use super::storage_contracts::{
CompletePart, DeletedObject, HTTPRangeSpec, HealOperations as StorageHealOperations, ListMultipartsInfo, BucketOperations as StorageBucketOperations, CompletePart, DeletedObject, HTTPRangeSpec,
ListObjectVersionsInfo as StorageListObjectVersionsInfo, ListObjectsV2Info as StorageListObjectsV2Info, HealOperations as StorageHealOperations, ListMultipartsInfo, ListObjectVersionsInfo as StorageListObjectVersionsInfo,
ListOperations as StorageListOperations, ListPartsInfo, MultipartInfo, MultipartOperations as StorageMultipartOperations, ListObjectsV2Info as StorageListObjectsV2Info, ListOperations as StorageListOperations, ListPartsInfo, MultipartInfo,
MultipartUploadResult, NamespaceLocking as StorageNamespaceLocking, ObjectIO as StorageObjectIO, MultipartOperations as StorageMultipartOperations, MultipartUploadResult, NamespaceLocking as StorageNamespaceLocking,
ObjectInfoOrErr as StorageObjectInfoOrErr, ObjectOperations as StorageObjectOperations, ObjectToDelete, PartInfo, ObjectIO as StorageObjectIO, ObjectInfoOrErr as StorageObjectInfoOrErr, ObjectOperations as StorageObjectOperations,
StorageAdminApi, WalkOptions as StorageWalkOptions, ObjectToDelete, PartInfo, StorageAdminApi, WalkOptions as StorageWalkOptions,
}; };
pub(crate) use super::{DiskStore, ECStore, Error, GetObjectReader, ObjectInfo, ObjectOptions, PutObjReader}; pub(crate) use super::{DiskStore, ECStore, Error, GetObjectReader, ObjectInfo, ObjectOptions, PutObjReader, SetDisks};
} }
pub(crate) mod legacy_bitrot_read { pub(crate) mod legacy_bitrot_read {
@@ -42,6 +42,10 @@ local boundary or storage-api contract first, then route consumers through it.
| Replication | Bucket target and metadata systems, bucket target client config, disk, object API, runtime sources, notification, and SetDisks lock timing. | `ReplicationStorage`, `ReplicationMetadataStore`, `ReplicationRuntime`, `ReplicationEventSink`, and `ReplicationLifecycleBridge`. | | Replication | Bucket target and metadata systems, bucket target client config, disk, object API, runtime sources, notification, and SetDisks lock timing. | `ReplicationStorage`, `ReplicationMetadataStore`, `ReplicationRuntime`, `ReplicationEventSink`, and `ReplicationLifecycleBridge`. |
| SetDisks | Shared disks, endpoints, format state, namespace locks, cache, and implementations for object IO, namespace locking, bucket, object, list, multipart, and heal operations. | Pure shard source, disk error, bitrot IO, namespace lock, metrics label, and file metadata contracts before any operation family moves. | | SetDisks | Shared disks, endpoints, format state, namespace locks, cache, and implementations for object IO, namespace locking, bucket, object, list, multipart, and heal operations. | Pure shard source, disk error, bitrot IO, namespace lock, metrics label, and file metadata contracts before any operation family moves. |
`crates/ecstore/tests/ecstore_contract_compat_test.rs` keeps compile-time
coverage for `ECStore` and `SetDisks` storage-api trait compatibility before
any facade shrink or operation-family movement.
## Shrink Rules ## Shrink Rules
1. Do not remove a facade item until its downstream boundary has compile-time 1. Do not remove a facade item until its downstream boundary has compile-time