Skip to content

Refactor test fixtures#5902

Open
JamesC1305 wants to merge 3 commits into
firecracker-microvm:mainfrom
JamesC1305:refactor-test-fixtures
Open

Refactor test fixtures#5902
JamesC1305 wants to merge 3 commits into
firecracker-microvm:mainfrom
JamesC1305:refactor-test-fixtures

Conversation

@JamesC1305
Copy link
Copy Markdown
Contributor

Changes

  • Refactor test fixtures to centre around a single uvm fixture.
  • Update all tests to use new fixtures (NB: this PR does not try to alter the restrictions on test cases that run, it should be a 1:1 mapping from old to new)
  • Updated tests/README.md to reflect the new fixtures

Reason

Fixtures had become rather fragmented and unwieldy. With our current system, new test dimensions (e.g. PCI most recently) encourage new fixtures to be created to isolate values of the dimension.

With this PR, we take the approach of parameterizing the single uvm fixture. The fixture is open by default (tests all dimension values), so restrictions must be applied to limit the cases tested where necessary. This can be done either via module-level pytestmark assignments, or on individual tests using annotations. Some helpers have been defined to simplify the syntax for this (e.g. pin_guest_kernel()). This approach has the additional benefit of forcing developers to think about the restrictions they need to enforce on the test cases, rather than just picking the nearest fixture.

Primarily, this centralisation makes it easier to add new dimensions to existing tests, with the trade-off being that we must annotate functions where the new dimension is not to be tested.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

The problem:
Our python test suite had too many very similar but slightly different
test fixtures. Whenever a new test dimension was added, you would either
have to isolate it via creating a new fixture, or accept that all values
of the dimension will be run across the existing fixtures.

Solution:
Re-work existing test fixtures to instead focus around `uvm` fixture.
This fixture is open by default – all values of all dimensions are
tested by default (minus CPU templates and huge pages), and the tested
values can be restricted either at file-level (via `pytestmark`
variable) or at test-level via annotations.

This has two benefits -  1) it makes the dimensional restrictions more
explicit, a developer has to think more about what test cases are and
are not valuable. 2) it makes it easier to add new tested dimensions
without fragmenting fixtures, at the cost of having to annotate older
tests to not include certain values of the new dim (if we don't want
to test it for whatever reason)

Mapping of old fixtures -> new ones:
- uvm_plain_any -> uvm
- uvm_plain -> uvm w/ GUEST_KERNEL_DEFAULT
- uvm_plain_6_1 (removed, 6.1 set to default) -> uvm w/
GUEST_KERNEL_DEFAULT
- uvm_plain_acpi -> uvm w/ ACPI_GUEST_KERNELS
- uvm_plain_rw -> uvm w/ GUEST_KERNEL_DEFAULT + rootfs ‘rw'
- uvm_plain_debug -> uvm w/ GUEST_KERNEL_6_1_DEBUG
- uvm_booted -> uvm_booted [uvm w/ 2 vCPU + 256MiB memory + 1 net iface
+ cpu template (if specified)]
- uvm_restored -> uvm_restored [uvm_booted restored from snap]
- uvm_any -> uvm_booted + uvm_restored
- uvm_any_booted -> uvm_booted w/ any CPU templates
- uvm_any_with_pci -> uvm w/ ACPI, PCI and any CPU templates
- uvm_any_without_pci -> uvm w/ GUEST_KERNEL_DEFAULT and no PCI
- uvm_nano -> uvm_configured [uvm w/ 2 vCPU + 256MiB memory, spawned but
  not booted]

All old fixtures collapsed into uvm, uvm_configured, uvm_booted,
uvm_restored and uvm_any.

Signed-off-by: James Curtis <jxcurtis@amazon.co.uk>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.90%. Comparing base (c294d31) to head (c0c85bf).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5902   +/-   ##
=======================================
  Coverage   82.90%   82.90%           
=======================================
  Files         277      277           
  Lines       30058    30058           
=======================================
  Hits        24919    24919           
  Misses       5139     5139           
Flag Coverage Δ
5.10-m5n.metal ?
5.10-m6a.metal 82.54% <ø> (-0.01%) ⬇️
5.10-m6g.metal 79.84% <ø> (ø)
5.10-m6i.metal 83.20% <ø> (+<0.01%) ⬆️
5.10-m7a.metal-48xl 82.53% <ø> (ø)
5.10-m7g.metal 79.84% <ø> (ø)
5.10-m7i.metal-24xl 83.17% <ø> (+<0.01%) ⬆️
5.10-m7i.metal-48xl 83.17% <ø> (ø)
5.10-m8g.metal-24xl 79.84% <ø> (ø)
5.10-m8g.metal-48xl 79.84% <ø> (ø)
5.10-m8i.metal-48xl 83.17% <ø> (+<0.01%) ⬆️
5.10-m8i.metal-96xl 83.18% <ø> (+<0.01%) ⬆️
6.1-m5n.metal 83.23% <ø> (+<0.01%) ⬆️
6.1-m6a.metal 82.57% <ø> (ø)
6.1-m6g.metal 79.84% <ø> (ø)
6.1-m6i.metal 83.23% <ø> (ø)
6.1-m7a.metal-48xl 82.55% <ø> (ø)
6.1-m7g.metal 79.84% <ø> (+<0.01%) ⬆️
6.1-m7i.metal-24xl 83.23% <ø> (ø)
6.1-m7i.metal-48xl 83.24% <ø> (+<0.01%) ⬆️
6.1-m8g.metal-24xl 79.84% <ø> (ø)
6.1-m8g.metal-48xl 79.84% <ø> (ø)
6.1-m8i.metal-48xl 83.24% <ø> (+<0.01%) ⬆️
6.1-m8i.metal-96xl 83.24% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Refactor all python tests to use fixtures described in the previous
commit.

Signed-off-by: James Curtis <jxcurtis@amazon.co.uk>
Update the README to reflect the new state regarding fixtures.

Signed-off-by: James Curtis <jxcurtis@amazon.co.uk>
@JamesC1305 JamesC1305 force-pushed the refactor-test-fixtures branch from 98ca9a6 to c0c85bf Compare May 19, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant