Vmsync test implementation handover #
What's done #
Unit tests (45 tests, all passing) #
src/config.unit.test.ts:validateName,stripJsoncComments,vmDir,vmConfigPath,detectHypervisorsrc/boot.unit.test.ts:parseMemoryToBytes(exported for testing)src/import.unit.test.ts:nameFromPath(exported for testing)
Run unit tests with mise run //package/cli/vmsync:test:unit.
Run lifecycle tests with mise run //package/cli/vmsync:test:e2e.
Linux lifecycle e2e test (passing) #
src/lifecycle.expensive.unit.test.ts contains the Linux lifecycle test.
It is named .unit.test.ts because .e2e.test.ts is reserved for Playwright in this monorepo.
It uses sequential test structure because VM lifecycle tests share expensive external state.
Flow: creates Ubuntu VM via mvm, pushes tsdown bundle via virtiofs, installs mise+Node inside guest, runs all vmsync subcommands.
Run:
mise run //package/cli/vmsync:test:e2e
Windows lifecycle e2e test #
Implemented in src/lifecycle.expensive.unit.test.ts.
Current flow:
- Creates
vmsync-e2e-winviamvm create --image windows. - Pushes the bundled vmsync entry point via
mvm push. - Installs the Visual C++ runtime because
mise.exerequiresvcruntime140.dll. - Downloads the latest mise Windows zip via the GitHub release redirect.
- Installs Node through mise.
- Exercises help, list, status, config, and already-synced sync behavior.
The test assumes VirtioFsSvc maps the mvm-shared virtiofs tag to Z:\.
What changed in mvm #
virtiofs shared directory #
domain-xml.ts: addedsharedDirparam,<filesystem>+<memoryBacking>elementscloud-init.ts: auto-mountsmvm-sharedat/mnt/sharedvia cloud-initmountsdirectivecreate.ts+clone.ts: createshared/directory per VM, pass todomainXmlconfig.ts: addedSHARED_DIR_NAME,GUEST_MOUNT_POINT,WINDOWS_GUEST_MOUNT_POINTconstants
push/pull CLI commands #
file-transfer.ts:pushFile(host copy to shared dir),pullFile(read from shared dir)index-parsers-cmds.ts+index-parsers.ts: addedpushCmd,pullCmdparsers + union membersindex.ts: dispatch handlers for push/pullpackage.json: added./file-transferexport
Performance: 95 MB in ~90 ms via virtiofs (vs minutes via guest agent protocol).
Windows template changes #
autounattend-virtio.ts: includesviofsinVIRTIO_DRIVER_DIRStemplate-windows.ts: downloads the Windows ISO, virtio-win ISO, and WinFsp MSItemplate-windows.ts: installs WinFsp and VirtioFsSvc dependencies via guest agent after QEMU-GA is reachableautounattend.ts: does not embed mise. Windows lifecycle tests install mise at runtime.
Bug fix found #
import.ts was missing mkdir for the VM directory before calling qemu-img convert.
Added import { mkdir } from 'node:fs/promises' and await mkdir(dir, { recursive: true })
before convertSourceImage.
This is a real bug,
not test-specific.
Build setup #
tsdown.node.config.ts: bundles@monochromatic-dev/*,@optique/*,nano-spawnmise.toml:build:js:nodetask,test:e2edepends on itpackage.json: added@monochromatic-dev/config-tsdown,find-upas devDependencies
Key files #
| File | Purpose |
|---|---|
| `package/cli/vmsync/src/config.unit.test.ts` | Pure function unit tests |
| `package/cli/vmsync/src/boot.unit.test.ts` | parseMemoryToBytes tests |
| `package/cli/vmsync/src/import.unit.test.ts` | nameFromPath tests |
| `package/cli/vmsync/src/lifecycle.expensive.unit.test.ts` | Linux + Windows expensive lifecycle |
| `package/cli/vmsync/tsdown.node.config.ts` | Bundle config |
| `package/cli/vmsync/mise.toml` | Task definitions |
| `package/cli/mvm/src/file-transfer.ts` | virtiofs push/pull |
| `package/cli/mvm/src/domain-xml.ts` | virtiofs XML generation |
| `package/cli/mvm/src/autounattend-virtio.ts` | viofs driver addition |