Skip to content

Conversation

@LecrisUT
Copy link
Contributor

@LecrisUT LecrisUT commented Dec 12, 2025

Without those keys we take the tmt tree to be the default value for the path

Pull Request Checklist

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

Fixes #4422

@LecrisUT LecrisUT added the ci | full test Pull request is ready for the full test execution label Dec 12, 2025
@LecrisUT LecrisUT added the area | libraries Issues related to beakerlib libraries support label Dec 15, 2025
@LecrisUT LecrisUT marked this pull request as ready for review December 15, 2025 08:46
@github-project-automation github-project-automation bot moved this to backlog in planning Dec 15, 2025
@LecrisUT LecrisUT moved this from backlog to review in planning Dec 15, 2025
@HouMinXi
Copy link

after testing, name work as design. More test log please check attachment.
Uploading tmt_4427.tar.gz…

        prepare task #2: default-0 on client (client) and server (server)
[server (server)]         started
[server (server)]         how: install
[client (client)]         started
[server (server)]         summary: install packages
[client (client)]         how: install
[server (server)]         guest: server
[server (server)]         package: 21 packages requested
[client (client)]         summary: install packages
[server (server)]             bc
[client (client)]         guest: client
[server (server)]             beakerlib-redhat
[server (server)]             bind-utils
[server (server)]             bzip2
[server (server)]             ethtool
[server (server)]             expect
[server (server)]             gcc
[server (server)]             git
[server (server)]             iproute
[server (server)]             libtool
[server (server)]             lsof
[server (server)]             nc
[server (server)]             net-tools
[server (server)]             nmap
[server (server)]             nmap-ncat
[server (server)]             patch
[server (server)]             rsync
[server (server)]             socat
[server (server)]             tcpdump
[server (server)]             traceroute
[server (server)]             wget
[client (client)]         package: 21 packages requested
[client (client)]             bc
[client (client)]             beakerlib-redhat
[client (client)]             bind-utils
[client (client)]             bzip2
[client (client)]             ethtool
[client (client)]             expect
[client (client)]             gcc
[client (client)]             git
[client (client)]             iproute
[client (client)]             libtool
[client (client)]             lsof
[client (client)]             nc
[client (client)]             net-tools
[client (client)]             nmap
[client (client)]             nmap-ncat
[client (client)]             patch
[client (client)]             rsync
[client (client)]             socat
[client (client)]             tcpdump
[client (client)]             traceroute
[client (client)]             wget

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Dec 16, 2025

Ok @HouMinXi ready for a second try. To elaborate on the requirement. Let's say you have a repo example.com/Me/some_repo that has both beakerlib library and some tmt tests that want to test that library, something arranged like:

$ tree -a .
.
├── .fmf
│   └── version
├── my_lib
│   ├── lib.sh
│   └── main.fmf
├── plans
│   └── main.fmf
└── tests
    ├── my_lib.fmf
    └── test.sh

5 directories, 6 files

Then what you care about is how you define the tests, e.g. in this case it is /tests/my_lib

summary: Test the my_lib beakerlib library
test: test.sh
require:
  - type: library
    name: /my_lib
    nick: some_repo

and the tests file

#!/bin/bash
. /usr/share/beakerlib/beakerlib.sh || exit 1

rlJournalStart
    rlPhaseStartSetup
        rlRun "rlImport some_repo/my_lib"
    rlPhaseEnd

    rlPhaseStartTest
        rlRun "..."
    rlPhaseEnd

    rlPhaseStartCleanup
    rlPhaseEnd
rlJournalEnd

Particularly see the some_repo here matching nick and should match however you or your external users would consume the beakerlib library.

Hope this breakdown makes sense?

@HouMinXi
Copy link

Here is my test topo
repo: https://gitlab.cee.redhat.com/mhou/kernel
branch: mhou_tmp_branch

My simplified file-topology is as follows:

.
├── .fmf
│   └── version
networking
├── common
│   └── main.fmf
└── openvswitch
    └── topo
        └── main.fmf

in /networking/openvswitch/topo/main.fmf, I define the local file library as below:

summary: ovs topo testing
description: |
    FIXME: more description about ovs topo
contact: Rick Alongi <[email protected]>
component:
  - openvswitch
test: bash ./runtest.sh
framework: beakerlib
require:
  - type: library
    name: /networking/common
    nick: kernel
duration: 24h
extra-summary: /kernel/networking/openvswitch/topo
extra-task: /kernel/networking/openvswitch/topo

In plan-level I define discover as below:

- name: ovs_topo
      how: fmf
      url: https://gitlab.cee.redhat.com/mhou/kernel/-/archive/mhou_tmp_branch/kernel-mhou_tmp_branch.tar.gz
      url-content-type: archive
      path: kernel-mhou_tmp_branch
      test:
        - ^/networking/openvswitch/topo$

