修复预览发布测试状态文件恢复竞态 #455

Merged
lhk229 merged 1 commits from codex/fix-preview-deployer-test-race into master 2026-09-22 01:01:48 +08:00
@@ -461,6 +461,9 @@ async fn deploy_and_uninstall_use_fixed_job_and_apply_owned_artifacts() {
.to_bytes();
let list: Value = serde_json::from_slice(&list_body).unwrap();
assert_eq!(list["deployments"], json!([]));
wait_for_persisted_status(&state.config, &id, super::DeploymentStatus::Stopped)
.await
.expect("persisted deployment reaches stopped");
let state_file = state.config.state_file.clone();
let mut recovered_config = test_config(state.config.jenkins_root_url.clone());
recovered_config.state_file = state_file.clone();
@@ -659,6 +662,24 @@ async fn wait_for_status(
Err(())
}
async fn wait_for_persisted_status(
config: &Config,
id: &str,
expected: super::DeploymentStatus,
) -> Result<(), ()> {
for _ in 0..100 {
if super::load_deployments(config)
.ok()
.and_then(|deployments| deployments.get(id).map(|record| record.public.status))
.is_some_and(|status| status == expected)
{
return Ok(());
}
tokio::time::sleep(Duration::from_millis(5)).await;
}
Err(())
}
#[test]
fn public_web_url_is_derived_from_instance_id_and_configured_domain() {
assert_eq!(