Skip to content

docs: Add example for sharing tests across repositories#2

Closed
mcasquer wants to merge 1 commit intomainfrom
feat/add-share-tests-example
Closed

docs: Add example for sharing tests across repositories#2
mcasquer wants to merge 1 commit intomainfrom
feat/add-share-tests-example

Conversation

@mcasquer
Copy link
Owner

@mcasquer mcasquer commented Jun 3, 2025

This commit adds a new subsection to examples.rst explaining how to share tests across different repositories using tmt.

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

This commit adds a new subsection to `examples.rst` explaining how to share tests across different repositories using tmt.
@mcasquer mcasquer added the documentation Improvements or additions to documentation label Jun 3, 2025
mcasquer pushed a commit that referenced this pull request Sep 16, 2025
…Mode (teemtee#4025)

There is a hack which TF uses to exclude packages from installation:

```
prepare:
  - how: install
    exclude:
      - curl-minimal
      - libcurl-minimal
```

While it is correctly skipped in Package Mode:

```
        prepare task #2: default-0 on default-0
        how: install
        
        prepare task #3...
```

In Image Mode it throws the next error:

```
        prepare task #2: default-0 on default-0
        how: install
        package: building container image with dependencies
        warn: Installation failed, trying again after metadata refresh.
        package: building container image with dependencies
        package: switching to new image localhost/tmt/bootc/98d6fbdf-87c5-45d9-9bf2-d57a7ad7a065
        package: rebooting to apply new image
        package: building container image with dependencies
        fail: Command 'podman build -t localhost/tmt/bootc/71da0589-8b12-4642-a548-8ef063ba2524 -f tmp.sYftMCdBvD/Containerfile /var/ARTIFACTS/work-all-no-buildrootj4t_5bzu/plans/all-no-buildroot/prepare' returned 125.
```

The reason is that the prepare step above doesn't trigger the `install`
function of the `BootcEngine`, which leads to an empty
`containerfile_directives` of the engine. The patch adds a check to see
if `containerfile_directives` is empty and skips the build process
completely in that case.
mcasquer pushed a commit that referenced this pull request Jan 19, 2026
Previously, SUPPORTED_DISTRO_PATTERNS was a
(shared) generator. That breaks use of fips prepare feature in multiple
plans within the same tmt run. Now SUPPORTED_DISTRO_PATTERS is just a
tuple and sharing has no negative effects.

Consider the following plan:

```
# reproducer.fmf
summary: Test plan

prepare:
  - name: Enable FIPS mode
    how: feature
    fips: enabled

execute:
  how: tmt

discover:
  - how: shell
    tests:
      - name: sample-test
        test: echo 'hello!'

/first:

/second:
```

Previously:

```
❯ tmt run plan --name /plans/reproducer discover provision --how minute --image rhel-10.1 prepare
/var/tmp/tmt/run-001

/plans/reproducer/first
    discover
        ...
    provision
        ....
        summary: 1 guest provisioned
    prepare
        queued push task #1: push to default-0

        push task #1: push to default-0

        queued prepare task #1: essential-requires on default-0
        queued prepare task #2: Enable FIPS mode on default-0

        prepare task #1: essential-requires on default-0
        how: install
        summary: Install essential required packages
        name: essential-requires
        where: default-0
        package: /usr/bin/python3 and /usr/bin/flock

        prepare task #2: Enable FIPS mode on default-0
        how: feature
        name: Enable FIPS mode
        Enable FIPS

        queued pull task #1: pull from default-0

        pull task #1: pull from default-0

        summary: 2 preparations applied

/plans/reproducer/second
    discover
        ...
    provision
        ...
        summary: 1 guest provisioned
    prepare
        queued push task #1: push to default-0

        push task #1: push to default-0

        queued prepare task #1: essential-requires on default-0
        queued prepare task #2: Enable FIPS mode on default-0

        prepare task #1: essential-requires on default-0
        how: install
        summary: Install essential required packages
        name: essential-requires
        where: default-0
        package: /usr/bin/python3 and /usr/bin/flock

        prepare task #2: Enable FIPS mode on default-0
        how: feature
        name: Enable FIPS mode
        fail: FIPS prepare feature is supported on RHEL/CentOS-Stream 8, 9 or 10.

plan failed

The exception was caused by 1 earlier exceptions

Cause number 1:

    prepare step failed

    The exception was caused by 1 earlier exceptions

    Cause number 1:

        FIPS prepare feature is supported on RHEL/CentOS-Stream 8, 9 or 10.
```

This is because now `SUPPORTED_DISTRO_PATTERNS` is a generator now.

```
SUPPORTED_DISTRO_PATTERNS = (
    re.compile(pattern)
    for pattern in (r'Red Hat Enterprise Linux (8|9|10)', r'CentOS Stream (8|9|10)')
)

```

And the prepare phase of the first plan already takes the first pattern
and hence there is nothing useful left for the prepare phase of the
second plan.

Signed-off-by: Ondrej Moris <ondrej.moris@gmail.com>
@mcasquer mcasquer closed this Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant