Skip to content

itest: New macro, support for tmt and debian autopkgtest, and more#246

Open
cgwalters wants to merge 1 commit intobootc-dev:mainfrom
cgwalters:itest-ext
Open

itest: New macro, support for tmt and debian autopkgtest, and more#246
cgwalters wants to merge 1 commit intobootc-dev:mainfrom
cgwalters:itest-ext

Conversation

@cgwalters
Copy link
Copy Markdown
Collaborator

A lot of stuff for itest, which is our Rust-based test framework for integration testing.

Fork-exec output capture: when not running under nextest or tmt, the harness re-executes itself per test to capture stdout/stderr, matching cargo test default behavior. ITEST_NOCAPTURE=1 disables for debugging.

Test metadata generation: --emit-tmt and --emit-autopkgtest flags generate FMF and DEP-8 metadata from registered tests, enabling tmt and autopkgtest to discover and run individual tests. Verified end-to-end with tmt.

TestMeta: per-test metadata struct (timeout, needs_root, isolation, tags, summary, needs_internet, flaky) that maps to tmt and autopkgtest fields. Stored in distributed slices alongside test functions.

Proc macro (#[itest::test_attr]): attribute macro that replaces the declarative macros for cleaner ergonomics. Preserves doc comments, handles error type conversion (anyhow/eyre/io::Error), supports async fn via automatic tokio runtime creation, and accepts all metadata as attribute arguments.

VM instance type: privileged_test! and booted_test! accept itype for VM sizing, threaded through require_root() to bcvk --itype.

The Justfile now prefers nextest with cargo test fallback, and fixes a pre-existing bug where set -e skipped cleanup on test failure.

Assisted-by: OpenCode (Claude Opus 4)

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new itest-macros crate to provide attribute macros for test registration, enhances the itest harness with output capture via fork-exec, and adds support for emitting test metadata in tmt (FMF) and autopkgtest (DEP-8) formats. My feedback highlights a potential naming collision in the generated static items and notes that the current output capture implementation may lose temporal ordering between stdout and stderr, though it remains acceptable for general use.

… capping

Major feature expansion of the itest integration test framework to
make it reusable across bootc-dev projects (bcvk, composefs-rs, bootc).

Fork-exec output capture: when not under nextest or tmt, the harness
re-executes itself per test to capture stdout/stderr, preventing
interleaved output from parallel tests.

Test metadata: --emit-tmt and --emit-autopkgtest flags generate FMF
and DEP-8 metadata from registered tests, enabling tmt and autopkgtest
to discover and run individual tests.  Per-test TestMeta (timeout,
needs_root, isolation, tags, flaky, etc.) maps to format-specific
fields.  Verified end-to-end with tmt.

Proc macro: #[itest::test_attr] attribute macro replaces the
declarative macros.  Preserves doc comments, auto-converts error
types (anyhow/eyre compatible), detects async fn and wraps with a
tokio runtime, and accepts all metadata as attribute arguments.

VM resource capping: when no explicit --itype is set, itest detects
host memory (from /proc/meminfo and cgroup v2/v1 limits) and caps
the VM to 70% of available memory.  Prevents OOM on constrained CI
runners like GHA (7 GiB / 2 vCPU).  Override via ITEST_VM_MEMORY_MIB,
ITEST_VM_VCPUS, or ITEST_VM_MEMORY_FRACTION.

Spiked on composefs-rs: 43 tests migrated, net -120 lines deleted,
all tests pass.

Assisted-by: OpenCode (Claude Opus 4)
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