Skip to content

Commit 3d5a2ad

Browse files
committed
fix(docker): make orphan-restore process test tolerate PID reuse
- Update process_api test to accept either a dead orphan PID or the same PID with a new starttime, since the OS can recycle PIDs under load after kill+respawn - Check both PID and starttime to prove the orphan process was successfully replaced, avoiding flaky test failures when the kernel reuses the orphan's PID for the respawned bot - Bump version to 0.1.127
1 parent f276701 commit 3d5a2ad

5 files changed

Lines changed: 25 additions & 12 deletions

File tree

.textile-monorepo-source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
38fe58de50aa3994786d1e82bb4963d2af650009
1+
f11110d1262d7913c50315d291ae0945f4de6a4d

.textile-stitch-release-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.126
1+
0.1.127

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stitch-bot"
3-
version = "0.1.126"
3+
version = "0.1.127"
44
edition = "2021"
55
description = "Stitch — Textile filler-network operator bot; market-makes the filler order book with signed UniswapX limit orders."
66
license = "AGPL-3.0-or-later"

src/panel/docker/process_api.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,16 +1354,29 @@ mod tests {
13541354
persist_record(&state, &record).unwrap();
13551355

13561356
let rt = ProcessRuntime::new(sleep_bin, &bots).unwrap();
1357-
assert!(
1358-
!process_alive(orphan_pid),
1359-
"orphan from the previous panel must be terminated on restore"
1360-
);
1361-
let new_pid = {
1357+
let (new_pid, new_start) = {
13621358
let inner = rt.inner.lock().unwrap();
1363-
inner["stitch-bot-a"].record.pid
1359+
let live = &inner["stitch-bot-a"];
1360+
(live.record.pid, live.record.pid_starttime)
13641361
};
1365-
assert!(new_pid.is_some());
1366-
assert_ne!(new_pid, Some(orphan_pid));
1362+
assert!(
1363+
new_pid.is_some(),
1364+
"wanted bot must be respawned after orphan kill"
1365+
);
1366+
// Don't assert `!process_alive(orphan_pid)` alone: under load the OS can
1367+
// recycle that pid onto the respawned bot, which is still a successful
1368+
// kill+spawn. Prove the orphan is gone via pid or starttime.
1369+
if new_pid == Some(orphan_pid) {
1370+
assert_ne!(
1371+
new_start, orphan_start,
1372+
"respawn reused orphan pid; starttime must show a new process"
1373+
);
1374+
} else {
1375+
assert!(
1376+
!process_alive(orphan_pid),
1377+
"orphan from the previous panel must be terminated on restore"
1378+
);
1379+
}
13671380
drop(rt);
13681381
let _ = std::fs::remove_dir_all(root);
13691382
}

0 commit comments

Comments
 (0)