From cb62079ba68c01db8b7525cd689598053986be0e Mon Sep 17 00:00:00 2001 From: cxymds Date: Wed, 29 Jul 2026 13:53:59 +0800 Subject: [PATCH] test(ilm): make active cancellation deterministic (#5403) * ci: preserve timeout evidence for workspace tests * test(ilm): make active cancellation deterministic * ci: allow cold doctest compilation to finish --------- Co-authored-by: houseme --- .github/workflows/ci.yml | 4 ++-- crates/e2e_test/src/reliant/tiering.rs | 12 ++++++++++-- rustfs/Cargo.toml | 1 + rustfs/src/admin/handlers/ilm_transition.rs | 6 ++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2fd167bf..2e24bd278 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -372,7 +372,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} - name: Build debug binary - run: cargo build -p rustfs --bins + run: cargo build -p rustfs --bins --features e2e-test-hooks - name: Upload debug binary uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 @@ -402,7 +402,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} - name: Build debug binary with rio-v2 - run: cargo build -p rustfs --bins --features rio-v2 + run: cargo build -p rustfs --bins --features rio-v2,e2e-test-hooks - name: Upload debug binary uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 diff --git a/crates/e2e_test/src/reliant/tiering.rs b/crates/e2e_test/src/reliant/tiering.rs index ee4d89e81..872a594bc 100644 --- a/crates/e2e_test/src/reliant/tiering.rs +++ b/crates/e2e_test/src/reliant/tiering.rs @@ -95,6 +95,7 @@ const MANUAL_ASYNC_PARALLEL_OBJECTS: usize = 64; const MANUAL_ACTIVE_CANCEL_OBJECTS: usize = 512; const MANUAL_RESTART_CANCEL_OBJECTS: usize = 512; const MANUAL_ACTIVE_CANCEL_RUNNING_TIMEOUT: StdDuration = StdDuration::from_secs(15); +const MANUAL_TRANSITION_CANCEL_BARRIER_ENV: &str = "RUSTFS_E2E_MANUAL_TRANSITION_CANCEL_BARRIER"; const MANUAL_ASYNC_CONFLICT_TERMINAL_TIMEOUT: StdDuration = StdDuration::from_secs(90); const MANUAL_RESTART_RECOVERY_TIMEOUT: StdDuration = StdDuration::from_secs(80); const OBJECT_KEY: &str = "tier/鲁A12345/report.bin"; @@ -1684,8 +1685,15 @@ async fn test_manual_transition_async_active_cancel_reports_terminal_cancelled() cold_client.create_bucket().bucket(TIER_BUCKET).send().await?; let mut hot = RustFSTestEnvironment::new().await?; - hot.start_rustfs_server_with_env(vec![], &[("RUSTFS_SCANNER_ENABLED", "false"), ("RUSTFS_SCANNER_CYCLE", "3600")]) - .await?; + hot.start_rustfs_server_with_env( + vec![], + &[ + ("RUSTFS_SCANNER_ENABLED", "false"), + ("RUSTFS_SCANNER_CYCLE", "3600"), + (MANUAL_TRANSITION_CANCEL_BARRIER_ENV, "1"), + ], + ) + .await?; let hot_client = hot.create_s3_client(); add_rustfs_tier(&hot, &cold).await?; diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 4915a1755..13dca03c4 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -47,6 +47,7 @@ io-scheduler-debug = [] # Enable debug information in I/O scheduler tracing-chunk-debug = [] # Enable per-chunk tracing in data plane (high noise, for debugging only) full = ["metrics-gpu", "ftps", "swift", "webdav", "sftp", "pyroscope"] manual-test-runners = [] +e2e-test-hooks = [] rio-v2 = ["rustfs-ecstore/rio-v2"] pyroscope = ["rustfs-obs/pyroscope"] # Tokio runtime telemetry. Requires `--cfg tokio_unstable`; use `make build-profiling`. diff --git a/rustfs/src/admin/handlers/ilm_transition.rs b/rustfs/src/admin/handlers/ilm_transition.rs index 5d935187c..3adb22673 100644 --- a/rustfs/src/admin/handlers/ilm_transition.rs +++ b/rustfs/src/admin/handlers/ilm_transition.rs @@ -58,6 +58,8 @@ const LOG_SUBSYSTEM_ILM_TRANSITION: &str = "ilm_transition"; const EVENT_ADMIN_ILM_TRANSITION_STATE: &str = "admin_ilm_transition_state"; static ACTIVE_MANUAL_TRANSITION_SCOPES: OnceLock>> = OnceLock::new(); +#[cfg(feature = "e2e-test-hooks")] +const E2E_MANUAL_TRANSITION_CANCEL_BARRIER_ENV: &str = "RUSTFS_E2E_MANUAL_TRANSITION_CANCEL_BARRIER"; static ACTIVE_MANUAL_TRANSITION_JOBS: OnceLock>> = OnceLock::new(); static MANUAL_TRANSITION_OWNER_ID: OnceLock = OnceLock::new(); @@ -748,6 +750,10 @@ async fn start_manual_transition_job( let job_heartbeat_shutdown_token = heartbeat_shutdown_token.clone(); spawn_manual_transition_job_heartbeat(store, job_id, scan_cancel_token, heartbeat_shutdown_token); tokio::spawn(async move { + #[cfg(feature = "e2e-test-hooks")] + if std::env::var_os(E2E_MANUAL_TRANSITION_CANCEL_BARRIER_ENV).is_some() { + job_scan_cancel_token.cancelled().await; + } let result = enqueue_transition_for_existing_objects_scoped(run_store.clone(), &bucket, run_options).await; if let Some(final_record) = finalize_manual_transition_job(run_store.clone(), job_id, result).await && final_record.is_terminal()