Skip to content

Commit ae9aed2

Browse files
bchaliosroypat
authored andcommitted
test: remove snapshot forward-compatibility tests
We dropped support for Firecracker snapshots forward compatibility. Clean up the tests related to this functionality. Mainly remove tests that directly use the removed feature and re-organize some of the code to adapt to the now missing functionality. Signed-off-by: Babis Chalios <[email protected]>
1 parent 28587db commit ae9aed2

File tree

9 files changed

+56
-330
lines changed

9 files changed

+56
-330
lines changed

tests/framework/artifacts.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ def current_release(version):
125125
return binaries
126126

127127

128+
def working_version_as_artifact():
129+
"""
130+
Return working copy of Firecracker as a release artifact
131+
"""
132+
cargo_version = get_firecracker_version_from_toml()
133+
return FirecrackerArtifact(current_release(cargo_version.base_version)[0])
134+
135+
128136
def firecracker_artifacts():
129137
"""Return all supported firecracker binaries."""
130138
cargo_version = get_firecracker_version_from_toml()
@@ -141,7 +149,7 @@ def firecracker_artifacts():
141149
continue
142150
yield pytest.param(fc, id=fc.name)
143151

144-
fc = FirecrackerArtifact(current_release(cargo_version.base_version)[0])
152+
fc = working_version_as_artifact()
145153
yield pytest.param(fc, id=fc.name)
146154

147155

tests/framework/microvm.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,7 @@ def resume(self):
710710
"""Resume the microVM"""
711711
self.api.vm.patch(state="Resumed")
712712

713-
def make_snapshot(
714-
self, snapshot_type: SnapshotType | str, target_version: str = None
715-
):
713+
def make_snapshot(self, snapshot_type: SnapshotType | str):
716714
"""Create a Snapshot object from a microvm.
717715
718716
It pauses the microvm before taking the snapshot.
@@ -725,7 +723,6 @@ def make_snapshot(
725723
mem_file_path=str(mem_path),
726724
snapshot_path=str(vmstate_path),
727725
snapshot_type=snapshot_type.value,
728-
version=target_version,
729726
)
730727
root = Path(self.chroot())
731728
return Snapshot(
@@ -737,13 +734,13 @@ def make_snapshot(
737734
snapshot_type=snapshot_type,
738735
)
739736

740-
def snapshot_diff(self, target_version: str = None):
737+
def snapshot_diff(self):
741738
"""Make a Diff snapshot"""
742-
return self.make_snapshot("Diff", target_version)
739+
return self.make_snapshot("Diff")
743740

744-
def snapshot_full(self, target_version: str = None):
741+
def snapshot_full(self):
745742
"""Make a Full snapshot"""
746-
return self.make_snapshot("Full", target_version)
743+
return self.make_snapshot("Full")
747744

748745
def restore_from_snapshot(
749746
self,

tests/integration_tests/functional/test_api.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,28 +1291,6 @@ def test_map_private_seccomp_regression(test_microvm_with_api):
12911291
test_microvm.api.mmds.put(**data_store)
12921292

12931293

1294-
def test_negative_snapshot_create_api(microvm_factory, guest_kernel, rootfs):
1295-
"""
1296-
Test snapshot create API.
1297-
"""
1298-
1299-
vm = microvm_factory.build(guest_kernel, rootfs)
1300-
vm.spawn()
1301-
vm.basic_config()
1302-
vm.start()
1303-
1304-
# Specifying `version` in the create API is deprecated
1305-
vm.pause()
1306-
response = vm.api.snapshot_create.put(
1307-
mem_file_path="mem",
1308-
snapshot_path="vmstate",
1309-
snapshot_type="Full",
1310-
version="1.4.0",
1311-
)
1312-
assert response.headers["deprecation"]
1313-
assert "PUT /snapshot/create: 'version' field is deprecated." in vm.log_data
1314-
1315-
13161294
# pylint: disable=protected-access
13171295
def test_negative_snapshot_load_api(microvm_factory):
13181296
"""

tests/integration_tests/functional/test_drives.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -361,46 +361,6 @@ def test_flush(uvm_plain_rw):
361361
assert fc_metrics["block"]["flush_count"] > 0
362362

363363

