mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
The scripts waited with copies of the same loop: desktop.txtar's and nix_cache.txtar's waitfor files, and sh -c loops in link_life, fixture_v010_links, fixture_v010_small, ports and ports_stopped, each with its own interval and limit. They now use one testscript command, wait_until SCRIPT, which runs sh -c SCRIPT every 100 ms until it succeeds, for up to 90 s, and fails at once when every background command has ended, as wait_file does, or when SCRIPT exits 100 (waitGiveUp, a status no tool the scripts run gives), as the links check does when its session has ended. Contributing's tests page names it beside wait_file, whose limit it now says is 60 s. The docs workflow's release job installed every tool in the tag's mise.toml. It now installs only Go, Hugo by the name the tag gives it (hugo-extended before Hugo 0.170) and Node when the tag draws its diagrams, with --locked as mise-action did, picking them with mise's own reading of the tag's mise.toml (mise ls --current --json, the tag's file alone), and fails when the tag names no Hugo. MISE_AUTO_INSTALL is off for the job, so mise run docs:diagrams and the shims install nothing more, and a tool the pick missed fails the build. This job runs only at a release, so it hasn't run yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
61 lines
2.2 KiB
Plaintext
61 lines
2.2 KiB
Plaintext
# A stopped VM's listed ports are what it forwards when it runs, never a
|
|
# hold on them: another VM forwards them meanwhile. The running VM that
|
|
# forwards a port keeps it, and a VM that lists it too, started again,
|
|
# warns (ports_held) and forwards it once the other stops.
|
|
|
|
# The VMs' hostagent here: the test's runner, so their forwarders run on.
|
|
# Every VM listens on port P, one free on this host.
|
|
exec sh -c 'echo $PPID > "$STUB_DIR/hostagent"'
|
|
free_port P
|
|
exec sh -c 'printf "0100007F:%04X\n" '$P' > "$STUB_DIR/guest-ports"'
|
|
|
|
# VM a lists P and forwards it, then stops.
|
|
project a
|
|
exec devvm --network open --no-git-protect --ports $P
|
|
vm_name A a
|
|
wait_until 'sed -n 2p "$A_dir/run/ports.forwarded" 2>/dev/null | grep -qx '$P
|
|
exec devvm stop
|
|
wait_until '! ps -axww -o command= | grep -q -- "[_]ports -vm $A "'
|
|
|
|
# VM b lists P too, and forwards it: a, stopped, holds none of it.
|
|
project b
|
|
exec devvm --network open --no-git-protect --ports $P
|
|
! stderr 'ports_(taken|held)'
|
|
vm_name B b
|
|
wait_until 'sed -n 2p "$B_dir/run/ports.forwarded" 2>/dev/null | grep -qx '$P
|
|
|
|
# a starts again: b keeps P, and a says so, and forwards it once b stops.
|
|
# devvm ports and its JSON show who has it.
|
|
project a
|
|
exec devvm
|
|
stderr '^devvm: ports_held count=1 other='$B' ports='$P' vm='$A'$'
|
|
! stderr ports_taken
|
|
exec sh -c 'ps -axww -o command= | grep -- "[_]ports -vm $A "'
|
|
stdout ' -only '$P'$'
|
|
exec devvm ports
|
|
stdout '\A'$P'\n\z'
|
|
stderr '^devvm: ports_held count=1 other='$B' ports='$P' vm='$A'$'
|
|
exec devvm ports --json
|
|
stdout '"held_by": \[\n {\n "vm": "'$B'",\n "ports": "'$P'"\n }\n \]'
|
|
# b's own view: it holds P, and waits for no one.
|
|
project b
|
|
exec devvm ports --json
|
|
! stdout held_by
|
|
! stderr .
|
|
|
|
# b stops: a forwards P at its next report.
|
|
exec devvm stop
|
|
exec sh -c 'printf "0100007F:%04X\n0100007F:0016\n" '$P' > "$STUB_DIR/guest-ports"'
|
|
wait_until 'sed -n 2p "$A_dir/run/ports.forwarded" 2>/dev/null | grep -qx '$P
|
|
project a
|
|
exec devvm ports --json
|
|
! stdout held_by
|
|
|
|
# VM c forwards every port, and leaves P, which running a lists, alone.
|
|
project c
|
|
exec devvm --network open --no-git-protect --ports all
|
|
vm_name C c
|
|
wait_until 'grep -q "forwarding $C.s ports" "$C_dir/logs/ports.log" 2>/dev/null'
|
|
! grep 'port '$P': forwarded' $C_dir/logs/ports.log
|
|
exec devvm stop
|