Skip to content

Improve test coverage for prepare plugins in image mode#4719

Draft
thrix wants to merge 6 commits intomainfrom
issue-4606
Draft

Improve test coverage for prepare plugins in image mode#4719
thrix wants to merge 6 commits intomainfrom
issue-4606

Conversation

@thrix
Copy link
Contributor

@thrix thrix commented Mar 19, 2026

Fixes #4606

Get rid of the standalone tests/prepare/bootc/ and user rather the existing per-plugin prepare step test suites (prepare/install, prepare/shell, prepare/recommend). Extend them with image mode coverage on both CentOS Stream 10 and Fedora 44 bootc qcow2 images.

All image mode tests verify that prepared state (installed packages, enabled repos, excluded packages) persists after a reboot, which is critical for image mode where changes are applied via Containerfile rebuild + bootc switch + reboot.

Implements three missing methods in Bootc package manager (tmt/package_managers/bootc.py) that enable prepare/install with COPR and prepare/artifact on image mode guests:

  • enable_copr() — delegates to the underlying Dnf/Dnf5 package manager via bootc_builder. The copr plugin install and dnf copr enable write to /etc which persists in image mode.

  • create_repository() — delegates to aux_engine to run createrepo on the live system.

  • install_repository() — delegates to aux_engine to write .repo file to /etc/yum.repos.d/ and refresh the package cache on the live system without triggering a container rebuild.

create_repository() and install_repository() are not directly tested — they are trivial one-line delegations to aux_engine and will be exercised once the prepare/artifact tests are extended for image mode in a follow-up PR.

  • Adds TEST_IMAGE_MODE_IMAGES variable and is_image_mode* helper functions to tests/images.sh

  • Creates /plans/provision/virtual-image-mode CI plan with PROVISION_HOW=virtual-image-mode environment. Tests can be marked to run in this plan using the tag provision-virtual-image-mode.

  • Adds corresponding Packit job provision-virtual-image-mode to run the tests separately

The following existing tests are extended with image mode coverage (reboot persistence verification via tmt-reboot):

Test Scenarios on image mode
prepare/install existing packages, downloaded packages, COPR, debuginfo, exclude, escape
prepare/shell custom script with Containerfile assertions
prepare/recommend recommended packages with missing package handling

Inner test plans gain adjust: when: package_manager == bootc blocks that override the execute step to verify packages/repos and reboot.

Plugin Reason
prepare/artifact Currently provision-container only with distro == fedora gate. Code fixes are in place but test infrastructure needs refactoring.
prepare/ansible Runs ansible-playbook via SSH, cannot be deferred to Containerfile. Tracked in #4636.
prepare/feature/epel, fips, profile Use Ansible playbooks internally. To be covered with #4636 or follow-up.
prepare/distgit Existing test needs refactoring to support image mode provision.
prepare/require Currently provision-container only.

Pull Request Checklist

  • implement the feature
  • extend the test coverage

Assisted-by: Claude Code

Fixes #4606

Get rid of the standalone `tests/prepare/bootc/` and user rather
the existing per-plugin prepare step test suites (`prepare/install`, `prepare/shell`,
`prepare/recommend`). Extend them with image mode coverage on
both CentOS Stream 10 and Fedora 44 bootc qcow2 images.

All image mode tests verify that prepared state (installed packages,
enabled repos, excluded packages) persists after a reboot, which is
critical for image mode where changes are applied via Containerfile
rebuild + `bootc switch` + reboot.

Implements three missing methods in `Bootc` package manager
(`tmt/package_managers/bootc.py`) that enable `prepare/install`
with COPR and `prepare/artifact` on image mode guests:

- `enable_copr()` — delegates to the underlying `Dnf`/`Dnf5`
  package manager via `bootc_builder`. The copr plugin install
  and `dnf copr enable` write to `/etc` which persists in image
  mode.

- `create_repository()` — delegates to `aux_engine` to run
  `createrepo` on the live system.

- `install_repository()` — delegates to `aux_engine` to write
  `.repo` file to `/etc/yum.repos.d/` and refresh the package
  cache on the live system without triggering a container rebuild.

`create_repository()` and `install_repository()` are not directly
tested — they are trivial one-line delegations to `aux_engine` and
will be exercised once the `prepare/artifact` tests are extended
for image mode in a follow-up PR.

- Adds `TEST_IMAGE_MODE_IMAGES` variable and `is_image_mode*`
  helper functions to `tests/images.sh`

- Creates `/plans/provision/virtual-image-mode` CI plan with
  `PROVISION_HOW=virtual-image-mode` environment. Tests can be
  marked to run in this plan using the tag `provision-virtual-image-mode`.

