tmt.steps.prepare package

Subpackages

Submodules

tmt.steps.prepare.ansible module

class tmt.steps.prepare.ansible.PrepareAnsible(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: PreparePlugin[PrepareAnsibleData]

Run Ansible playbooks against the guest, by running ansible-playbook for all given playbooks.

Note

The plugin requires a working Ansible to be available on the test runner.

Warning

When specifying playbooks with paths:

  • If a metadata tree root exists, all paths must be relative to the metadata tree root.

  • If the metadata tree root does not exist, all paths must be relative to the current working directory.

Warning

The plugin may be a subject of various limitations, imposed by Ansible itself:

  • Ansible 2.17+ no longer supports Python 3.6 and older. Guests where Python 3.7+ is not available cannot be prepared with the ansible plugin. This has been observed when Fedora Rawhide runner is used with CentOS 7 or CentOS Stream 8 guests. Possible workarounds: downgrade Ansible tmt uses, or install Python 3.7+ before using ansible plugin from an alternative repository or local build.

Run a single playbook on the guest:

prepare:
    how: ansible
    playbook: ansible/packages.yml
prepare --how ansible --playbook ansible/packages.yml

Run multiple playbooks in one phase, with extra arguments for ansible-playbook:

prepare:
    how: ansible
    playbook:
      - one.yml
      - two.yml
    extra-args: '-vvv'
prepare --how ansible --playbook one.yml --playbook two.yml --extra-args '-vvv'

Remote playbooks - provided as URLs starting with http:// or https://, local playbooks - optionally starting with a file:// schema, and playbooks bundled with collections can be referenced as well as local ones, and all kinds can be intermixed:

prepare:
    how: ansible
    playbook:
      - https://foo.bar/one.yml
      - two.yml
      - file://three.yml
      - ansible_galaxy_namespace.cool_collection.four
prepare --how ansible --playbook https://foo.bar/two.yml \
                      --playbook two.yml \
                      --playbook file://three.yml \
                      --playbook ansible_galaxy_namespace.cool_collection.four

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
essential_requires() list[DependencySimple | DependencyFmfId | DependencyFile]

Collect all essential requirements of the plugin.

Essential requirements of a plugin are necessary for the plugin to perform its basic functionality.

Returns:

a list of requirements.

go(*, guest: Guest, environment: Environment | None = None, logger: Logger) PluginOutcome

Prepare the guests

class tmt.steps.prepare.ansible.PrepareAnsibleData(name: str, how: str, order: int = 50, when: list[str] = <factory>, summary: str | None = None, where: list[str] = <factory>, playbook: list[str] = <factory>, extra_args: str | None = None)

Bases: PrepareStepData

extra_args: str | None = None
playbook: list[str]
classmethod pre_normalization(raw_data: _RawAnsibleStepData, logger: Logger) None

Called before normalization, useful for tweaking raw data

tmt.steps.prepare.distgit module

class tmt.steps.prepare.distgit.DistGitData(name: str, how: str, order: int = 60, when: list[str] = <factory>, summary: str | None = None, where: list[str] = <factory>, source_dir: tmt._compat.pathlib.Path | None = None, phase_name: str = <factory>, install_builddeps: bool = False, require: list['tmt.base.DependencySimple'] = <factory>)

Bases: PrepareStepData

install_builddeps: bool = False
order: int = 60
phase_name: str
require: list[tmt.base.DependencySimple]
source_dir: Path | None = None
tmt.steps.prepare.distgit.PHASE_ORDER_PREPARE_DISTGIT_RPMBUILD = 60

Application of patches by rpm-build command invoked by discover/fmf plugin when dist-git-source key is used.

class tmt.steps.prepare.distgit.PrepareDistGit(*, discover: DiscoverPlugin[Any] | None = None, future_requires: PreparePlugin[Any] | None = None, future_recommends: PreparePlugin[Any] | None = None, **kwargs: Any)

Bases: PreparePlugin[DistGitData]

Companion to the discover-dist-git, place where rpmbuild -bp happens

Step is responsible: 1. Install required packages for the rpmbuild itself 2. Detect and install build requires 3. Patch sources (rpmbuild -bp) 4. Move patched sources from buildroot into TMT_SOURCE_DIR 5. Call function of discover plugin to discover tests from TMT_SOURCE_DIR

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) PluginOutcome

Prepare the guests for building rpm sources

tmt.steps.prepare.distgit.insert_to_prepare_step(discover_plugin: DiscoverPlugin[Any], sourcedir: Path) None

Single place to call when inserting PrepareDistGit from discover

tmt.steps.prepare.install module

class tmt.steps.prepare.install.Copr(*args: Any, guest: Guest, **kwargs: Any)

Bases: Common

Initialize name and relation with the parent object

Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.

cli_invocation: 'tmt.cli.CliInvocation' | None = None
copr_plugin: str
enable_copr(repositories: list[str]) None

