fix: align restore guard tests with stale observation errors

Assert the distinct stale-observation contract while retaining same-generation conflict, no-launch, resource and historical replay checks. Include actual errors in assertion diagnostics.
This commit is contained in:
2026-11-01 01:54:34 +09:00
parent bfbddfa443
commit 922e5e3fc3
@@ -942,13 +942,17 @@ async fn restore_guard_rejects_stale_list_and_stopped_restored_stopped_aba() {
.restore(&WorkerOperationContext::Backend, stale_list.clone()) .restore(&WorkerOperationContext::Backend, stale_list.clone())
.await .await
.unwrap_err(); .unwrap_err();
assert!(matches!(conflict.error, Error::RestoreObservationConflict)); assert!(
matches!(conflict.error, Error::WorkerLifecycleObservationStale),
"{conflict:?}"
);
assert_eq!(api_error_status(&conflict.error), StatusCode::CONFLICT);
let typed = conflict.into_repository_api_error(); let typed = conflict.into_repository_api_error();
assert_eq!(typed.error, "Conflict");
assert_eq!( assert_eq!(
api_error_status(&Error::RestoreObservationConflict), typed.message,
StatusCode::CONFLICT "Worker lifecycle observation is stale; this request was not accepted"
); );
assert_eq!(typed.error, "restore_observation_conflict");
handle handle
.stop(&WorkerOperationContext::Backend, operation_lifecycle()) .stop(&WorkerOperationContext::Backend, operation_lifecycle())
.await .await
@@ -967,7 +971,7 @@ async fn restore_guard_rejects_stale_list_and_stopped_restored_stopped_aba() {
.await .await
.unwrap_err() .unwrap_err()
.error, .error,
Error::RestoreObservationConflict Error::WorkerLifecycleObservationStale
)); ));
assert_eq!(api.runtime.worker(&identity).unwrap().state, "stopped"); assert_eq!(api.runtime.worker(&identity).unwrap().state, "stopped");
assert!( assert!(
@@ -1153,7 +1157,10 @@ async fn restore_guard_stale_ssh_intent_does_not_issue_workspace_resource() {
.restore(&WorkerOperationContext::Backend, stale) .restore(&WorkerOperationContext::Backend, stale)
.await .await
.unwrap_err(); .unwrap_err();
assert!(matches!(conflict.error, Error::RestoreObservationConflict)); assert!(
matches!(conflict.error, Error::WorkerLifecycleObservationStale),
"{conflict:?}"
);
assert_eq!( assert_eq!(
api.resource_broker.repository_ssh_access_handle_count(), api.resource_broker.repository_ssh_access_handle_count(),
before before
@@ -1330,7 +1337,10 @@ async fn restore_guard_internal_stale_conflict_retires_intent_for_later_explicit
.unwrap(); .unwrap();
let count = execution.restore_operations.lock().unwrap().len(); let count = execution.restore_operations.lock().unwrap().len();
let error = restore_internal_worker_intent(&api, &identity, domain.into()).unwrap_err(); let error = restore_internal_worker_intent(&api, &identity, domain.into()).unwrap_err();
assert!(matches!(error.error, Error::RestoreObservationConflict)); assert!(
matches!(error.error, Error::WorkerLifecycleObservationStale),
"{error:?}"
);
assert_eq!( assert_eq!(
execution.restore_operations.lock().unwrap().len(), execution.restore_operations.lock().unwrap().len(),
count, count,
@@ -1439,7 +1449,10 @@ async fn restore_guard_internal_conflict_same_generation_has_distinct_fresh_inte
); );
} }
let error = restore_internal_worker_intent(&api, &identity, domain.into()).unwrap_err(); let error = restore_internal_worker_intent(&api, &identity, domain.into()).unwrap_err();
assert!(matches!(error.error, Error::RestoreObservationConflict)); assert!(
matches!(error.error, Error::RestoreObservationConflict),
"{error:?}"
);
assert_eq!(execution.restore_operations.lock().unwrap().len(), count); assert_eq!(execution.restore_operations.lock().unwrap().len(), count);
} }
} }