mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 16:28:15 +00:00
test(ecstore): cover fresh tmp cleanup path (#2562)
This commit is contained in:
@@ -2838,6 +2838,32 @@ mod test {
|
||||
assert!(entries.next_entry().await.unwrap().is_some());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cleanup_stale_tmp_objects_keeps_fresh_dirs_and_regular_files() {
|
||||
use tempfile::tempdir;
|
||||
|
||||
let dir = tempdir().unwrap();
|
||||
let tmp = LocalDisk::meta_path(dir.path(), RUSTFS_META_TMP_BUCKET);
|
||||
let fresh_dir = tmp.join("fresh").join("data");
|
||||
let regular_file = tmp.join("note.txt");
|
||||
let trash = LocalDisk::meta_path(dir.path(), RUSTFS_META_TMP_DELETED_BUCKET);
|
||||
|
||||
fs::create_dir_all(fresh_dir.parent().unwrap()).await.unwrap();
|
||||
fs::create_dir_all(&trash).await.unwrap();
|
||||
fs::write(&fresh_dir, b"temporary").await.unwrap();
|
||||
fs::write(®ular_file, b"keep").await.unwrap();
|
||||
|
||||
LocalDisk::cleanup_stale_tmp_objects_with_expiry(dir.path().to_path_buf(), Duration::from_secs(60))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(tmp.join("fresh").exists());
|
||||
assert!(regular_file.exists());
|
||||
|
||||
let mut entries = fs::read_dir(&trash).await.unwrap();
|
||||
assert!(entries.next_entry().await.unwrap().is_none());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_scan_dir_includes_nested_object_dirs() {
|
||||
use rustfs_filemeta::MetacacheReader;
|
||||
|
||||
Reference in New Issue
Block a user