1400 Snapshot and LabSnapshot
vm:snapshot() returns a Snapshot wrapping a single file.
lab:snapshot() returns a LabSnapshot wrapping a directory containing
per-VM snapshot files plus a lab.json index.
Both are thin handles over filesystem paths. They have no agent-side state, once the snapshot file or directory is on disk, the userdata gives you ergonomic access to it.
1400.1 Snapshot #
1400.1.1 Constructing #
| Source | Returns |
|---|---|
vm:snapshot() | New snapshot at a fresh tempfile. |
vm:snapshot("/explicit/path") | Snapshot at that exact path. |
A fixture's chunk returns a Snapshot (single-VM fixture); the harness reads the path, compresses + sparsifies the file, and installs it into the cache.
1400.1.2 Methods #
1400.1.3 snap:path() #
Returns the on-disk path as a Lua string.
1400.1.4 snap:size() #
Returns the file size in bytes. Returns 0 rather than ENOENT if the file has
been moved or deleted (idempotent with :delete()).
1400.1.5 snap:delete() #
Best-effort delete. Idempotent, calling on a path that's already gone is fine. Returns nothing.
1400.2 LabSnapshot #
1400.2.1 Constructing #
| Source | Returns |
|---|---|
lab:snapshot() | New lab snapshot in a fresh tempdir. |
provium:snapshot() | Same, on the root lab. |
A lab fixture's chunk returns a LabSnapshot; the harness moves the directory
into the cache as <key>.lab/.
1400.2.2 Methods #
1400.2.3 lab_snap:path() #
Returns the on-disk directory path as a Lua string.
1400.2.4 lab_snap:size() #
Returns the sum of file sizes directly under the directory (one level deep, doesn't recurse). Useful for picking large fixtures out of the cache.
1400.2.5 lab_snap:delete() #
Recursively deletes the directory. Idempotent, calling on a path that's already gone is fine.
1400.3 Example: build a fixture #
-- tests/fixtures/base.fixture.lua
local vm = provium::
vm::
return vm:
-- tests/fixtures/cluster.fixture.lua
provium:
local a = provium::
local b = provium::
provium.:
a:
b:
return provium:
-- tests/uses-base.test.lua
test
test
1400.4 See also #
- VM:
vm:snapshot(),vm:restore(). - Lab:
lab:snapshot(),lab:restore(),lab:vm_fixture(),lab:lab_fixture(). - Fixtures and dependencies, how snapshots become cached fixtures.