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 storage_api::contract_compat::{
CompletePart, DeletedObject, DiskStore, ECStore, Error, GetObjectReader, HTTPRangeSpec, ListMultipartsInfo, ListPartsInfo,
MultipartInfo, MultipartUploadResult, ObjectInfo, ObjectOptions, ObjectToDelete, PartInfo, PutObjReader, StorageAdminApi,
StorageHealOperations, StorageListObjectVersionsInfo, StorageListObjectsV2Info, StorageListOperations,
StorageMultipartOperations, StorageNamespaceLocking, StorageObjectIO, StorageObjectInfoOrErr, StorageObjectOperations,
StorageWalkOptions,
MultipartInfo, MultipartUploadResult, ObjectInfo, ObjectOptions, ObjectToDelete, PartInfo, PutObjReader, SetDisks,
StorageAdminApi, StorageBucketOperations, StorageHealOperations, StorageListObjectVersionsInfo, StorageListObjectsV2Info,
StorageListOperations, StorageMultipartOperations, StorageNamespaceLocking, StorageObjectIO, StorageObjectInfoOrErr,
StorageObjectOperations, StorageWalkOptions,
};
use tokio_util::sync::CancellationToken;
@@ -66,6 +66,13 @@ where
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
where
T: StorageObjectOperations<
@@ -135,6 +142,11 @@ fn ecstore_implements_storage_object_io_contract() {
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]
fn ecstore_implements_storage_object_operations_contract() {
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() {
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::erasure::Erasure;
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;
pub(crate) mod contract_compat {
pub(crate) use super::storage_contracts::{
CompletePart, DeletedObject, HTTPRangeSpec, HealOperations as StorageHealOperations, ListMultipartsInfo,
ListObjectVersionsInfo as StorageListObjectVersionsInfo, ListObjectsV2Info as StorageListObjectsV2Info,
ListOperations as StorageListOperations, ListPartsInfo, MultipartInfo, MultipartOperations as StorageMultipartOperations,
MultipartUploadResult, NamespaceLocking as StorageNamespaceLocking, ObjectIO as StorageObjectIO,
ObjectInfoOrErr as StorageObjectInfoOrErr, ObjectOperations as StorageObjectOperations, ObjectToDelete, PartInfo,
StorageAdminApi, WalkOptions as StorageWalkOptions,
BucketOperations as StorageBucketOperations, CompletePart, DeletedObject, HTTPRangeSpec,
HealOperations as StorageHealOperations, ListMultipartsInfo, ListObjectVersionsInfo as StorageListObjectVersionsInfo,
ListObjectsV2Info as StorageListObjectsV2Info, ListOperations as StorageListOperations, ListPartsInfo, MultipartInfo,
MultipartOperations as StorageMultipartOperations, MultipartUploadResult, NamespaceLocking as StorageNamespaceLocking,
ObjectIO as StorageObjectIO, ObjectInfoOrErr as StorageObjectInfoOrErr, ObjectOperations as StorageObjectOperations,
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 {