-
Notifications
You must be signed in to change notification settings - Fork 162
Allow beakerlib library without url/path #4427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
after testing, name work as design. More test log please check attachment. |
|
Ok @HouMinXi ready for a second try. To elaborate on the requirement. Let's say you have a repo $ tree -a .
.
├── .fmf
│ └── version
├── my_lib
│ ├── lib.sh
│ └── main.fmf
├── plans
│ └── main.fmf
└── tests
├── my_lib.fmf
└── test.sh
5 directories, 6 filesThen what you care about is how you define the tests, e.g. in this case it is 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
rlJournalEndParticularly see the Hope this breakdown makes sense? |
|
Here is my test topo My simplified file-topology is as follows: in /networking/openvswitch/topo/main.fmf, I define the local file library as below: In plan-level I define discover as below: run the tmt with debug mode, raise error |
tmt/libraries/beakerlib.py
Outdated
| 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] |
There was a problem hiding this comment.
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?
| 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] |
There was a problem hiding this comment.
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-branchis part of the path to the unzipped archive. But that value is not inself.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.
There was a problem hiding this comment.
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
pathto be the content undertestdir) 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]>
Signed-off-by: Cristian Le <[email protected]>
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ``rlImport`` is taken as the last directory pointed by | |
| ``rlImport``) is taken as the last directory pointed by |
Without those keys we take the tmt tree to be the default value for the
pathPull Request Checklist
Fixes #4422