-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat(cli): implement test subcommand for autopkgtests #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1705bc5
1c4819c
2fcc70f
35e242e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Tests: smoke | ||
| Depends: @ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/sh | ||
| set -e | ||
|
|
||
| debmagic --version | ||
| debmagic test --help |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # Running package tests | ||
|
|
||
| Quick reference for running a package's declared Debian autopkgtest tests with `debmagic test`. | ||
|
|
||
| ## TL;DR | ||
|
|
||
| - Entry point: `debmagic test` — runs tests from `debian/tests/control`; needs a prior `debmagic build` | ||
| - Requires a completed build in the same build root (or pass `--changes` to point at exported artifacts) | ||
|
|
||
| ```shell | ||
| cd your-package | ||
| debmagic build binary --driver docker | ||
| debmagic test --driver docker | ||
| ``` | ||
|
|
||
| ## What it does | ||
|
|
||
| `debmagic test` installs the binary packages from a prior build and runs the package's declared autopkgtest tests (`debian/tests/control`) | ||
| inside a **fresh, separate** driver-managed environment. | ||
| The test environment is never the build environment — even when `--persistent` reuses a container across runs, | ||
| the test tree is reset and the `.debs` are reinstalled each time. | ||
|
|
||
| The driver *is* the testbed: `autopkgtest` runs with the `null` backend inside the container (or on the host for the bare driver). No `autopkgtest-virt-*` backends are used. | ||
|
|
||
| ## Available options | ||
|
|
||
| | Option | Description | | ||
| |---|---| | ||
| | `--driver <...>` | Test environment driver (defaults to the driver recorded in the prior build's `environment.json`) | | ||
| | `--persistent` | Retain the test environment after the run for reattach/debug | | ||
| | `--strict` | Treat skipped tests and "no tests declared" as failures (exit code 2) | | ||
| | `--changes <path>` | Path to a `.changes` file whose directory supplies the built `.debs` (for pipeline use) | | ||
| | `--distro <name>` | Override the target distro for the test environment (defaults to the prior build's distro from `environment.json`, not the changelog) | | ||
| | `--proposed` | Enable the `<release>-proposed` pocket in the test environment | | ||
| | `--apt-mirror <url>` | Mirror URL (same as [`debmagic build`](build.md)) | | ||
| | `--source-dir <dir>` | Directory containing the `debian/` package directory | | ||
| | `--allow-host-test` | Allow the bare driver, which runs autopkgtest as root on the host | | ||
| | `--shell-on-failure` | On test failure, drop into an interactive shell in the test environment when stdout is a TTY | | ||
|
|
||
| Driver-specific flags (`--driver-docker-base-image`, `--driver-lxd-*`) mirror `debmagic build`. | ||
|
|
||
| ## Picking a driver | ||
|
|
||
| Use the same drivers as for builds. Pass `--driver` explicitly (or rely on the driver recorded in the prior build's `environment.json`): | ||
|
|
||
| | Driver | Isolation the Environment provides | | ||
| |---|---| | ||
| | `lxd` / `incus` | Container (`isolation-container`) | | ||
| | `docker` | Container (`isolation-container`) | | ||
| | `bare` | None — tests run as root on the host; requires `--allow-host-test` | | ||
|
|
||
| The driver *is* the testbed, so autopkgtest is told to run tests whose isolation restrictions the environment actually satisfies (`--ignore-restrictions`, only for those rungs). Tests that declare `Restrictions: isolation-container` therefore run on Docker/LXD/Incus instead of skipping. `isolation-machine` is not provided by any current driver (none is a VM); those tests still skip. Bare provides nothing, even with `--allow-host-test`. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lxd can be a vm - for convenience the best thing would be that the test env is upgraded to be a vm when a test requires isolation machine
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we always should have our driver selection and behavior deterministic and not automagic. I.e. if we try running a test which requires vm isolation hint that you can use the lxd driver.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, and the lxd should get a --vm flag or something |
||
|
|
||
| ## Exit codes | ||
|
|
||
| | Code | Meaning | | ||
| |---|---| | ||
| | `0` | All tests passed, or skips/no-tests were allowed | | ||
| | `1` | Test failure, testbed error, or other autopkgtest error | | ||
| | `2` | Strict-only failure: skipped tests or no tests declared under `--strict` | | ||
|
|
||
| autopkgtest skips tests whose `Restrictions:` the Environment cannot satisfy (today: `isolation-machine` on every current driver). Skips are reported loudly; use `--strict` to escalate them to exit code 2. | ||
|
|
||
| If no `debian/tests/control` exists (or it declares no tests), the run exits 0 with a notice — or exit 2 under `--strict`. | ||
|
|
||
| ## Inspecting a failed test run | ||
|
|
||
| On failure the test environment is torn down by default. Pass `--shell-on-failure` to drop into an interactive shell inside the test environment when stdout is a TTY (destroyed on shell exit unless `--persistent` was used). | ||
|
|
||
| Test output and logs are exported to a `test/` subdirectory of the build root; the path is printed at the end of the run. | ||
|
|
||
| ## Prior build required | ||
|
|
||
| By default `debmagic test` resolves the prior build from the build root (same layout as `debmagic shell`). If no build artifacts are found: | ||
| run `debmagic build` first | ||
|
|
||
| Use `--changes` to supply a `.changes` file from an exported output directory instead. | ||
|
|
||
| ## Bare driver | ||
|
|
||
| The bare driver runs autopkgtest as root directly on the host. | ||
| This violates the no-leak principle for normal use — pass `--allow-host-test` to opt in explicitly. | ||
Uh oh!
There was an error while loading. Please reload this page.