@@ -264,17 +264,59 @@ $systemd_run -u "mangos-test-${testid}-socat" -d -p SuccessExitStatus=130 -q --w
264264
265265step ssh into VM
266266
267- if $systemd_run -d --wait -q -p StandardOutput=journal -- ssh -i ./mkosi.key \
268- -o UserKnownHostsFile=/dev/null \
269- -o StrictHostKeyChecking=no \
270- -o LogLevel=ERROR \
271- -o ProxyCommand=" mkosi sandbox -- socat - VSOCK-CONNECT:42:%p" \
272- root@mkosi ' mangosctl --base-url=http://10.0.2.2:8081 updatectl add-overrides ; /usr/share/mangos/self_test.sh'
273- then
267+ # Stream the remote self-test live to the workflow console and also save to a logfile
268+ diag_ssh_out=" ${tmpdir} /self_test_ssh.out"
269+ echo " Streaming remote self-test output to ${diag_ssh_out} "
270+
271+ # Use direct ssh (with forced tty) so output is streamed live. Save output with tee.
272+ # Run ssh+tee in background and tail the logfile in foreground so CI logs show live output
273+ ssh_cmd=(ssh -tt -i ./mkosi.key
274+ -o UserKnownHostsFile=/dev/null
275+ -o StrictHostKeyChecking=no
276+ -o LogLevel=ERROR
277+ -o ProxyCommand=" mkosi sandbox -- socat - VSOCK-CONNECT:42:%p"
278+ root@mkosi " bash -lc 'mangosctl --base-url=http://10.0.2.2:8081 updatectl add-overrides ; /usr/share/mangos/self_test.sh'" )
279+
280+ # Ensure diag file exists
281+ touch " ${diag_ssh_out} "
282+
283+ # Trap to clean child processes on exit
284+ cleanup_ssh_tail () {
285+ if [ -n " ${ssh_pid:- } " ]; then
286+ kill " ${ssh_pid} " 2> /dev/null || true
287+ fi
288+ if [ -n " ${tail_pid:- } " ]; then
289+ kill " ${tail_pid} " 2> /dev/null || true
290+ fi
291+ }
292+ trap cleanup_ssh_tail EXIT
293+
294+ # Start ssh pipeline in background, using stdbuf to avoid buffering
295+ stdbuf -oL " ${ssh_cmd[@]} " 2>&1 | stdbuf -oL tee " ${diag_ssh_out} " &
296+ ssh_pid=$!
297+
298+ # Give ssh/tee a moment to start writing, then tail the logfile to stream live output
299+ sleep 1
300+ tail -n +1 -f " ${diag_ssh_out} " &
301+ tail_pid=$!
302+
303+ # Wait for ssh to finish
304+ wait ${ssh_pid}
305+ ssh_rc=$?
306+
307+ # Stop tailing
308+ kill ${tail_pid} 2> /dev/null || true
309+ wait ${tail_pid} 2> /dev/null || true
310+
311+ trap - EXIT
312+
313+ if [ ${ssh_rc} -eq 0 ]; then
274314 success
275- $ systemd_run -u " mangos-test-${testid} -result" -q -- echo " Mangos test ${testid} succeeded "
315+ echo " Mangos test ${testid} succeeded " | $ systemd_run -q - u " mangos-test-${testid} -result" -- cat
276316else
277317 failure
278- $systemd_run -u " mangos-test-${testid} -result" -q -- echo " Mangos test ${testid} failed"
279- exit 1
318+ echo " Mangos test ${testid} failed" | $systemd_run -q -u " mangos-test-${testid} -result" -- cat
319+ echo " --- Tail of remote self-test output (last 200 lines) ---"
320+ tail -n 200 " ${diag_ssh_out} " || true
321+ exit ${ssh_rc}
280322fi
0 commit comments