run the tmt with debug mode, raise error Failed to find library kernel/common at /var/tmp/tmt/run-008/openvswitch/topo/plan/discover/ovs_topo/tests

    discover
    workdir: /var/tmp/tmt/run-008/openvswitch/topo/plan/discover
        how: fmf
        name: ovs_topo
        order: 50
        Workdir '/var/tmp/tmt/run-008/openvswitch/topo/plan/discover/ovs_topo' created.
        url: https://gitlab.cee.redhat.com/mhou/kernel/-/archive/mhou_tmp_branch/kernel-mhou_tmp_branch.tar.gz
        Downloading 'https://gitlab.cee.redhat.com/mhou/kernel/-/archive/mhou_tmp_branch/kernel-mhou_tmp_branch.tar.gz'.
        Extracting archive to '/var/tmp/tmt/run-008/openvswitch/topo/plan/discover/ovs_topo/tests'.
        Run command: git rev-parse --short HEAD
        err: fatal: not a git repository (or any of the parent directories): .git
        Command returned '128' (unrecognized).
        path: kernel-mhou_tmp_branch
        tests: ^/networking/openvswitch/topo$
        Check metadata tree in '/var/tmp/tmt/run-008/openvswitch/topo/plan/discover/ovs_topo/tests/kernel-mhou_tmp_branch'.
        Detected library '{'name': '/networking/common', 'nick': 'kernel', 'type': 'library'}'.
        Fetch library 'kernel/common'.
        Failed to find library kernel/common at /var/tmp/tmt/run-008/openvswitch/topo/plan/discover/ovs_topo/tests
        summary: 1 test selected
            /ovs_topo/networking/openvswitch/topo
    status: done
    Write file '/var/tmp/tmt/run-008/openvswitch/topo/plan/discover/step.yaml'.
    Write file '/var/tmp/tmt/run-008/openvswitch/topo/plan/discover/tests.yaml'.
Plan shaper 'max-tests' not applicable.
Plan shaper 'repeat' not applicable.
            Run command: git rev-parse --is-inside-work-tree
            err: fatal: not a git repository (or any of the parent directories): .git
            Command returned '128' (unrecognized).
    Write file '/var/tmp/tmt/run-008/openvswitch/topo/plan/execute/step.yaml'.
    Write file '/var/tmp/tmt/run-008/openvswitch/topo/plan/execute/results.yaml'.
    provision
    workdir: /var/tmp/tmt/run-008/openvswitch/topo/plan/provision

@LecrisUT LecrisUT self-assigned this Dec 18, 2025
@psss psss added this to the 1.65 milestone Jan 8, 2026
@tcornell-bus tcornell-bus self-requested a review January 8, 2026 13:01
assert isinstance(self.parent, DiscoverFmf) # narrow type
# FIXME: Remove these pyright workarounds after #4391
assert isinstance(self.parent.testdir, Path) # pyright:ignore[reportAttributeAccessIssue]
self.path = self.parent.testdir # pyright:ignore[reportAttributeAccessIssue]
Copy link
Collaborator

@tcornell-bus tcornell-bus Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to reproduce @HouMinXi's issue in this comment. It looks like when we use archive:

    url: https://gitlab.cee.redhat.com/tcornell/kernel/-/archive/tmp-tmt-branch/kernel-tmp-tmt-branch.tar.gz
    url-content-type: archive
    path: kernel-tmp-tmt-branch

(I also set nick: kernel-tmp-tmt-branch in the test main.fmf instead of nick: kernel)
The path value kernel-tmp-tmt-branch is part of the path to the unzipped archive. But that value is not in self.parent.testdir.
In this instance:

self.parent.testdir == Path('/var/tmp/tmt/run-022/openvswitch/discover/ovs_topo/tests')

But we need:

self.parent.testdir == Path('/var/tmp/tmt/run-022/openvswitch/discover/ovs_topo/tests/kernel-tmp-tmt-branch')

Making the following change seemed to result in the library being found, but I don't know if the real solution should be that self.parent.testdir should be set correctly to begin with instead?

Suggested change
self.path = self.parent.testdir # pyright:ignore[reportAttributeAccessIssue]
if self.parent.data.path:
self.path = self.parent.testdir / self.parent.data.path # pyright:ignore[reportAttributeAccessIssue]
else:
self.path = self.parent.testdir # pyright:ignore[reportAttributeAccessIssue]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for looking into this, it helped a lot to find out what's going on.

The path value kernel-tmp-tmt-branch is part of the path to the unzipped archive. But that value is not in self.parent.testdir.

I think that is expected, testdir is always tests, but haven't considered what the intended path handling should be under there. Been thinking about this, and I think your approach is correct (alternative being to move everything under path to be the content under testdir) because it would keep us open if the tests are trying to access files outside of the fmf tree.

Copy link
Contributor Author

@LecrisUT LecrisUT Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been thinking about this, and I think your approach is correct (alternative being to move everything under path to be the content under testdir) because it would keep us open if the tests are trying to access files outside of the fmf tree.

Argh, actually this thing is failing because when using different url-content-type it either has or does not have data.path attached in the testsdir. What I can do instead is unify better the path construction under content-type: archive to strip out the path and try to expand that in a different PR. This is definitely not the first time that the test path construction has tripped us up.

Edit: Actually I can differ that part for later since it seems I only need to check for existence of url and already we have a divergence in behavior regardless of url-content-type.

Without those keys we take the tmt tree to be the default value for the `path`

Signed-off-by: Cristian Le <[email protected]>
Signed-off-by: Cristian Le <[email protected]>
Signed-off-by: Cristian Le <[email protected]>
:name: nick-usage

The name of the beakerlib library (the value used with
``rlImport`` is taken as the last directory pointed by
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``rlImport`` is taken as the last directory pointed by
``rlImport``) is taken as the last directory pointed by

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area | libraries Issues related to beakerlib libraries support ci | full test Pull request is ready for the full test execution

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

Need support only name in test level require

6 participants