From 9808a602a9d82a5e21b27feed52ac015e6211027 Mon Sep 17 00:00:00 2001 From: iamdoubz Date: Sun, 18 Oct 2026 14:11:40 -0500 Subject: [PATCH] e2e: phones unregister before their container is removed Killing the baresip container left 'Avail' contacts in Asterisk; the next script's phones (same IP) then had two contacts each and m5-t3's presence check saw no state change. stop() now sends baresip SIGTERM (found via /proc: no procps in the image) and waits before removing. Task: M6-T8 --- scripts/e2e/phones.mjs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/e2e/phones.mjs b/scripts/e2e/phones.mjs index 3821d77..1ed4a0b 100644 --- a/scripts/e2e/phones.mjs +++ b/scripts/e2e/phones.mjs @@ -63,6 +63,21 @@ export function startPhones({ name, net, ast, phones }) { const f = join(dir, ext, 'log'); return existsSync(f) ? readFileSync(f, 'utf8') : ''; }, - stop: () => docker('rm', '-f', name), + /** + * baresip unregisters on SIGTERM; killing the container would leave stale "Avail" contacts + * behind (Asterisk keeps them until they expire) that a later script's phones then share. + */ + stop: () => { + // No procps in the image: find baresip through /proc. + docker( + 'exec', + name, + 'sh', + '-c', + 'for p in /proc/[0-9]*; do [ "$(cat $p/comm 2>/dev/null)" = baresip ] && kill -TERM ${p#/proc/}; done; true', + ); + spawnSync('sleep', ['2']); + docker('rm', '-f', name); + }, }; }