364-
def test_block_default_cache_old_version(test_microvm_with_api):
365-
"""
366-
Verify that saving a snapshot for old versions works correctly.
367-
"""
368-
test_microvm = test_microvm_with_api
369-
test_microvm.spawn()
370-
371-
test_microvm.basic_config(vcpu_count=1, add_root_device=False)
372-
373-
# Add the block device with explicitly enabling flush.
374-
test_microvm.add_drive(
375-
"rootfs",
376-
test_microvm.rootfs_file,
377-
is_root_device=True,
378-
cache_type="Writeback",
379-
)
380-
381-
test_microvm.start()
382-
383-
# Pause the VM to create the snapshot.
384-
test_microvm.pause()
385-
386-
# Create the snapshot for a version without block cache type.
387-
test_microvm.api.snapshot_create.put(
388-
mem_file_path="memfile",
389-
snapshot_path="snapsfile",
390-
snapshot_type="Full",
391-
version="0.24.0",
392-
)
393-
394-
# We should find a warning in the logs for this case as this
395-
# cache type was not supported in 0.24.0 and we should default
396-
# to "Unsafe" mode.
397-
test_microvm.check_log_message(
398-
"Target version does not implement the"
399-
" current cache type. "
400-
'Defaulting to "unsafe" mode.'
401-
)
402-
403-
404364
def _check_block_size(ssh_connection, dev_path, size):
405365
_, stdout, stderr = ssh_connection.run("blockdev --getsize64 {}".format(dev_path))
406366
assert stderr == ""

tests/integration_tests/functional/test_mmds.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import pytest
1111

