mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
Refusals and help that need a person now say 'in a terminal without --no-input', as no_terminal_fetch and no_terminal_delete did: each message names the command to run, so the condition sits in it rather than being added by UI.Refused. size_pending is for a stopped VM; size_pending_running keeps the restart hint for a running one. setup's size question goes through a Reporter the tests make (msg.Fake). Co-Authored-By: Claude Opus 5.5 <[email protected]>
184 lines
6.8 KiB
Plaintext
184 lines
6.8 KiB
Plaintext
# devvm size: a folder's VM's CPUs, memory and disk, changed from its next
|
|
# start, with a restart offered for a running one; with -g, the size new
|
|
# VMs get (config.toml's, else settings.json's) and where each came from.
|
|
|
|
# No VM yet.
|
|
project web
|
|
! exec devvm size
|
|
stderr '^devvm: no_vm_size dir=\S*/web$'
|
|
|
|
# A bad size is refused before devvm looks for the VM.
|
|
! exec devvm size --cpus many
|
|
stderr '^devvm: cpus_not_number flag=--cpus value="many"$'
|
|
stderr '^usage_help command=devvm size$'
|
|
! stderr no_vm_size
|
|
! exec devvm size --memory
|
|
stderr '^devvm: flag_needs_value flag=--memory form=--memory GiB$'
|
|
|
|
# -g: the size new VMs get, unset (the image's) until it's set; each change
|
|
# keeps what it leaves unset. No VM is looked at.
|
|
stub_reset
|
|
exec devvm size -g
|
|
cmp stdout $WORK/unset
|
|
exec devvm size -g --cpus 2 --memory 3G
|
|
stdout '^==> size_defaults size=cpus=2 memory=3GiB$'
|
|
exec devvm size -g --memory=2.5GiB
|
|
stdout '^==> size_defaults size=cpus=2 memory=2\.5GiB$'
|
|
exec devvm size -g
|
|
cmp stdout $WORK/set
|
|
# --json: what's unset left out; it only shows.
|
|
exec devvm size -g --json
|
|
stdout '\A{\n "version": 1,\n "cpus": 2,\n "memory_gib": 2\.5,\n "sources": {\n "cpus": "settings.json",\n "disk": "built-in",\n "memory": "settings.json"\n }\n}\n\z'
|
|
! exec devvm size -g --json --cpus 4
|
|
stderr '^devvm: json_shows_only command=devvm size$'
|
|
grep '^ "size": {\n "cpus": "2",\n "memory": "2\.5"\n },?$' $DATA/settings.json
|
|
! exec devvm size -g --cpus 9999
|
|
stderr '^devvm: too_many_cpus have=8 want=9999$'
|
|
! exec devvm size -g --memory 16M
|
|
stderr '^devvm: size_not_gib flag=--memory value="16M"$'
|
|
! stub_calls
|
|
# config.toml's memory wins, and -g shows where it came from; -g refuses
|
|
# to change it, naming the file and the key, and changes what it leaves.
|
|
cp $WORK/memory.toml $CFG/config.toml
|
|
exec devvm size -g
|
|
stdout '\Acpus=2 # devvm: settings\.json\nmemory=6 # \S*/config/devvm/config\.toml\ndisk= # devvm: default\n\z'
|
|
exec devvm size -g --json
|
|
stdout '"memory": "config.toml"'
|
|
! exec devvm size -g --memory 4
|
|
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=size\.memory$'
|
|
! exec devvm size -g --cpus 1 --memory 4
|
|
stderr '^devvm: set_in_config '
|
|
grep '"cpus": "2"' $DATA/settings.json
|
|
exec devvm size -g --cpus 1
|
|
stdout '^==> size_defaults size=cpus=1 memory=6GiB$'
|
|
# A hand-edited config.toml with a bad value is refused, to show or
|
|
# change, naming its line.
|
|
cp $WORK/bad-size.toml $CFG/config.toml
|
|
! exec devvm size -g
|
|
stderr '^devvm: size_failed reason=\S*/config/devvm/config\.toml:3: size_not_gib flag=memory value="1\$\(touch x\)"$'
|
|
! exec devvm size -g --cpus 2
|
|
stderr '^devvm: size_failed reason=\S*/config/devvm/config\.toml:3: '
|
|
rm $CFG/config.toml
|
|
cp $WORK/features-none.json $DATA/settings.json
|
|
|
|
# A new VM. Running: devvm size shows what it has, and a change waits for
|
|
# its next start. It has 2 CPUs, which any host running the tests has.
|
|
exec devvm --network open --no-git-protect
|
|
vm_name WEB web
|
|
exec stub size $WEB 2 8589934592 107374182400
|
|
exec devvm size
|
|
stdout '\Acpus=2 memory=8GiB disk=100GiB\n\z'
|
|
! stderr .
|
|
exec devvm size --json
|
|
stdout '\A{\n "version": 1,\n "cpus": 2,\n "memory_gib": 8,\n "disk_gib": 100\n}\n\z'
|
|
! stderr .
|
|
stub_reset
|
|
exec devvm size --cpus 1 --memory 3
|
|
stderr '^devvm: next_start count=1 vm=devvm-web-[0-9a-f]{14}$'
|
|
! stdout vm_size
|
|
stub_calls
|
|
! stdout 'limactl edit'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^size.cpus=1$'
|
|
stdout '^size.memory=3$'
|
|
exec devvm size
|
|
stdout '\Acpus=2 memory=8GiB disk=100GiB\n\z'
|
|
stderr '^size_pending_running size=cpus=1 memory=3GiB vm=devvm-web-[0-9a-f]{14}$'
|
|
exec devvm size --json
|
|
stdout '^ "disk_gib": 100,\n "pending": {\n "cpus": 1,\n "memory_gib": 3\n }\n}\n\z'
|
|
stderr '^size_pending_running '
|
|
# Back to what it has: nothing waits.
|
|
exec devvm size --cpus 2 --memory 8
|
|
stdout '^==> vm_size size=cpus=2 memory=8GiB disk=100GiB vm=devvm-web-[0-9a-f]{14}$'
|
|
! stderr .
|
|
# A smaller disk is refused, running or not, and so is more than this
|
|
# machine has.
|
|
! exec devvm size --disk 50
|
|
stderr '^devvm: disk_shrink have=100 vm=devvm-web-[0-9a-f]{14} want=50$'
|
|
! exec devvm size --cpus 9999
|
|
stderr '^devvm: too_many_cpus have=8 want=9999$'
|
|
! exec devvm size --cpus 1.5
|
|
stderr '^devvm: cpus_not_number flag=--cpus value="1\.5"$'
|
|
|
|
# Stopped: saved, and changed at its next start, only what differs, in
|
|
# that start's one edit.
|
|
exec limactl stop $WEB
|
|
stub_reset
|
|
exec devvm size --cpus 1 --memory 8 --disk 120GiB
|
|
stdout '^==> size_pending size=cpus=1 disk=120GiB vm=devvm-web-[0-9a-f]{14}$'
|
|
exec devvm size
|
|
stderr '^size_pending size=cpus=1 disk=120GiB vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl edit'
|
|
stub_reset
|
|
exec devvm
|
|
stub_calls
|
|
stdout '^limactl edit --tty=false devvm-web-[0-9a-f]{14} --cpus 1 --disk 120( |$)'
|
|
! stdout '(?s)limactl edit --tty=false devvm-web.*limactl edit --tty=false devvm-web'
|
|
exec devvm size
|
|
stdout '\Acpus=1 memory=8GiB disk=120GiB\n\z'
|
|
! stderr .
|
|
! exec devvm size --disk 100
|
|
stderr '^devvm: disk_shrink have=120 vm=devvm-web-[0-9a-f]{14} want=100$'
|
|
|
|
# --cpus on devvm is ignored, with a warning naming devvm size.
|
|
exec devvm --cpus 3
|
|
stderr '^devvm: new_vm_flags_ignored_run command=devvm size flags=--cpus vm=devvm-web-[0-9a-f]{14}$'
|
|
|
|
# Opening it while a new size waits: without a terminal, the warnings
|
|
# alone, and it keeps running.
|
|
exec devvm size --cpus 2
|
|
stderr '^devvm: next_start count=1 vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_reset
|
|
exec devvm
|
|
stderr '^devvm: next_start_size vm=devvm-web-[0-9a-f]{14}\ndevvm: next_start count=1 vm=devvm-web-[0-9a-f]{14}$'
|
|
! stderr 'restart_now'
|
|
stub_calls
|
|
! stdout 'limactl (stop|edit)'
|
|
# In a terminal, one question after the line naming what waits, no by
|
|
# default: no keeps the warning and the VM running.
|
|
stub_reset
|
|
ttyin -stdin $WORK/no.txt
|
|
exec devvm
|
|
stderr '^next_start_size vm=devvm-web-[0-9a-f]{14}$'
|
|
stderr '^restart_now count=1 vm=devvm-web-[0-9a-f]{14} \[y/N\] '
|
|
stderr 'devvm: next_start count=1 vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl (stop|edit)'
|
|
# Yes stops it and starts it with its new size, then sets it up (which
|
|
# fails here, so the run ends before its shell).
|
|
stub_reset
|
|
exec sh -c ': > "$STUB_DIR/sync-fails-with"'
|
|
ttyin -stdin $WORK/yes.txt
|
|
! exec devvm
|
|
stderr '^restart_now count=1 vm=devvm-web-[0-9a-f]{14} \[y/N\] '
|
|
! stderr 'next_start '
|
|
stdout '^==> starting vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl stop devvm-web-[0-9a-f]{14}\n(.*\n)*limactl edit --tty=false devvm-web-[0-9a-f]{14} --cpus 2( |$)'
|
|
rm $STUB_DIR/sync-fails-with
|
|
exec devvm size
|
|
stdout '\Acpus=2 memory=8GiB disk=120GiB\n\z'
|
|
|
|
-- unset --
|
|
cpus= # devvm: default
|
|
memory= # devvm: default
|
|
disk= # devvm: default
|
|
-- set --
|
|
cpus=2 # devvm: settings.json
|
|
memory=2.5 # devvm: settings.json
|
|
disk= # devvm: default
|
|
-- no.txt --
|
|
n
|
|
-- yes.txt --
|
|
y
|
|
-- features-none.json --
|
|
{"features": []}
|
|
-- memory.toml --
|
|
[size]
|
|
memory = "6GiB"
|
|
-- bad-size.toml --
|
|
# new VMs' size
|
|
[size]
|
|
memory = "1$(touch x)"
|