test(push-gateway): attempt every probe drop before reporting a drop failure

A failed drop of the first probe on a passing run panicked inside the
loop and skipped dropping the second probe. Collect drop failures and
report them after both drops have been attempted.

Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
This commit is contained in:
Elrond
2026-10-16 10:16:13 -04:00
parent a3d41964d7
commit 5107ebabd1

View File

@@ -234,20 +234,27 @@ async fn desired_state_schema_matches_migrations() {
probes.clone(), probes.clone(),
)) ))
.await; .await;
// Attempt every drop before reporting any failure, so one failed drop
// never leaks the other probe.
let mut drop_failures = Vec::new();
for db in &probes { for db in &probes {
let dropped = sqlx::query(AssertSqlSafe(format!( if let Err(error) = sqlx::query(AssertSqlSafe(format!(
"DROP DATABASE IF EXISTS {db} WITH (FORCE)" "DROP DATABASE IF EXISTS {db} WITH (FORCE)"
))) )))
.execute(&admin) .execute(&admin)
.await; .await
match (dropped, &outcome) { {
(Ok(_), _) => {} drop_failures.push(format!("drop probe database {db}: {error}"));
(Err(error), Ok(())) => panic!("drop probe database {db}: {error}"),
(Err(error), Err(_)) => eprintln!("could not drop probe database {db}: {error}"),
} }
} }
if let Err(failure) = outcome { match outcome {
std::panic::resume_unwind(failure.into_panic()); Err(failure) => {
for message in &drop_failures {
eprintln!("{message}");
}
std::panic::resume_unwind(failure.into_panic());
}
Ok(()) => assert!(drop_failures.is_empty(), "{}", drop_failures.join("; ")),
} }
struct PgschemaConnection { struct PgschemaConnection {