Enable requested copr repositories

enable_copr_epel6(copr: str) None

Manually enable copr repositories for epel6

guest: Guest
class tmt.steps.prepare.install.InstallApk(*, parent: PrepareInstall, guest: Guest, dependencies: list[DependencySimple], directories: list[Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallBase

Install packages using apk

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install_debuginfo() None

Install debuginfo packages

install_from_repository() None

Install packages from a repository

install_from_url() None

Install packages stored on a remote URL

install_local() None

Install packages stored in a local directory

class tmt.steps.prepare.install.InstallApt(*, parent: PrepareInstall, guest: Guest, dependencies: list[DependencySimple], directories: list[Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallBase

Install packages using apt

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install_debuginfo() None

Install debuginfo packages

install_from_repository() None

Install packages from a repository

install_from_url() None

Install packages stored on a remote URL

install_local() None

Install packages stored in a local directory

class tmt.steps.prepare.install.InstallBase(*, parent: PrepareInstall, guest: Guest, dependencies: list[DependencySimple], directories: list[Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: Common

Base class for installation implementations

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
debuginfo_packages: list[Package]
exclude: list[Package]
guest: Guest
install() None

Perform the actual installation

install_debuginfo() None

Default base install method for debuginfo packages

install_from_repository() None

Default base install method for packages from repositories

install_from_url() None

Default base install method for packages which are from URL

install_local() None

Default base install method for local packages

list_installables(title: str, *installables: Package | FileSystemPath | PackagePath | PackageUrl) Iterator[Package | FileSystemPath | PackagePath | PackageUrl]

Show package info and return package names

local_packages: list[PackagePath]
package_directory: Path
packages: list[Package | FileSystemPath]
prepare_install_local() None

Copy packages to the test system

prepare_installables(dependencies: list[DependencySimple], directories: list[Path]) None

Process package names and directories

remote_packages: list[PackageUrl]
rpm_check(package: str, mode: str = '-q') None

Run rpm command to check package existence

Throws tmt.utils.RunError

skip_missing: bool = False
class tmt.steps.prepare.install.InstallBootc(*, parent: PrepareInstall, guest: Guest, dependencies: list[DependencySimple], directories: list[Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallBase

Install packages using bootc container image mode

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install_debuginfo() None

Default base install method for debuginfo packages

install_from_repository() None

Default base install method for packages from repositories

install_from_url() None

Default base install method for packages which are from URL

install_local() None

Default base install method for local packages

class tmt.steps.prepare.install.InstallDnf(*, parent: PrepareInstall, guest: Guest, dependencies: list[DependencySimple], directories: list[Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallBase, Copr

Install packages using dnf

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
copr_plugin: str = 'dnf-plugins-core'
install_debuginfo() None

Install debuginfo packages

install_from_repository() None

Install packages from a repository

install_from_url() None

Install packages stored on a remote URL

install_local() None

Install packages stored in a local directory

class tmt.steps.prepare.install.InstallDnf5(*, parent: PrepareInstall, guest: Guest, dependencies: list[DependencySimple], directories: list[Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallDnf

Install packages using dnf5

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
copr_plugin: str = 'dnf5-command(copr)'
class tmt.steps.prepare.install.InstallMock(*, parent: PrepareInstall, guest: Guest, dependencies: list[DependencySimple], directories: list[Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallBase

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install_from_repository() None

Default base install method for packages from repositories

install_from_url() None

Default base install method for packages which are from URL

install_local() None

Default base install method for local packages

class tmt.steps.prepare.install.InstallRpmOstree(*, parent: PrepareInstall, guest: Guest, dependencies: list[DependencySimple], directories: list[Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallBase, Copr

Install packages using rpm-ostree

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
copr_plugin: str = 'dnf-plugins-core'
enable_copr(repositories: list[str]) None

Enable requested copr repositories

install_debuginfo() None

Install debuginfo packages

install_from_repository() None

Install packages from the repository

install_local() None

Install copied local packages

recommended_packages: list[Package | FileSystemPath]
required_packages: list[Package | FileSystemPath]
sort_packages() None

Identify required and recommended packages

class tmt.steps.prepare.install.InstallYum(*, parent: PrepareInstall, guest: Guest, dependencies: list[DependencySimple], directories: list[Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallDnf

Install packages using yum

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
copr_plugin: str = 'yum-plugin-copr'
class tmt.steps.prepare.install.PrepareInstall(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: PreparePlugin[PrepareInstallData]

Install packages on the guest.

Example config:

prepare:
    how: install
    copr: psss/tmt
    package: tmt-all
    missing: fail

Use copr for enabling a desired Copr repository and missing to choose whether missing packages should be silently ignored (skip) or a preparation error should be reported (fail), which is the default.

One or more RPM packages can be specified under the package attribute. The packages will be installed on the guest. They can either be specified using their names, paths to local rpm files or urls to remote rpms.

# Install local rpms using file path
prepare:
    how: install
    package:
        - tmp/RPMS/noarch/tmt-0.15-1.fc31.noarch.rpm
        - tmp/RPMS/noarch/python3-tmt-0.15-1.fc31.noarch.rpm
# Install remote packages using url
prepare:
    how: install
    package:
      - https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
      - https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-8.noarch.rpm
# Install the whole directory, exclude selected packages
prepare:
    how: install
    directory:
      - tmp/RPMS/noarch
    exclude:
      - tmt+all
      - tmt+provision-virtual
prepare:
    how: install
    # Repository with a group owner (@ prefixed) requires quotes, e.g.
    # copr: "@osci/rpminspect"
    copr: psss/tmt
    package: tmt-all
    missing: skip

Use directory to install all packages from given folder and exclude to skip selected packages (globbing characters are supported as well).

prepare:
    how: install
    directory: tmp/RPMS/noarch
    exclude: tmt+provision-virtual

Note

When testing ostree booted deployments tmt will use rpm-ostree as the package manager to perform the installation of requested packages. The current limitations of the rpm-ostree implementation are:

  • Cannot install new version of already installed local rpm.

  • No support for installing debuginfo packages at this time.

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) PluginOutcome

Perform preparation for the guests

class tmt.steps.prepare.install.PrepareInstallData(name: str, how: str, order: int = 50, when: list[str] = <factory>, summary: str | None = None, where: list[str] = <factory>, package: list[tmt.base.DependencySimple] = <factory>, directory: list[tmt._compat.pathlib.Path] = <factory>, copr: list[str] = <factory>, exclude: list[str] = <factory>, missing: Literal['skip', 'fail'] = 'fail')

Bases: PrepareStepData

copr: list[str]
directory: list[Path]
exclude: list[str]
missing: Literal['skip', 'fail'] = 'fail'
package: list[DependencySimple]

tmt.steps.prepare.shell module

class tmt.steps.prepare.shell.PrepareShell(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: PreparePlugin[PrepareShellData]

Prepare guest using shell (Bash) scripts.

Default shell options are applied to the script, see the test key specification for more details.

prepare:
    how: shell
    script:
      - sudo dnf install -y 'dnf-command(copr)'
      - sudo dnf copr enable -y psss/tmt
      - sudo dnf install -y tmt

Scripts can also be fetched from a remote git repository. Specify the url for the repository and optionally ref to checkout a specific branch, tag or commit. TMT_PREPARE_SHELL_URL_REPOSITORY will hold the value of the repository path.

prepare:
    how: shell
    url: https://github.com/teemtee/tmt.git
    ref: main
    script: cd $TMT_PREPARE_SHELL_URL_REPOSITORY && make docs

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) PluginOutcome

Prepare the guests

class tmt.steps.prepare.shell.PrepareShellData(name: str, how: str, order: int = 50, when: list[str] = <factory>, summary: str | None = None, where: list[str] = <factory>, script: list[tmt.utils.ShellScript] = <factory>, url: str | None = None, ref: str | None = None)

Bases: PrepareStepData

ref: str | None = None
script: list[ShellScript]
to_spec() dict[str, Any]

Convert to a form suitable for saving in a specification file

url: str | None = None

Module contents

class tmt.steps.prepare.DependencyCollection(guests: list[~tmt.steps.provision.Guest], dependencies: list[~tmt.base.DependencySimple] = <factory>)

Bases: object

Bundle guests and packages to install on them

property as_key: frozenset[DependencySimple]
dependencies: list[DependencySimple]
guests: list[Guest]
class tmt.steps.prepare.Prepare(*, plan: Plan, data: _RawStepData | list[_RawStepData], logger: Logger)

Bases: Step

Prepare the environment for testing.

Use the ‘order’ attribute to select in which order preparation should happen if there are multiple configs. Default order is ‘50’. Default order of required packages installation is ‘70’, for the recommended packages it is ‘75’.

Initialize prepare step data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
cli_invocations: list['tmt.cli.CliInvocation'] = []
go(force: bool = False) None

Prepare the guests

summary() None

Give a concise summary of the preparation

wake() None

Wake up the step (process workdir and command line)

class tmt.steps.prepare.PreparePlugin(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: Plugin[PrepareStepDataT, PluginOutcome]

Common parent of prepare plugins

Store plugin name, data and parent step

classmethod base_command(usage: str, method_class: type[Command] | None = None) Command

Create base click command (common for all prepare plugins)

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) PluginOutcome

Prepare the guest (common actions)

class tmt.steps.prepare.PrepareStepData(name: str, how: str, order: int = 50, when: list[str] = <factory>, summary: str | None = None, where: list[str] = <factory>)

Bases: WhereableStepData, StepData