- Adds corresponding Packit job `provision-virtual-image-mode` to run
  the tests separately

The following existing tests are extended with image mode coverage
(reboot persistence verification via `tmt-reboot`):

| Test | Scenarios on image mode |
|------|------------------------|
| `prepare/install` | existing packages, downloaded packages, COPR, debuginfo, exclude, escape |
| `prepare/shell` | custom script with Containerfile assertions |
| `prepare/recommend` | recommended packages with missing package handling |

Inner test plans gain `adjust: when: package_manager == bootc`
blocks that override the execute step to verify packages/repos
and reboot.

| Plugin | Reason |
|--------|--------|
| `prepare/artifact` | Currently `provision-container` only with `distro == fedora` gate. Code fixes are in place but test infrastructure needs refactoring. |
| `prepare/ansible` | Runs ansible-playbook via SSH, cannot be deferred to Containerfile. Tracked in #4636. |
| `prepare/feature/epel`, `fips`, `profile` | Use Ansible playbooks internally. To be covered with #4636 or follow-up. |
| `prepare/distgit` | Existing test needs refactoring to support image mode provision. |
| `prepare/require` | Currently `provision-container` only. |

Pull Request Checklist

* [x] implement the feature
* [x] extend the test coverage

Assisted-by: Claude Code

Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
@thrix thrix added test coverage Improvements or additions to test coverage of tmt itself ci | full test Pull request is ready for the full test execution plugin | install The prepare plugin for installing packages labels Mar 19, 2026
Copy link
Contributor

@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 significantly improves test coverage for prepare plugins in image mode by refactoring existing tests and adding new ones for bootc-based guests. It also implements missing methods in the Bootc package manager to support these tests. The changes are well-structured and the new test infrastructure is a valuable addition. I have one suggestion to simplify some of the new shell helper functions for better readability.

@thrix thrix marked this pull request as draft March 19, 2026 07:42
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this to backlog in planning Mar 19, 2026
@LecrisUT LecrisUT moved this from backlog to implement in planning Mar 19, 2026
thrix added 4 commits March 19, 2026 23:46
- Fix `tmt_plan` pattern in `.packit.yaml` to use trailing slash
  `/plans/provision/virtual/` preventing prefix match against
  `/plans/provision/virtual-image-mode/` plans

- Add `execute` step to `$tmt_steps` for image mode in install test
  so the inner reboot persistence test actually runs

- Fix `"total: 1 test passed"` assertion format (was `"1 test passed"`)

- Remove `"Collected command for Containerfile"` assertion in shell
  test (debug-level message not visible at `-arv` verbosity)

- Skip `Multiple Commandline Scripts` and `Remote Script` shell test
  phases on image mode: `/tmp` is tmpfs cleared on reboot, and
  `$TMT_PREPARE_SHELL_URL_REPOSITORY` env var is empty during
  Containerfile `RUN`

Assisted-by: Claude Code
Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
The prepare install test only needs to verify that the prepare step
works on image mode — it does not need to run the execute step.
Adding `execute` to `$tmt_steps` broke CLI-based test phases that
use `--insert` option.

The prepare step itself handles the container rebuild, `bootc switch`,
and reboot. If it completes successfully, packages are baked into the
new image — persistence is guaranteed by the bootc architecture.

Assisted-by: Claude Code
Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
Add a dedicated `/reboot-persistence` inner plan that installs
packages, verifies them, reboots via `tmt-reboot`, and re-verifies
after reboot. This tests the fundamental bootc guarantee that
packages baked into the image via Containerfile rebuild persist
across reboots.

The test runs as a separate phase only for image mode images,
using a full `tmt run --all` (including execute) so that
`tmt-reboot` works properly.

Assisted-by: Claude Code
Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
Move image mode plan under `/plans/provision/virtual/image-mode`
instead of a standalone file, as suggested by @happz. This keeps
all virtual provision plans together and allows running all virtual
plans with a single `/plans/provision/virtual/` selector.

Replace the `PROVISION_HOW=virtual-image-mode` intermediate value
with `IS_IMAGE_MODE=yes` set directly from the plan environment.
Tests now check `IS_IMAGE_MODE` instead of a special `PROVISION_HOW`
value, which is cleaner.

Update `.packit.yaml` to use regex `(?!image-mode)` to separate
the virtual and image-mode packit jobs.

Assisted-by: Claude Code
Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci | full test Pull request is ready for the full test execution plugin | install The prepare plugin for installing packages test coverage Improvements or additions to test coverage of tmt itself

Projects

Status: implement

Development

Successfully merging this pull request may close these issues.

Improve test coverage for prepare plugins in image mode

2 participants