mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-24 13:16:28 +00:00
test(scanner): align pristine startup fixtures (#6516)
This commit is contained in:
@@ -33,6 +33,10 @@ use tokio::time::{Duration, advance};
|
|||||||
const TEST_DEFAULT_SCANNER_CYCLE_SECS: u64 = 24 * 60 * 60;
|
const TEST_DEFAULT_SCANNER_CYCLE_SECS: u64 = 24 * 60 * 60;
|
||||||
|
|
||||||
async fn setup_scanner_cycle_store() -> (tempfile::TempDir, Arc<ECStore>) {
|
async fn setup_scanner_cycle_store() -> (tempfile::TempDir, Arc<ECStore>) {
|
||||||
|
setup_scanner_cycle_store_with_usage_baseline(true).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn setup_scanner_cycle_store_with_usage_baseline(seed_usage_baseline: bool) -> (tempfile::TempDir, Arc<ECStore>) {
|
||||||
init_ecstore_config_for_scanner_tests();
|
init_ecstore_config_for_scanner_tests();
|
||||||
let temp_dir = tempfile::tempdir().expect("scanner cycle test directory should be created");
|
let temp_dir = tempfile::tempdir().expect("scanner cycle test directory should be created");
|
||||||
let mut endpoints = Vec::new();
|
let mut endpoints = Vec::new();
|
||||||
@@ -69,14 +73,16 @@ async fn setup_scanner_cycle_store() -> (tempfile::TempDir, Arc<ECStore>) {
|
|||||||
.await
|
.await
|
||||||
.expect("scanner cycle test ECStore should initialize");
|
.expect("scanner cycle test ECStore should initialize");
|
||||||
init_bucket_metadata_sys_for_scanner_tests(store.clone()).await;
|
init_bucket_metadata_sys_for_scanner_tests(store.clone()).await;
|
||||||
save_config(
|
if seed_usage_baseline {
|
||||||
store.clone(),
|
save_config(
|
||||||
DATA_USAGE_OBJ_NAME_PATH.as_str(),
|
store.clone(),
|
||||||
serde_json::to_vec(&complete_usage_with_bucket_count(Some(std::time::SystemTime::UNIX_EPOCH), 0))
|
DATA_USAGE_OBJ_NAME_PATH.as_str(),
|
||||||
.expect("scanner cycle usage baseline should encode"),
|
serde_json::to_vec(&complete_usage_with_bucket_count(Some(std::time::SystemTime::UNIX_EPOCH), 0))
|
||||||
)
|
.expect("scanner cycle usage baseline should encode"),
|
||||||
.await
|
)
|
||||||
.expect("scanner cycle usage baseline should persist");
|
.await
|
||||||
|
.expect("scanner cycle usage baseline should persist");
|
||||||
|
}
|
||||||
|
|
||||||
(temp_dir, store)
|
(temp_dir, store)
|
||||||
}
|
}
|
||||||
@@ -2148,7 +2154,7 @@ async fn scanner_usage_floor_fails_closed_on_zero_byte_usage_objects() {
|
|||||||
let appearing = Arc::new(MemoryConfigStore::default());
|
let appearing = Arc::new(MemoryConfigStore::default());
|
||||||
appearing.insert_after_gets.lock().await.insert(key, Vec::new());
|
appearing.insert_after_gets.lock().await.insert(key, Vec::new());
|
||||||
|
|
||||||
let err = persisted_usage_floor(appearing)
|
let err = persisted_usage_floor_for_startup(appearing, true)
|
||||||
.await
|
.await
|
||||||
.expect_err("an empty usage object appearing during confirmation must prevent pristine bootstrap");
|
.expect_err("an empty usage object appearing during confirmation must prevent pristine bootstrap");
|
||||||
assert!(
|
assert!(
|
||||||
@@ -2171,7 +2177,7 @@ async fn scanner_usage_floor_fails_closed_when_usage_appears_during_pristine_con
|
|||||||
let store = Arc::new(MemoryConfigStore::default());
|
let store = Arc::new(MemoryConfigStore::default());
|
||||||
insert_usage_after_first_legacy_backup_read(store.as_ref()).await;
|
insert_usage_after_first_legacy_backup_read(store.as_ref()).await;
|
||||||
|
|
||||||
let err = persisted_usage_floor(store)
|
let err = persisted_usage_floor_for_startup(store, true)
|
||||||
.await
|
.await
|
||||||
.expect_err("an appearing usage snapshot must prevent pristine bootstrap");
|
.expect_err("an appearing usage snapshot must prevent pristine bootstrap");
|
||||||
assert!(err.to_string().contains("changed while confirming pristine state"));
|
assert!(err.to_string().contains("changed while confirming pristine state"));
|
||||||
@@ -2212,7 +2218,7 @@ fn scanner_pristine_cycle_state_requires_no_durable_progress() {
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn scanner_pristine_bootstrap_allows_first_bucket_to_win_startup() {
|
async fn scanner_pristine_bootstrap_allows_first_bucket_to_win_startup() {
|
||||||
let (_temp_dir, store) = setup_scanner_cycle_store().await;
|
let (_temp_dir, store) = setup_scanner_cycle_store_with_usage_baseline(false).await;
|
||||||
let cycle = CurrentCycle::default();
|
let cycle = CurrentCycle::default();
|
||||||
let revision = DataUsageCacheRevision::Missing;
|
let revision = DataUsageCacheRevision::Missing;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user