test(update): wait for the old daemon to exit after the handover

It now exits only after it has seen the replacement serve, so it can
still be running when the replacement publishes daemon.json.
This commit is contained in:
drakezhang
2026-09-27 01:35:24 +08:00
parent 15c0baba05
commit eb9b1425fa
+13 -10
View File
@@ -322,16 +322,19 @@ fn automatic_update_exits_old_daemon_and_restarts_on_the_same_port() {
.info()
.is_some_and(|info| info.pid != old_pid && info.ws_port == port)
});
assert!(
fixture
.daemon
.as_mut()
.unwrap()
.try_wait()
.unwrap()
.is_some(),
"old daemon must exit"
);
// The old daemon exits only after it has seen the replacement serve.
let deadline = Instant::now() + Duration::from_secs(30);
while fixture
.daemon
.as_mut()
.unwrap()
.try_wait()
.unwrap()
.is_none()
{
assert!(Instant::now() < deadline, "old daemon must exit");
thread::sleep(Duration::from_millis(50));
}
// The replacement removes the image its predecessor ran from.
fixture.wait_for("leftover cleanup", || fixture.leftovers().is_empty());
let status = fixture