Skip to content

Commit bf2ae25

Browse files
committed
chore: remove redundant snapshot version check for old FC versions
The snapshot version check was iterating over last several FC versions pulled from S3, but it was unnecessary since there were no cross FC checks. Remove checks of old FC versions and only test the current version. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent d130c7d commit bf2ae25

File tree

3 files changed

+10
-139
lines changed

3 files changed

+10
-139
lines changed

tests/framework/artifacts.py

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
"""Define classes for interacting with CI artifacts"""
55

66
import re
7-
from dataclasses import dataclass
87
from pathlib import Path
98
from typing import Iterator
109

1110
import pytest
1211

1312
from framework.defs import ARTIFACT_DIR
14-
from framework.utils import check_output, get_firecracker_version_from_toml
15-
from framework.with_filelock import with_filelock
16-
from host_tools.cargo_build import get_binary
1713

1814

1915
def select_supported_kernels():
@@ -55,101 +51,3 @@ def kernel_params(
5551
"""Return supported kernels"""
5652
for kernel in select(glob, artifact_dir):
5753
yield pytest.param(kernel, id=kernel.name)
58-
59-
60-
@dataclass(frozen=True, repr=True)
61-
class FirecrackerArtifact:
62-
"""Utility class for Firecracker binary artifacts."""
63-
64-
path: Path
65-
66-
@property
67-
def name(self):
68-
"""Get the Firecracker name."""
69-
return self.path.name
70-
71-
@property
72-
def jailer(self):
73-
"""Get the jailer with the same version."""
74-
return self.path.with_name(f"jailer-v{self.version}")
75-
76-
@property
77-
def version(self):
78-
"""Return Firecracker's version: `X.Y.Z-prerelase`."""
79-
# Get the filename, split on the first '-' and trim the leading 'v'.
80-
# sample: firecracker-v1.2.0-alpha
81-
return self.path.name.split("-", 1)[1][1:]
82-
83-
@property
84-
def version_tuple(self):
85-
"""Return the artifact's version as a tuple `(X, Y, Z)`."""
86-
return tuple(int(x) for x in self.version.split("."))
87-
88-
@property
89-
def snapshot_version_tuple(self):
90-
"""Return the artifact's snapshot version as a tuple: `X.Y.0`."""
91-
92-
# Starting from Firecracker v1.7.0, snapshots have their own version that is
93-
# independent of Firecracker versions. For these Firecracker versions, use
94-
# the --snapshot-version Firecracker flag, to figure out which snapshot version
95-
# it supports.
96-
97-
return (
98-
check_output([self.path, "--snapshot-version"])
99-
.stdout.strip()
100-
.split("\n")[0]
101-
.split(".")
102-
)
103-
104-
@property
105-
def snapshot_version(self):
106-
"""Return the artifact's snapshot version: `X.Y.0`.
107-
108-
Due to how Firecracker maps release versions to snapshot versions, we
109-
have to request the minor version instead of the actual version.
110-
"""
111-
return ".".join(str(x) for x in self.snapshot_version_tuple)
112-
113-
114-
@with_filelock
115-
def current_release(version):
116-
"""Massage this working copy Firecracker binary to look like a normal
117-
release, so it can run the same tests.
118-
"""
119-
binaries = []
120-
for binary in ["firecracker", "jailer"]:
121-
bin_path1 = get_binary(binary)
122-
bin_path2 = bin_path1.with_name(f"{binary}-v{version}")
123-
if not bin_path2.exists():
124-
bin_path2.unlink(missing_ok=True)
125-
bin_path2.hardlink_to(bin_path1)
126-
binaries.append(bin_path2)
127-
return binaries
128-
129-
130-
def working_version_as_artifact():
131-
"""
132-
Return working copy of Firecracker as a release artifact
133-
"""
134-
cargo_version = get_firecracker_version_from_toml()
135-
return FirecrackerArtifact(current_release(str(cargo_version))[0])
136-
137-
138-
def firecracker_artifacts():
139-
"""Return all supported firecracker binaries."""
140-
cargo_version = get_firecracker_version_from_toml()
141-
# until the next minor version (but *not* including)
142-
max_version = (cargo_version.major, cargo_version.minor + 1, 0)
143-
prefix = "firecracker/firecracker-*"
144-
for firecracker in sorted(ARTIFACT_DIR.glob(prefix)):
145-
match = re.match(r"firecracker-v(\d+)\.(\d+)\.(\d+)", firecracker.name)
146-
if not match:
147-
continue
148-
fc = FirecrackerArtifact(firecracker)
149-
version = fc.version_tuple
150-
if version >= max_version:
151-
continue
152-
yield pytest.param(fc, id=fc.name)
153-
154-
fc = working_version_as_artifact()
155-
yield pytest.param(fc, id=fc.name)

tests/integration_tests/functional/conftest.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/integration_tests/functional/test_cmd_line_parameters.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,30 @@
1111
from host_tools.fcmetrics import validate_fc_metrics
1212

1313

14-
def test_describe_snapshot_all_versions(
15-
microvm_factory, guest_kernel, rootfs, firecracker_release
16-
):
14+
def test_describe_snapshot(uvm_plain):
1715
"""
1816
Test `--describe-snapshot` correctness for all snapshot versions.
1917
2018
For each release create a snapshot and verify the data version of the
2119
snapshot state file.
2220
"""
2321

24-
target_version = firecracker_release.snapshot_version
25-
vm = microvm_factory.build(
26-
guest_kernel,
27-
rootfs,
28-
fc_binary_path=firecracker_release.path,
29-
jailer_binary_path=firecracker_release.jailer,
30-
)
31-
# FIXME: Once only FC versions >= 1.12 are supported, drop log_level="warn"
32-
vm.spawn(log_level="warn", serial_out_path=None)
22+
vm = uvm_plain
23+
fc_binary = vm.fc_binary_path
24+
25+
cmd = [fc_binary, "--snapshot-version"]
26+
snap_version_tuple = check_output(cmd).stdout.strip().split("\n")[0].split(".")
27+
snap_version = ".".join(str(x) for x in snap_version_tuple)
28+
3329
vm.basic_config(track_dirty_pages=True)
3430
vm.start()
3531
snapshot = vm.snapshot_diff()
36-
print("========== Firecracker create snapshot log ==========")
37-
print(vm.log_data)
3832
vm.kill()
3933

40-
# Fetch Firecracker binary
41-
fc_binary = microvm_factory.fc_binary_path
42-
# Verify the output of `--describe-snapshot` command line parameter
43-
cmd = [fc_binary] + ["--describe-snapshot", snapshot.vmstate]
34+
cmd = [fc_binary, "--describe-snapshot", snapshot.vmstate]
4435
_, stdout, stderr = check_output(cmd)
4536
assert stderr == ""
46-
assert target_version in stdout
37+
assert snap_version in stdout
4738

4839

4940
def test_cli_metrics_path(uvm_plain):

0 commit comments

Comments
 (0)