Refactor test fixtures#5902
Open
JamesC1305 wants to merge 3 commits into
Open
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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>
98ca9a6 to
c0c85bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
uvmfixture.tests/README.mdto reflect the new fixturesReason
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
uvmfixture. 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-levelpytestmarkassignments, 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
tools/devtool checkbuild --allto verify that the PR passesbuild checks on all supported architectures.
tools/devtool checkstyleto verify that the PR passes theautomated style checks.
how they are solving the problem in a clear and encompassing way.
in the PR.
CHANGELOG.md.Runbook for Firecracker API changes.
integration tests.
TODO.rust-vmm.