From 51db0837eab270611470e8290b7cf98e4ea1920a Mon Sep 17 00:00:00 2001 From: Louis Haftmann <30736553+LouisHaftmann@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:37:33 +0100 Subject: [PATCH] test(cleanup): stop part cleanup test from flaking when the Merge finishes early The second full download could open after the Merge completed, read the merged object under a Storage lease, and leave the Parts unprotected. Open the Parts reader first as a ranged read, which always reads Parts. Co-Authored-By: Claude Opus 5.5 --- src/tests/cleanup.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tests/cleanup.rs b/src/tests/cleanup.rs index 7869e88..5fa06f4 100644 --- a/src/tests/cleanup.rs +++ b/src/tests/cleanup.rs @@ -11,7 +11,7 @@ use super::harness::{ use crate::cleanup::{CleanupSummary, Task, reconcile_orphaned_storage}; use crate::db::{StorageLocation, now_ms, uploads}; use crate::error::{Failure, Result}; -use crate::storage::{AuthorizedUpload, CreatedUpload}; +use crate::storage::{AuthorizedUpload, CreatedUpload, EndPosition, RangeRequest, StartPosition}; const DAY_MS: i64 = 24 * 60 * 60 * 1000; @@ -216,8 +216,19 @@ async fn part_cleanup_waits_for_an_active_parts_download() { ) .await; let storage = server.storage(); + // Ranged, and opened before the Merge can finish, so it reads the Parts on every backend. + let reading_parts = storage + .download( + &location.id, + Some(RangeRequest { + start: StartPosition::Index(0), + end: EndPosition::LastByte, + }), + ) + .await + .unwrap() + .unwrap(); let merging = storage.download(&location.id, None).await.unwrap().unwrap(); - let reading_parts = storage.download(&location.id, None).await.unwrap().unwrap(); read_all(merging.stream).await.unwrap(); storage.wait_for_ongoing_merges().await;