Skip to content
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

Cannot execute beakerlib library self-tests #391

Open
t184256 opened this issue Oct 6, 2020 · 10 comments
Open

Cannot execute beakerlib library self-tests #391

t184256 opened this issue Oct 6, 2020 · 10 comments

Comments

@t184256
Copy link
Contributor

t184256 commented Oct 6, 2020

Beakerlib libraries usually have lib.sh to rlImport from tests and runtest.sh containing self-tests for the library. runtest.sh thus rlImports the appropriate lib.sh, and, worst of all it does it by name.

For example, https://github.com/beakerlib/openssl/tree/master/certgen contains lib.sh and runtest.sh with rlImport openssl/certgen. My attempts to execute it with tmt end up with rlImport: Could not find library openssl/certgen, as the test itself is not on rlImport lookup path.

I also advise against solving that with self-dependencies in metadata, because that'd require some way to prevent version discrepancies between lib.sh and runtest.sh. My guess is that we'll have to resort to some trick to enable beakerlib tests with to rlImport their lib.sh.

@psss
Copy link
Collaborator

psss commented Oct 12, 2020

@sopos, do you think that this could/should be handled on the beakerlib side? Is there a way to instruct beakerlib to look at the current working directory as well when looking for libraries?

@psss psss added the libraries label Oct 12, 2020
@sopos
Copy link

sopos commented Oct 12, 2020

Yes I think so. It might be worked around using BEAKERLIB_LIBRARY_PATH="${BEAKERLIB_LIBRARY_PATH:+$BEAKERLIB_LIBRARY_PATH:}$PWD/../../"

Currently the search in libraries root tries following locations

  • $BEAKERLIB_LIBRARY_PATH/$COMPONENT/Library/$LIBRARY/lib.sh
  • $BEAKERLIB_LIBRARY_PATH/*/$COMPONENT/Library/$LIBRARY/lib.sh
  • $BEAKERLIB_LIBRARY_PATH/$COMPONENT/$LIBRARY/lib.sh
  • $BEAKERLIB_LIBRARY_PATH/libs/$COMPONENT/$LIBRARY/lib.sh

During upwards traversal following are tried

  • $DIRECTORY/$COMPONENT/Library/$LIBRARY/lib.sh
  • $DIRECTORY/*/$COMPONENT/Library/$LIBRARY/lib.sh
  • $DIRECTORY/libs/$COMPONENT/$LIBRARY/lib.sh

In the traversal the $DIRECTORY/$COMPONENT/$LIBRARY/lib.sh is missing. Adding it would solve this issue, I guess.

@psss
Copy link
Collaborator

psss commented Oct 13, 2020

Thanks for the detailed description, @sopos. Thinking about it a bit more: Would it make sense for beakerlib to always look at the current working directory? If it founds lib.sh and if it defines the requested library name it could directly import it without additional variables hacking needed. I think that library and its runtest.sh is are always closely related so such behaviour sounds natural to me.

@sopos
Copy link

sopos commented Oct 13, 2020

There's a problem with it. There's no defined way how the library should specify its own name but directory structure. So beakerlib cannot tell what's the library in current WD without looking at the directories above.

@psss
Copy link
Collaborator

psss commented Oct 13, 2020

I see. So what about checking for $cwd/../../$component/$library/lib.sh and if it is found then use it?

@sopos
Copy link

sopos commented Oct 13, 2020

That's basically the same as extending the upwards traversal with $DIRECTORY/$COMPONENT/$LIBRARY/lib.sh. I thing to check the same path patterns for search in root and upwards traveral makes sense as well. I do not think there's high chance of collisions.

@psss
Copy link
Collaborator

psss commented Oct 14, 2020

We've agreed with @sopos that this will be fixed on beakerlib side. Tracked in beakerlib/beakerlib#70.

@psss psss closed this as completed Oct 14, 2020
@t184256
Copy link
Contributor Author

t184256 commented Mar 2, 2021

I'm reopening that after a discussion with @sopos

This still doesn't work for me:

$ mkdir library-self-test && cd library-self-test
$ fmf init
$ beaker-wizard -s library  # and press Return many times to use defaults
$ cd Library/a-few-descriptive-words/
$ grep rlImport runtest.sh
        rlRun "rlImport library-self-test/a-few-descriptive-words"
$ tmt test import .
$ tmt run -a provision --how container  # fails

From the logs I can see that cwd is /var/tmp/tmt/run-012/plans/default/discover/default/tests/Library/a-few-descriptive-words and that rlImport fails with [ ERROR ] :: rlImport: Could not find library library-self-test/a-few-descriptive-words. beakerlib's at beakerlib-1.25-1.fc33.

Note how the cwd doesn't contain the "component component" (library-self-test) at all, which means beakerlib can't use it when looking for library-self-test/a-few-descriptive-words.

@psss psss reopened this Mar 2, 2021
@sopos
Copy link

sopos commented Mar 9, 2021

@psss had an idea to use rlImport . for the case of self-import. It actually does not work in beakerlib at this point but it is really simple to add it.

However, what currently work is rlImport ./a-few-descriptive-words - you need to explicitly state the name of the library (the current directory name).

@psss
Copy link
Collaborator

psss commented Mar 9, 2021

The beakerlib support for rlImport . filed as beakerlib/beakerlib/issues/94.

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

No branches or pull requests

3 participants