Use tmux for test runner — detachable SSH sessions
Tests now run inside a tmux session so you can disconnect and reconnect without interrupting multi-hour test runs. Changes: - create-vm.sh: cloud-init no longer auto-runs tests, just provisions packages and clones the repo. Installs a `darkforge-test` command in /usr/local/bin that wraps run-in-vm.sh in tmux. - run-in-vm.sh: detects when called as `darkforge-test` and re-execs inside a tmux session named "darkforge". --tmux flag for internal use. - README updated with tmux workflow (detach/reattach instructions). Workflow: ssh darkforge@<ip> darkforge-test --quick # starts in tmux Ctrl+B D # detach, go do other things tmux attach -t darkforge # come back later Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -144,6 +144,7 @@ packages:
|
||||
- bc
|
||||
- rsync
|
||||
- openssh
|
||||
- tmux
|
||||
|
||||
runcmd:
|
||||
# Grow the partition to fill the disk
|
||||
@@ -159,21 +160,26 @@ runcmd:
|
||||
echo "CLONE FAILED — manually clone the repo"
|
||||
'
|
||||
|
||||
# Copy the test runner
|
||||
# Create the darkforge-test convenience command
|
||||
- |
|
||||
if [ -f /home/darkforge/darkforge/tests/proxmox/run-in-vm.sh ]; then
|
||||
cp /home/darkforge/darkforge/tests/proxmox/run-in-vm.sh /home/darkforge/
|
||||
chown darkforge:darkforge /home/darkforge/run-in-vm.sh
|
||||
chmod +x /home/darkforge/run-in-vm.sh
|
||||
cat > /usr/local/bin/darkforge-test << 'DTEOF'
|
||||
#!/bin/bash
|
||||
SCRIPT="/home/darkforge/darkforge/tests/proxmox/run-in-vm.sh"
|
||||
if [ ! -f "$SCRIPT" ]; then
|
||||
echo "ERROR: Test script not found. Is the repo cloned?"
|
||||
echo " git clone --recurse-submodules https://git.dannyhaslund.dk/danny8632/darkforge.git ~/darkforge"
|
||||
exit 1
|
||||
fi
|
||||
ARGS="$*"
|
||||
exec tmux new-session -d -s darkforge \
|
||||
"bash ${SCRIPT} --tmux ${ARGS}; echo ''; echo 'Tests finished. Press Enter to close.'; read" \; \
|
||||
attach-session -t darkforge
|
||||
DTEOF
|
||||
chmod +x /usr/local/bin/darkforge-test
|
||||
|
||||
# Run the test suite automatically
|
||||
- |
|
||||
su - darkforge -c '
|
||||
if [ -f /home/darkforge/run-in-vm.sh ]; then
|
||||
bash /home/darkforge/run-in-vm.sh 2>&1 | tee /home/darkforge/test-output.log
|
||||
fi
|
||||
'
|
||||
# Signal that provisioning is done
|
||||
- touch /home/darkforge/.provisioned
|
||||
- chown darkforge:darkforge /home/darkforge/.provisioned
|
||||
CLOUDINIT
|
||||
|
||||
qm set "${VMID}" --cicustom "user=local:snippets/darkforge-test-init.yaml"
|
||||
@@ -187,23 +193,22 @@ echo ""
|
||||
echo "═══════════════════════════════════════════════"
|
||||
echo " VM ${VMID} created and starting."
|
||||
echo ""
|
||||
echo " The VM will:"
|
||||
echo " 1. Boot Arch Linux"
|
||||
echo " 2. Install required packages via cloud-init"
|
||||
echo " 3. Clone the DarkForge repository"
|
||||
echo " 4. Run the full test suite"
|
||||
echo " Cloud-init will install packages and clone the repo."
|
||||
echo " Wait ~5 min for provisioning, then SSH in to run tests."
|
||||
echo ""
|
||||
echo " Monitor progress:"
|
||||
echo " qm terminal ${VMID} (serial console)"
|
||||
echo " Get the VM IP:"
|
||||
echo " qm guest cmd ${VMID} network-get-interfaces | grep -oP '\"ip-address\":\\s*\"\\K[0-9.]+'"
|
||||
echo ""
|
||||
echo " SSH access (after boot):"
|
||||
echo " ssh darkforge@\$(qm guest cmd ${VMID} network-get-interfaces | grep -oP '\"ip-address\":\\s*\"\\K[0-9.]+')"
|
||||
echo " Password: darkforge"
|
||||
echo " SSH in:"
|
||||
echo " ssh darkforge@<IP> (password: darkforge)"
|
||||
echo ""
|
||||
echo " Or get IP:"
|
||||
echo " qm guest cmd ${VMID} network-get-interfaces"
|
||||
echo " Run tests in a tmux session (detachable):"
|
||||
echo " darkforge-test # starts tests in tmux"
|
||||
echo " darkforge-test --quick # fast mode (30 min)"
|
||||
echo ""
|
||||
echo " Collect report after tests finish:"
|
||||
echo " VM_IP=\$(qm guest cmd ${VMID} network-get-interfaces | grep -oP '\"ip-address\":\\s*\"\\K[0-9.]+')"
|
||||
echo " scp darkforge@\$VM_IP:/home/darkforge/darkforge/tests/report.* ./"
|
||||
echo " Detach from tmux: Ctrl+B then D"
|
||||
echo " Reattach later: tmux attach -t darkforge"
|
||||
echo ""
|
||||
echo " Collect report:"
|
||||
echo " scp darkforge@<IP>:~/darkforge/tests/report.* ./"
|
||||
echo "═══════════════════════════════════════════════"
|
||||
|
||||
Reference in New Issue
Block a user