12+
from framework.artifacts import working_version_as_artifact
1213
from framework.properties import global_props
1314
from framework.utils import (
1415
configure_mmds,
@@ -33,7 +34,6 @@ def _validate_mmds_snapshot(
3334
basevm,
3435
microvm_factory,
3536
version,
36-
target_fc_version=None,
3737
fc_binary_path=None,
3838
jailer_binary_path=None,
3939
):
@@ -76,7 +76,7 @@ def _validate_mmds_snapshot(
7676
run_guest_cmd(ssh_connection, cmd, data_store, use_json=True)
7777

7878
# Create snapshot.
79-
snapshot = basevm.snapshot_full(target_version=target_fc_version)
79+
snapshot = basevm.snapshot_full()
8080

8181
# Resume microVM and ensure session token is still valid on the base.
8282
response = basevm.resume()
@@ -591,22 +591,22 @@ def test_mmds_limit_scenario(test_microvm_with_api, version):
591591

592592

593593
@pytest.mark.parametrize("version", MMDS_VERSIONS)
594-
def test_mmds_snapshot(uvm_nano, microvm_factory, version, firecracker_release):
594+
def test_mmds_snapshot(uvm_nano, microvm_factory, version):
595595
"""
596596
Test MMDS behavior by restoring a snapshot on current FC versions.
597597
598598
Ensures that the version is persisted or initialised with the default if
599599
the firecracker version does not support it.
600600
"""
601601

602+
current_release = working_version_as_artifact()
602603
uvm_nano.add_net_iface()
603604
_validate_mmds_snapshot(
604605
uvm_nano,
605606
microvm_factory,
606607
version,
607-
target_fc_version=firecracker_release.snapshot_version,
608-
fc_binary_path=firecracker_release.path,
609-
jailer_binary_path=firecracker_release.jailer,
608+
fc_binary_path=current_release.path,
609+
jailer_binary_path=current_release.jailer,
610610
)
611611

612612

@@ -640,7 +640,6 @@ def test_mmds_older_snapshot(
640640
microvm,
641641
microvm_factory,
642642
mmds_version,
643-
firecracker_release.snapshot_version,
644643
*get_firecracker_binaries(),
645644
)
646645

tests/integration_tests/functional/test_snapshot_advanced.py

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33
"""Advanced tests scenarios for snapshot save/restore."""
44

5-
import platform
65
import tempfile
76

87
import pytest
@@ -55,51 +54,6 @@ def test_restore_old_to_current(
5554
print(vm.log_data)
5655

5756

58-
def test_restore_current_to_old(microvm_factory, uvm_plain, firecracker_release):
59-
"""
60-
Restore current snapshot with previous versions of Firecracker.
61-
62-
For each firecracker release:
63-
1. Snapshot with the current build
64-
2. Restore with the past release
65-
"""
66-
67-
# Microvm: 2vCPU 256MB RAM, balloon, 4 disks and 4 net devices.
68-
vm = uvm_plain
69-
vm.spawn()
70-
vm.basic_config(track_dirty_pages=True)
71-
72-
# Create a snapshot with current FC version targeting the old version.
73-
snapshot = create_snapshot_helper(
74-
vm,
75-
target_version=firecracker_release.snapshot_version,
76-
drives=scratch_drives,
77-
balloon=True,
78-
diff_snapshots=True,
79-
)
80-
81-
# Resume microvm using FC/Jailer binary artifacts.
82-
vm = microvm_factory.build(
83-
fc_binary_path=firecracker_release.path,
84-
jailer_binary_path=firecracker_release.jailer,
85-
)
86-
vm.spawn()
87-
vm.restore_from_snapshot(snapshot, resume=True)
88-
validate_all_devices(vm, True)
89-
print("========== Firecracker restore snapshot log ==========")
90-
print(vm.log_data)
91-
92-
93-
@pytest.mark.skipif(platform.machine() != "x86_64", reason="TSC is x86_64 specific.")
94-
def test_save_tsc_old_version(uvm_nano):
95-
"""
96-
Test TSC warning message when saving old snapshot.
97-
"""
98-
uvm_nano.start()
99-
uvm_nano.snapshot_full(target_version="0.24.0")
100-
uvm_nano.check_log_message("Saving to older snapshot version, TSC freq")
101-
102-
10357
def validate_all_devices(microvm, balloon):
10458
"""Perform a basic validation for all devices of a microvm."""
10559
# Test that net devices have connectivity after restore.
@@ -139,7 +93,6 @@ def validate_all_devices(microvm, balloon):
13993

14094
def create_snapshot_helper(
14195
vm,
142-
target_version=None,
14396
drives=None,
14497
balloon=False,
14598
diff_snapshots=False,
@@ -196,7 +149,7 @@ def create_snapshot_helper(
196149
exit_code, _, _ = vm.ssh.run(cmd)
197150
assert exit_code == 0
198151

199-
snapshot = vm.make_snapshot(snapshot_type, target_version=target_version)
152+
snapshot = vm.make_snapshot(snapshot_type)
200153
print("========== Firecracker create snapshot log ==========")
201154
print(vm.log_data)
202155
vm.kill()

tests/integration_tests/functional/test_snapshot_basic.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212

1313
import host_tools.drive as drive_tools
1414
from framework.microvm import SnapshotType
15-
from framework.utils import check_filesystem, wait_process_termination
15+
from framework.utils import (
16+
check_filesystem,
17+
get_firecracker_version_from_toml,
18+
run_cmd,
19+
wait_process_termination,
20+
)
1621
from framework.utils_vsock import (
1722
ECHO_SERVER_PORT,
1823
VSOCK_UDS_PATH,
@@ -23,6 +28,7 @@
2328
make_host_port_path,
2429
start_guest_echo_server,
2530
)
31+
from host_tools.cargo_build import get_firecracker_binaries
2632

2733

2834
def _get_guest_drive_size(ssh_connection, guest_dev_name="/dev/vdb"):
@@ -35,6 +41,32 @@ def _get_guest_drive_size(ssh_connection, guest_dev_name="/dev/vdb"):
3541
return lines[1].strip()
3642

3743

44+
def test_snapshot_current_version(uvm_nano):
45+
"""Tests taking a snapshot at the version specified in Cargo.toml
46+
47+
Check that it is possible to take a snapshot at the version of the upcoming
48+
release (during the release process this ensures that if we release version
49+
x.y, then taking a snapshot at version x.y works - something we'd otherwise
50+
only be able to test once the x.y binary has been uploaded to S3, at which
51+
point it is too late, see also the 1.3 release).
52+
"""
53+
vm = uvm_nano
54+
vm.start()
55+
56+
version = get_firecracker_version_from_toml()
57+
# normalize to a snapshot version
58+
version = f"{version.major}.{version.minor}.0"
59+
snapshot = vm.snapshot_full()
60+
61+
# Fetch Firecracker binary for the latest version
62+
fc_binary, _ = get_firecracker_binaries()
63+
# Verify the output of `--describe-snapshot` command line parameter
64+
cmd = [str(fc_binary)] + ["--describe-snapshot", str(snapshot.vmstate)]
65+
66+
_, stdout, _ = run_cmd(cmd)
67+
assert version in stdout
68+
69+
3870
# Testing matrix:
3971
# - Guest kernel: All supported ones
4072
# - Rootfs: Ubuntu 18.04

0 commit comments

Comments
 (0)