tmt.steps.discover package
Submodules
tmt.steps.discover.fmf module
- class tmt.steps.discover.fmf.DiscoverFmf(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)
Bases:
DiscoverPlugin[DiscoverFmfStepData]Discover available tests from fmf metadata.
By default all available tests from the current repository are used so the minimal configuration looks like this:
discover: how: fmf
Full config example:
discover: how: fmf url: https://github.com/teemtee/tmt ref: main path: /fmf/root test: /tests/basic filter: 'tier: 1'
If no
refis provided, the default branch from the origin is used.For DistGit repo one can extract sources first and discover tests from it by using
distgit-source: truelater in Prepare step. It can be used together withref,pathandurl, howeverrefis not possible without usingurl.discover: how: fmf dist-git-source: true
Related config options (all optional):
dist-git-merge- set totrueif you want to copy in extracted sources to the local repodist-git-init- set totrueandfmf initwill be called inside extracted sources (atdist-git-extractor top directory)dist-git-extract- directory (glob supported) to copy from extracted sources (defaults to inner fmf root)dist-git-remove-fmf-root- set totrueto remove fmf root from extracted sources
Selecting tests containing specified link is possible using
linkkey acceptingRELATION:TARGETformat of values. Regular expressions are supported for both relation and target part of the value. Relation can be omitted to target match any relation.discover: how: fmf link: verifies:.*issue/850$
It is also possible to limit tests only to those that have changed in git since a given revision. This can be particularly useful when testing changes to tests themselves (e.g. in a pull request CI).
Related config options (all optional):
modified-only- set totrueif you want to filter modified testsmodified-url- fetched as “reference” remote in the test dirmodified-ref- the ref to compare against
Example to compare local repo against upstream
mainbranch:discover: how: fmf modified-only: True modified-url: https://github.com/teemtee/tmt modified-ref: reference/main
Note that internally the modified tests are appended to the list specified via
test, so those tests will also be selected even if not modified.Use the
adjust-testskey to modify the discovered tests’ metadata directly from the plan. For example, extend the test duration for slow hardware or modify the list of required packages when you do not have write access to the remote test repository. The value should follow theadjustrules syntax.The following example adds an
avccheck for each discovered test, doubles its duration and replaces each occurrence of the wordpython3.11in the list of required packages.discover: how: fmf adjust-tests: - check+: - how: avc - duration+: '*2' because: Slow system under test when: arch == i286 - require~: - '/python3.11/python3.12/'
Store plugin name, data and parent step
- cli_invocation: 'tmt.cli.CliInvocation' | None = None
- do_the_discovery(path: Path | None = None) None
Discover the tests
- get_git_root(directory: Path) Path
Find git root of the path
- property is_in_standalone_mode: bool
Enable standalone mode when listing fmf ids
- post_dist_git(created_content: list[Path]) None
Discover tests after dist-git applied patches
- class tmt.steps.discover.fmf.DiscoverFmfStepData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, dist_git_source: bool = False, dist_git_type: Optional[str] = None, dist_git_download_only: bool = False, dist_git_install_builddeps: bool = False, dist_git_require: list['tmt.base.DependencySimple'] = <factory>, url: Optional[str] = None, ref: Optional[str] = None, path: Optional[str] = None, test: list[str] = <factory>, link: list[str] = <factory>, filter: list[str] = <factory>, exclude: list[str] = <factory>, modified_only: bool = False, modified_url: Optional[str] = None, modified_ref: Optional[str] = None, dist_git_init: bool = False, dist_git_remove_fmf_root: bool = False, dist_git_merge: bool = False, dist_git_extract: Optional[str] = None, sync_repo: bool = False, fmf_id: bool = False, prune: bool = False, adjust_tests: Optional[list[tmt.base._RawAdjustRule]] = <factory>, upgrade_path: Optional[str] = None, repository: Optional[str] = None, revision: Optional[str] = None)
Bases:
DiscoverStepData- adjust_tests: list[_RawAdjustRule] | None
- dist_git_extract: str | None = None
- dist_git_init: bool = False
- dist_git_merge: bool = False
- dist_git_remove_fmf_root: bool = False
- exclude: list[str]
- filter: list[str]
- fmf_id: bool = False
- link: list[str]
- modified_only: bool = False
- modified_ref: str | None = None
- modified_url: str | None = None
- path: str | None = None
- post_normalization(raw_data: _RawStepData, logger: Logger) None
Called after normalization, useful for tweaking normalized data
- prune: bool = False
- ref: str | None = None
- repository: str | None = None
- revision: str | None = None
- sync_repo: bool = False
- test: list[str]
- upgrade_path: str | None = None
- url: str | None = None
tmt.steps.discover.shell module
- class tmt.steps.discover.shell.DiscoverShell(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)
Bases:
DiscoverPlugin[DiscoverShellData]Use provided list of shell script tests.
List of test cases to be executed can be defined manually directly in the plan as a list of dictionaries containing test name, actual test script and optionally a path to the test. Example config:
discover: how: shell tests: - name: /help/main test: tmt --help - name: /help/test test: tmt test --help - name: /help/smoke test: ./smoke.sh path: /tests/shell
For DistGit repo one can download sources and use code from them in the tests. Sources are extracted into
$TMT_SOURCE_DIR, patches are applied by default. See options to install build dependencies or to just download sources without applying patches. To apply patches thepreparestep has to be enabled.discover: how: shell dist-git-source: true tests: - name: /upstream test: cd $TMT_SOURCE_DIR/*/tests && make test
To clone a remote repository and use it as a source specify
url. It accepts alsorefto checkout provided reference. Dynamic reference feature is supported as well.discover: how: shell url: https://github.com/teemtee/tmt.git ref: "1.18.0" tests: - name: first test test: ./script-from-the-repo.sh
Store plugin name, data and parent step
- cli_invocation: 'tmt.cli.CliInvocation' | None = None
- fetch_remote_repository(url: str | None, ref: str | None, testdir: Path, keep_git_metadata: bool = False) None
Fetch remote git repo from given url to testdir
- show(keys: list[str] | None = None) None
Show config details
- class tmt.steps.discover.shell.DiscoverShellData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, dist_git_source: bool = False, dist_git_type: Optional[str] = None, dist_git_download_only: bool = False, dist_git_install_builddeps: bool = False, dist_git_require: list['tmt.base.DependencySimple'] = <factory>, tests: list[tmt.steps.discover.shell.TestDescription] = <factory>, url: Optional[str] = None, ref: Optional[str] = None, keep_git_metadata: bool = False)
Bases:
DiscoverStepData- keep_git_metadata: bool = False
- ref: str | None = None
- tests: list[TestDescription]
- to_spec() _RawStepData
Convert to a form suitable for saving in a specification file
- url: str | None = None
- class tmt.steps.discover.shell.TestDescription(name: str, test: ~tmt.utils.ShellScript = <tmt.utils.ShellScript object>, summary: str | None = None, description: str | None = None, enabled: bool = True, order: int = 50, link: ~tmt.base.Links | None = None, id: str | None = None, tag: list[str] = <factory>, tier: str | None = None, adjust: list[~tmt.base._RawAdjustRule] | None = None, contact: list[str] = <factory>, component: list[str] = <factory>, path: str | None = None, framework: str | None = None, manual: bool = False, tty: bool = False, require: list[~tmt.base.DependencySimple | ~tmt.base.DependencyFmfId | ~tmt.base.DependencyFile] = <factory>, recommend: list[~tmt.base.DependencySimple | ~tmt.base.DependencyFmfId | ~tmt.base.DependencyFile] = <factory>, environment: ~tmt.utils.Environment = <factory>, duration: str = '1h', result: str = 'respect')
Bases:
SpecBasedContainer[dict[str,Any],dict[str,Any]],NormalizeKeysMixin,SerializableContainerKeys necessary to describe a shell-based test.
Provides basic functionality for transition between “raw” step data representation, which consists of keys and values given by fmf tree and CLI options, and this container representation for internal use.
- adjust: list[_RawAdjustRule] | None = None
- component: list[str]
- contact: list[str]
- description: str | None = None
- duration: str = '1h'
- enabled: bool = True
- environment: Environment
- framework: str | None = None
- classmethod from_spec(raw_data: dict[str, Any], logger: Logger) T
Convert from a specification file or from a CLI option
- id: str | None = None
- manual: bool = False
- name: str
- order: int = 50
- path: str | None = None
- recommend: list[DependencySimple | DependencyFmfId | DependencyFile]
- require: list[DependencySimple | DependencyFmfId | DependencyFile]
- result: str = 'respect'
- summary: str | None = None
- tag: list[str]
- test: ShellScript = <tmt.utils.ShellScript object>
- tier: str | None = None
- to_spec() dict[str, Any]
Convert to a form suitable for saving in a specification file
- tty: bool = False
Module contents
- class tmt.steps.discover.Discover(*, plan: Plan, data: _RawStepData | list[_RawStepData], logger: Logger)
Bases:
StepGather information about test cases to be executed.
Store supported attributes, check for sanity
- cli_invocation: 'tmt.cli.CliInvocation' | None = None
- cli_invocations: list['tmt.cli.CliInvocation'] = []
- go(force: bool = False) None
Discover all tests
- load() None
Load step data from the workdir
- save() None
Save step data to the workdir
- summary() None
Give a concise summary of the discovery
- wake() None
Wake up the step (process workdir and command line)
- class tmt.steps.discover.DiscoverPlugin(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)
Bases:
GuestlessPlugin[DiscoverStepDataT,None]Common parent of discover 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 discover plugins)
- cli_invocation: 'tmt.cli.CliInvocation' | None = None
- download_distgit_source(distgit_dir: Path, target_dir: Path, handler_name: str | None = None) None
Download sources to the target_dir
distgit_dir is path to the DistGit repository
- go(*, logger: Logger | None = None) None
Perform actions shared among plugins when beginning their tasks
- log_import_plan_details() None
Log details about the imported plan
- post_dist_git(created_content: list[Path]) None
Discover tests after dist-git applied patches
- class tmt.steps.discover.DiscoverStepData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, dist_git_source: bool = False, dist_git_type: Optional[str] = None, dist_git_download_only: bool = False, dist_git_install_builddeps: bool = False, dist_git_require: list['tmt.base.DependencySimple'] = <factory>)
Bases:
WhereableStepData,StepData- dist_git_download_only: bool = False
- dist_git_install_builddeps: bool = False
- dist_git_require: list[DependencySimple]
- dist_git_source: bool = False
- dist_git_type: str | None = None