fix(test): allow InstanceContext bucket_metadata_sys reinitialization for tests (#4638)

The OnceLock introduced in 5fbd49a80 for bucket_metadata_sys panics when
multiple test modules initialize their own ECStore against the shared
bootstrap context. Switch to Mutex<Option> so test fixtures can
reinitialize safely.

Extract shared gating test environment to gating_test_env.rs to avoid
duplicate ECStore setup across delete_objects_stat_gating_test and
put_prelookup_gating_test.

Fixes 8 test failures:
- capacity_dirty_scope_test (2 tests)
- delete_objects_stat_gating_test (3 tests)
- put_prelookup_gating_test (3 tests)
This commit is contained in:
Zhengchao An
2026-07-10 04:03:26 +08:00
committed by GitHub
parent 5e80980698
commit cefbe2ccc9
6 changed files with 135 additions and 160 deletions
+1 -6
View File
@@ -55,12 +55,7 @@ pub async fn init_bucket_metadata_sys(api: Arc<ECStore>, buckets: Vec<String>) {
let sys = Arc::new(RwLock::new(sys));
// Same fail-fast as the old process-global `.set().unwrap()`, scoped to
// the owning instance: double-initializing one store's metadata is a bug.
assert!(
instance_ctx.init_bucket_metadata_sys(sys.clone()),
"bucket metadata sys should be initialized once per instance"
);
instance_ctx.init_bucket_metadata_sys(sys.clone());
if is_dist_erasure {
start_refresh_buckets_metadata_loop(sys);