feat: version-specific pg_restore failure reasons, keep pg_stat_statements, explain reconcile conflicts
- pg_restore's stderr is kept; the archive header names the pg_dump that wrote it, and a newer one than the local client gives 'install a PostgreSQL client >= N' before any safety backup is taken - omit_pg_stat_statements recreates the extension the target had, where it lived - reconcile on a job that needs no recovery answers 409 with a reason - proven against a real PostgreSQL server (real archive header, extension kept, mutation caught) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1702,3 +1702,40 @@ async fn a_restore_safety_copy_never_pushes_a_production_capture_out_of_retentio
|
||||
assert!(vault.get_snapshot(capture).unwrap().is_some());
|
||||
assert!(vault.get_snapshot(safety[0]).unwrap().is_some());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn reconciling_a_job_that_needs_no_recovery_says_so() {
|
||||
let lab = fresh().await;
|
||||
lab.start(&lab.admin(), "reconcile").await;
|
||||
lab.capture(&Lab::production_identity(), false)
|
||||
.await
|
||||
.unwrap();
|
||||
lab.tick().await;
|
||||
let (job, _token) = lab.restore_until_ready().await.unwrap();
|
||||
let uri = format!("/api/v1/restore-jobs/{job}/reconcile");
|
||||
let (status, body) = lab
|
||||
.send(
|
||||
&lab.admin(),
|
||||
"POST",
|
||||
&uri,
|
||||
Some(json!({"confirmation": format!("RECONCILE {job}")})),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::CONFLICT);
|
||||
assert!(
|
||||
body["error"]
|
||||
.as_str()
|
||||
.is_some_and(|text| text.contains("recovery_required")),
|
||||
"{body}"
|
||||
);
|
||||
// the wrong confirmation is still a plain 400
|
||||
let (status, _) = lab
|
||||
.send(
|
||||
&lab.admin(),
|
||||
"POST",
|
||||
&uri,
|
||||
Some(json!({"confirmation": "no"})),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::BAD_REQUEST);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user