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

tests: test infrastructure (setup/teardown) improvements #1348

Open
jku opened this issue Apr 12, 2021 · 1 comment
Open

tests: test infrastructure (setup/teardown) improvements #1348

jku opened this issue Apr 12, 2021 · 1 comment

Comments

@jku
Copy link
Member

jku commented Apr 12, 2021

(Documenting test improvement ideas from #1346)

A lot (most?) of our tests require a test server (or several). This typically means moving metadata from sources to a temp directory, serving the temp directory and finally removing the temporary directories. Modified_Testcase handles parts of that but it seems obvious that A) it does not provide the required functionality (as tests re-implement a lot of it) and B) that it is hard to use correctly (as #1346 and many previous issues prove). The end result is that there are temp directories created inside tempdirectories and then those directories may or may not get removed (often in a fairly random order)

The common needs are these I think:

  • Test class must be able to serve a repository that all its tests run against
  • test instance must be able to serve it's own repository (because it wants to modify the contents)
  • the served repository paths must be exposed so the content can be modified during test

We could have a better Modified_Testcase that just always runs one test server per class, and provides helpers to "intitialize a new repo" (copy files from sources into a directory inside the served directory). This way both server startup/shutdown and tempdir management would be handled in one place: the actual test classes would only have to remember to chain up Setup*() and *Teardown() -- if they even need those when Modified_Testcase is better.

@lukpueh
Copy link
Member

lukpueh commented Mar 16, 2022

Modified_Testcase was removed in #1790 (eb67b09) and tmp dir setup/teardown was simplified in #1792.

For TUF's sister project in-toto (which has similar needs in this regard) I created TestCase mixins with classmethods that aggreate common test setup/teardown functionality. Maybe something to explore here as well?

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

2 participants