Remind users when a VM is still running after hanger vm ssh exits instead of silently dropping them back to the host shell.\n\nAttach a Firecracker vsock device to each VM, persist the host vsock path/CID,\nadd a new guest-side banger-vsock-pingd responder to the runtime bundle and both\nimage-build paths, and expose a vm.ping RPC that the CLI and TUI call after SSH\nreturns. Doctor and start/build preflight now validate the helper plus\n/dev/vhost-vsock so the feature fails early and clearly.\n\nValidated with go mod tidy, bash -n customize.sh, git diff --check, make build,\nand GOCACHE=/tmp/banger-gocache go test ./... outside the sandbox because the\ndaemon tests need real Unix/UDP sockets. Rebuild the image/rootfs used for new\nVMs so the guest ping service is present.
40 lines
1.7 KiB
Go
40 lines
1.7 KiB
Go
package daemon
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestBuildProvisionScriptInstallsDefaultTools(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
script := buildProvisionScript("devbox", "1.1.1.1", []string{"git", "curl"}, false)
|
|
for _, snippet := range []string{
|
|
"curl -fsSL https://mise.run | MISE_INSTALL_PATH='/usr/local/bin/mise' MISE_VERSION='v2025.12.0' sh",
|
|
"'/usr/local/bin/mise' use -g 'github:anomalyco/opencode'",
|
|
"cat > /etc/profile.d/mise.sh <<'EOF'",
|
|
"if [ -n \"${BASH_VERSION:-}\" ] && [ -x '/usr/local/bin/mise' ]; then",
|
|
`eval "$(/usr/local/bin/mise activate bash)"`,
|
|
`if ! grep -Fqx 'eval "$(/usr/local/bin/mise activate bash)"' '/etc/bash.bashrc'; then`,
|
|
`git clone --depth 1 'https://github.com/tmux-plugins/tpm' "$TMUX_PLUGIN_DIR/tpm"`,
|
|
`git clone --depth 1 'https://github.com/tmux-plugins/tmux-resurrect' "$TMUX_PLUGIN_DIR/tmux-resurrect"`,
|
|
`git clone --depth 1 'https://github.com/tmux-plugins/tmux-continuum' "$TMUX_PLUGIN_DIR/tmux-continuum"`,
|
|
"# >>> banger tmux plugins >>>",
|
|
"set -g @plugin 'tmux-plugins/tmux-resurrect'",
|
|
"set -g @plugin 'tmux-plugins/tmux-continuum'",
|
|
"set -g @continuum-save-interval '15'",
|
|
"set -g @continuum-restore 'off'",
|
|
"set -g @resurrect-dir '/root/.tmux/resurrect'",
|
|
"run '~/.tmux/plugins/tpm/tpm'",
|
|
"cat > /etc/modules-load.d/banger-vsock.conf <<'EOF'",
|
|
"vmw_vsock_virtio_transport",
|
|
"cat > /etc/systemd/system/banger-vsock-pingd.service <<'EOF'",
|
|
"ExecStart=/usr/local/bin/banger-vsock-pingd",
|
|
"systemctl enable --now banger-vsock-pingd.service || true",
|
|
"rm -f /root/get-docker /root/get-docker.sh /tmp/get-docker /tmp/get-docker.sh",
|
|
} {
|
|
if !strings.Contains(script, snippet) {
|
|
t.Fatalf("buildProvisionScript missing snippet %q\nscript:\n%s", snippet, script)
|
|
}
|
|
}
|
|
}
|