Improve test coverage for prepare plugins in image mode#4719
Draft
Improve test coverage for prepare plugins in image mode#4719
prepare plugins in image mode#4719Conversation
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>
Contributor
There was a problem hiding this comment.
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.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
- 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>
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.
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
Bootcpackage manager (tmt/package_managers/bootc.py) that enableprepare/installwith COPR andprepare/artifacton image mode guests:enable_copr()— delegates to the underlyingDnf/Dnf5package manager viabootc_builder. The copr plugin install anddnf copr enablewrite to/etcwhich persists in image mode.create_repository()— delegates toaux_engineto runcreaterepoon the live system.install_repository()— delegates toaux_engineto write.repofile to/etc/yum.repos.d/and refresh the package cache on the live system without triggering a container rebuild.create_repository()andinstall_repository()are not directly tested — they are trivial one-line delegations toaux_engineand will be exercised once theprepare/artifacttests are extended for image mode in a follow-up PR.Adds
TEST_IMAGE_MODE_IMAGESvariable andis_image_mode*helper functions totests/images.shCreates
/plans/provision/virtual-image-modeCI plan withPROVISION_HOW=virtual-image-modeenvironment. Tests can be marked to run in this plan using the tagprovision-virtual-image-mode.Adds corresponding Packit job
provision-virtual-image-modeto run the tests separatelyThe following existing tests are extended with image mode coverage (reboot persistence verification via
tmt-reboot):prepare/installprepare/shellprepare/recommendInner test plans gain
adjust: when: package_manager == bootcblocks that override the execute step to verify packages/repos and reboot.prepare/artifactprovision-containeronly withdistro == fedoragate. Code fixes are in place but test infrastructure needs refactoring.prepare/ansibleprepare/feature/epel,fips,profileprepare/distgitprepare/requireprovision-containeronly.Pull Request Checklist
Assisted-by: Claude Code