Skip to content

feat(image-test): run LISA test suites locally via 'image test'#292

Open
liunan-ms wants to merge 1 commit into
microsoft:mainfrom
liunan-ms:liunan/add_lisa
Open

feat(image-test): run LISA test suites locally via 'image test'#292
liunan-ms wants to merge 1 commit into
microsoft:mainfrom
liunan-ms:liunan/add_lisa

Conversation

@liunan-ms

@liunan-ms liunan-ms commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Previously LISA-type test suites were rejected by azldev image test and only served as metadata for external orchestration. This adds a local runner that generates a LISA runbook from a suite's configured test cases, boots the image in a QEMU VM, and runs the tests.

Changes

  • Extend LisaConfig with a framework git source, test-cases, pip pre-install/extras, and extra-args; validate that the framework ref is a full commit SHA and that test-cases is non-empty.
  • Generate a qemu-platform runbook that inlines the image path and an ephemeral admin key, with keep_environment=no so VMs are torn down after the run.
  • Auto-generate and clean up an ephemeral admin SSH key pair per run.
  • Require the image to already be qcow2 (reject other formats) before booting.
  • Regenerate CLI docs, JSON schema, and scenario snapshots.

Testing

  • mage unit — pass
  • mage check all — pass (golangci-lint, editorconfig, staticcheck, licenses, ruff, pyright)
  • mage scenarioUpdate — snapshots regenerated

Usage in microsoft/azurelinux#18042

Copilot AI review requested due to automatic review settings July 17, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enables running LISA-based image test suites locally via azldev image test, expanding the existing test-suite model (previously only pytest was runnable) to support generating a LISA runbook, booting the image via QEMU, and executing LISA against it.

Changes:

  • Extend test-suite configuration with an optional [lisa] subtable (LisaConfig) including framework git source + test cases and related options, plus validation of the framework ref and presence of test cases.
  • Add a local LISA runner that clones the framework repo at a pinned commit, creates/reuses a per-suite venv, generates a qemu-platform runbook, generates an ephemeral SSH keypair, and invokes LISA.
  • Regenerate schema, CLI docs, and scenario snapshots to reflect the new configuration surface.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
schemas/azldev.schema.json Generated JSON schema updates to include GitSourceConfig and LisaConfig.
scenario/snapshots/TestSnapshotsContainer_config_generate-schema_stdout_1.snap Snapshot refresh for schema generation output (container mode).
scenario/snapshots/TestSnapshots_config_generate-schema_stdout_1.snap Snapshot refresh for schema generation output (non-container mode).
internal/projectconfig/testsuite.go Adds LisaConfig, GitSourceConfig, and new validation logic for LISA suites.
internal/projectconfig/testsuite_test.go Unit tests for new LISA validation behavior.
internal/projectconfig/loader_test.go Loader test updated to parse and validate a LISA suite config.
internal/app/azldev/cmds/image/test.go Routes lisa suites to the new local runner and updates help text.
internal/app/azldev/cmds/image/lisarunner.go New implementation: clone framework, venv setup, runbook generation, qcow2 enforcement, and LISA invocation.
internal/app/azldev/cmds/image/lisarunbook.go New runbook YAML model + generator for QEMU platform.
internal/app/azldev/cmds/image/lisarunbook_internal_test.go Unit tests for runbook YAML generation.
docs/user/reference/cli/azldev_image_test.md Regenerated CLI docs describing LISA suite behavior.

Comment thread internal/projectconfig/testsuite.go Outdated
Comment thread internal/app/azldev/cmds/image/lisarunner.go
Comment thread internal/app/azldev/cmds/image/lisarunner.go
Comment thread internal/app/azldev/cmds/image/lisarunner.go
@liunan-ms liunan-ms changed the title feat: run LISA test suites locally via 'image test' feat (image-test): run LISA test suites locally via 'image test' Jul 17, 2026
@liunan-ms liunan-ms changed the title feat (image-test): run LISA test suites locally via 'image test' feat(image-test): run LISA test suites locally via 'image test' Jul 17, 2026
Previously LISA-type suites were rejected by 'azldev image test' and only
served as metadata for external orchestration. This adds a local runner
that generates a LISA runbook from a suite's configured test cases, boots
the image in a QEMU VM, and runs the tests.

- Extend LisaConfig with a framework git source, test-cases, pip
  pre-install/extras, and extra-args; validate that the framework ref is a
  full commit SHA and that test-cases is non-empty.
- Generate a qemu-platform runbook that inlines the image path and an
  ephemeral admin key, with keep_environment=no so VMs are torn down.
- Auto-generate and clean up an ephemeral admin SSH key pair per run.
- Require the image to be qcow2 (reject other formats) before booting.
- Regenerate CLI docs, JSON schema, and scenario snapshots.
Copilot AI review requested due to automatic review settings July 17, 2026 21:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

return fmt.Errorf("git is required to clone LISA repos:\n%w", err)
}

lisaBaseDir := filepath.Join(env.WorkDir(), lisaDirName)
Comment on lines +287 to +291
// Always checkout the pinned ref, even when reusing an existing checkout, so an
// interrupted or externally-modified clone still runs against the correct revision.
if err := gitProvider.Checkout(env, repoDir, source.Ref); err != nil {
return "", fmt.Errorf("failed to checkout %#q:\n%w", source.Ref, err)
}
Comment on lines +28 to +32
For LISA tests, the test runner executes on the host and boots the image in a
QEMU VM. azldev clones the LISA framework, generates a runbook from the suite's
configured test cases, and runs it against the image. azldev generates an
ephemeral SSH key pair to access the booted VM and removes it once the suite
finishes.
Comment on lines +371 to +378
// buildLisaArgs constructs the LISA command-line arguments. The runbook path is passed
// via -r, and extra-args are appended after placeholder expansion.
func buildLisaArgs(
runbookPath string,
extraArgs []string,
imageConfig *projectconfig.ImageConfig,
options *ImageTestOptions,
) []string {
@liunan-ms
liunan-ms marked this pull request as ready for review July 17, 2026 23:19
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.

2 participants