Skip to content

Commit 1e2cbff

Browse files
roypatpb8o
andcommitted
test: check that snapshots can be taken at current version
Add a test that verified that taking a snapshot with target_version set to the version specified in src/firecracker/Cargo.toml works, and yields a snapshot where --describe-snapshot returns that very same version again. This test covers the short window between a version bump before a release during which no new release binary has been uploaded to S3 yet. Previously, the existing tests would not catch if it was not possible to take a snapshot in the about-to-be-released version, as only versions that had their binaries in S3 were considered. Co-Authored-By: Pablo Barbáchano <[email protected]> Signed-off-by: Patrick Roy <[email protected]>
1 parent 7d7572e commit 1e2cbff

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

tests/integration_tests/functional/test_snapshot_version.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import pytest
88

99
from framework.artifacts import NetIfaceConfig
10-
from framework.builder import MicrovmBuilder, SnapshotBuilder
10+
from framework.builder import MicrovmBuilder, SnapshotBuilder, SnapshotType
11+
from framework.utils import get_firecracker_version_from_toml, run_cmd
12+
from host_tools.cargo_build import get_firecracker_binaries
1113

1214
# Firecracker v0.23 used 16 IRQ lines. For virtio devices,
1315
# IRQs are available from 5 to 23, so the maximum number
@@ -116,6 +118,47 @@ def test_create_invalid_version(bin_cloner_path):
116118
assert False, "Negative test failed"
117119

118120

121+
def test_snapshot_current_version(bin_cloner_path):
122+
"""Tests taking a snapshot at the version specified in Cargo.toml
123+
124+
Check that it is possible to take a snapshot at the version of the upcoming
125+
release (during the release process this ensures that if we release version
126+
x.y, then taking a snapshot at version x.y works - something we'd otherwise
127+
only be able to test once the x.y binary has been uploaded to S3, at which
128+
point it is too late, see also the 1.3 release).
129+
130+
@type: functional
131+
"""
132+
builder = MicrovmBuilder(bin_cloner_path)
133+
vm_instance = builder.build_vm_nano(diff_snapshots=True)
134+
vm = vm_instance.vm
135+
vm.start()
136+
137+
version = get_firecracker_version_from_toml()
138+
# normalize to a snapshot version
139+
(major, minor, _) = version.split(".", maxsplit=3)
140+
target_version = f"{major}.{minor}.0"
141+
# Create a snapshot builder from a microvm.
142+
snapshot_builder = SnapshotBuilder(vm)
143+
disks = [vm_instance.disks[0].local_path()]
144+
snapshot = snapshot_builder.create(
145+
disks,
146+
vm_instance.ssh_key,
147+
snapshot_type=SnapshotType.FULL,
148+
target_version=target_version,
149+
)
150+
151+
# Fetch Firecracker binary for the latest version
152+
fc_binary, _ = get_firecracker_binaries()
153+
# Verify the output of `--describe-snapshot` command line parameter
154+
cmd = [fc_binary] + ["--describe-snapshot", snapshot.vmstate]
155+
156+
code, stdout, stderr = run_cmd(cmd)
157+
assert code == 0, stderr
158+
assert stderr == ""
159+
assert target_version in stdout
160+
161+
119162
def test_create_with_newer_virtio_features(bin_cloner_path):
120163
"""
121164
Attempt to create a snapshot with newer virtio features.

0 commit comments

Comments
 (0)