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

TMT_TREE vs TMT_SOURCE_DIR #2184

Open
LecrisUT opened this issue Jun 30, 2023 · 8 comments
Open

TMT_TREE vs TMT_SOURCE_DIR #2184

LecrisUT opened this issue Jun 30, 2023 · 8 comments
Assignees

Comments

@LecrisUT
Copy link
Contributor

LecrisUT commented Jun 30, 2023

I was examining this run and I've noticed something peculiar in how the design works. In my test I have:

  rlRun "rsync -r $TMT_TREE$TMT_TEST_NAME/ $tmp" 0 "Copy example project"

But that does not work in upstream because it should point to TMT_SOURCE_DIR.

But then, what's the usecase of having TMT_TREE not point to TMT_SOURCE_DIR when using a plan with

discover:
  how: fmf
  dist-git-source: true

If we consider other cases when using how: fmf with url or otherwise, in those cases the source is available at TMT_TREE right? Only dist-git behaves differently with the downloaded tree pointing to a different location.

Is there a reason for having these be different? Should the behaviour be how non-dist-git download work, or the other way around? A temporary fix is possible with ${TMT_SOURCE_DIR:-$TMT_TREE}, but it is unexpected to have to do that.

LecrisUT added a commit to LecrisUT/scikit-build-core that referenced this issue Jun 30, 2023
Source path is different depending if it's dist-git downloaded or not. Could be a design problem upstream

teemtee/tmt#2184
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
henryiii pushed a commit to scikit-build/scikit-build-core that referenced this issue Jul 1, 2023
Probably a design flaw upstream, but this should be a quick fix in the
meantime

teemtee/tmt#2184

---------

Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
@lukaszachy lukaszachy self-assigned this Jul 27, 2023
@lukaszachy
Copy link
Collaborator

If we consider other cases when using how: fmf with url or otherwise, in those cases the source is available at TMT_TREE right? Only dist-git behaves differently with the downloaded tree pointing to a different location.

Test sources are always copied elsewhere (workdir//discover/<phase_name>/tests) and only in some cases you can find them within TMT_TREE location.

I don't think we expose the test path directly, but TMT_TEST_METADATA is the file which should contain that information.

To give you an example when TMT_TREE doesn't contain any test sources:

execute:
    how: tmt
    
discover:
    - how: fmf
      url: https://github.com/teemtee/tmt
      name: named-phase
      
    - how: fmf
      url: https://github.com/teemtee/fmf

When you $ tmt run discover pro -h container login you see that TMT_TREE contains single file (from which plan is defined) and no tests at all. Those are in /var/tmp/tmt/run-<id>/<planname>/{named-phase,default-1}/tests

@lukaszachy
Copy link
Collaborator

If we expose the test workdir directly (e.g. TMT_TEST_PATH) will it solve your problem?

I'm afraid that depending on the directory structure is a thing how to run into problems in the future.

@LecrisUT
Copy link
Contributor Author

Where would TMT_TEST_PATH point to in these cases. I am thinking there should be a few variables:

  • TMT_TEST_PATH, the working directory of the test after the copy.
    My understanding that in the tmt/fmf format, all the files under TMT_TEST_NAME (or rather its directory) are copied over in whichever run/provision/discover method is used
    • This does not allow the navigation to the caller's workspace or the gitrepo's
  • TMT_TEST_ROOT, the tmt tree root that has defined the test
    • This allows to (partially) navigate the git repo's files below the TMT_TEST_NAME path, e.g. to specify the common test.sh file relative to the tmt root (similar to this, but more clearer on the intention)
  • TMT_TEST_GIT_ROOT, the git root path that has defined the test
    • This allows to fully navigate the git repo's files. There are projects that would want to keep the git root structure as minimal as possible, and this would help in that design
  • Other variables to potentially get data from the plan caller, e.g. if using discover and we want to design a reusable tmt test where the caller defines the necessary variables/files (currently can only pass env variables though)

For prosperity, here is the test design that I am working with that sparked this necessary design. In this case just the TMT_TEST_PATH should be sufficient, but the others would be more beneficial for creating reusable tests

@LecrisUT
Copy link
Contributor Author

@lukaszachy Actually I tried with TMT_SOURCE_DIR and it doesn't seem to work. https://artifacts.dev.testing-farm.io/141d1d4d-1050-4646-95b8-f7d7e22aa870/ I've tried the reproducer to try and debug it locally, but it got rid of the temp files. I might need some help with this

@lukaszachy
Copy link
Collaborator

I'll take better look tomorrow. It is really possible there are more bugs here and there.

@lukaszachy
Copy link
Collaborator

@LecrisUT I think I understand the problem.
rsync runs for /var/tmp/tmt/run-115/plans/examples/discover/default-0/source/docs/examples/getting_started/cython/ however the code is in /var/tmp/tmt/run-115/plans/examples/discover/default-0/source/scikit_build_core-0.4.8/docs/examples/getting_started/cython/ -> see scikit_build_core-0.4.8 got added to the path (and that is expected).

It happens this way because there can be multiple source files and it isn't safe to merge them together (e.g what about name conflicts) so tmt extracts the tarball as-is into TMT_SOURCE_DIR.

I'm looking at available variables but I don't see any nice way how to do what you need.

pwd is /var/tmp/tmt/run-116/plans/examples/discover/default-0/tests/docs/examples
TMT_TEST_NAME=/docs/examples/getting_started/cython
TMT_SOURCE_DIR=/var/tmp/tmt/run-116/plans/examples/discover/default-0/source

I guess $TMT_SOURCE_DIR/*/$TMT_TEST_NAME should work however pwd and TMT_TEST_NAME overlap a bit so it you could strip that common part it will work always (and you will not depend if you run from distgit or from repo) as pwd will be always correct.

@lukaszachy
Copy link
Collaborator

in tmt we could probably export '/var/tmp/tmt/run-116/plans/examples/discover/default-0/tests' which is path to where tests are stored... not sure about the name though.

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Aug 2, 2023

So this is related to #2098 in some way as well. The wildcard solution should work ok, but I should work on applying the patches to source, otherwise fixing this downstream will be problematic.

Anyway for this issue, should consider some other useful variables to define to make these more navigable. From the previous comment:

  • TMT_TEST_PATH=/var/tmp/tmt/run-116/plans/examples/discover/default-0/tests/docs/examples/getting_started/cython (not affected by pwd change from the test definition). Not sure how to address the virtual paths (paths that do not have main.fmf), maybe always point to effective path for better consistency
  • TMT_TEST_ROOT=/var/tmp/tmt/run-116/plans/examples/discover/default-0/tests
  • TMT_TEST_GIT_ROOT=???
  • TMT_SOURCE_DIR=/var/tmp/tmt/run-116/plans/examples/discover/default-0/source
  • Some other paths to navigate across git and fmf root

LecrisUT added a commit to LecrisUT/scikit-build-core that referenced this issue Aug 14, 2023
teemtee/tmt#2184 (comment)
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
LecrisUT added a commit to LecrisUT/scikit-build-core that referenced this issue Aug 14, 2023
teemtee/tmt#2184 (comment)
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
LecrisUT added a commit to LecrisUT/scikit-build-core that referenced this issue Aug 14, 2023
teemtee/tmt#2184 (comment)
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
LecrisUT added a commit to LecrisUT/scikit-build-core that referenced this issue Aug 14, 2023
teemtee/tmt#2184 (comment)
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
LecrisUT added a commit to LecrisUT/scikit-build-core that referenced this issue Aug 14, 2023
teemtee/tmt#2184 (comment)
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants