Port tests to barrage#4357
Conversation
954cb2a to
b3dab11
Compare
|
I went through all the commits and did some cleanups. I also had a new claude session review the commits, including a careful cataloguing of old and new tests and making sure I didn't drop anything. I also introduced and verified |
|
That's a big chunk of work! Thanks! I've had a quick look over it and there are things I do like about this, but I'd be happier if this weren't so unittest/javaesque, i.e. there's got to be some test classes for setup (what fixtures did in pytest), but some of the config tests, json or kmod could do with just test functions, making the diff smaller (and the whole thing more flat). Also, generally using the functions from |
|
@behrmann cheers! Agreed to restructuring the classes wrt. fixtures, and flattening some test files.
I don't understand this. The docs explicitly say "Assertion helpers — same names as unittest", and barrage's own tests all use |
|
Ok, so this might be a case of the blind leading the blind, since I've not yet really had the time to look at barrage all to closely (mea culpa), but I don't think the |
|
@behrmann Ah! got it -- these are for test functions, as obviously they don't have a Most unit tests are straightforward, I fully agree they should be functions. I already re-converted them locally. Only test_config.py raises a little bit of doubt: The thing is, barrage really doesn't have a concept for "fixtures" in the pytest sense. We can use the I pushed a new version which moves the unit and install tests to functions. I didn't yet touch the integration tests. |
|
@behrmann I talked to @daandemeyer (he was sitting next to me), and the executive decision was to do the I moved the integration tests to functional as well. I spot-checked some of them, but I still run into There are still lots of concurrency bugs once more than one VM actually runs in parallel. Working through them. |
|
I worked this out. This first requires a bunch of fixes for the tests to allow running them in parallel, I split that out into #4360. Then I fixed the actual mkosi invocations to be async as well. On the latest run on my fork things now succeed, and they only take ~ 7 instead of ~ 15 minutes, i.e. actual 2x parallelism as specified in the workflow. I'm afraid we can't get higher until barrage learns about test VM resource usage and throttling itself -- |
|
For those following along at home: At least for me, the @daandemeyer also sent a PR to systemd about that: systemd/systemd#42534 |
be3f71b to
0ab7657
Compare
|
Rebased and adjusted for the "pass on snapshot to extension build" change that happened in the meantime. Mostly green, just this ppc64le download failure smells like qemu emulation segfault. Feel free to retry. Otherwise ready to review. |
|
#4373 landed, so that output directory fix needs to be re-done. |
We are going to port our tests to <https://github.com/amutable-systems/barrage>. Get it into the box via pip; this will allow dependabot (or renovate) to keep it up to date without custom logic, once we move from "pull from git" to "pull latest release from pypi". With renovate, we could also keep the git SHA pinning, but renovate requires some more set up effort. Note: An alternative way for this would be to pull in barrage as a submodule. Dependabot/renovate work great for these, but the human ergonomics are not very pleasant.
barrage does not have the equivalent of pytest markers, but it can select by file pattern. So unit tests retain `test_*.py`, and rename the other two kinds to `install_*.py` and `integration_*.py`. This parallelizes the subprocess-y parts like test_linters.py.
barrage has no equivalent to pytest's `parametrize`. Open-code that with `do_test_*(params...)` helpers and individual tests calling that. Stop passing the explicit `--distribution` to the test. The new `ImageConfigManager` singleton (which replaces the old `config` pytest fixture) reads the distribution from `mkosi.local.conf`. This avoids having to specify it twice, and leaves the configuration to `integration-test-setup.sh`. Drop the `log_setup()` call. The integration tests themselves don't use `logging`, this mostly just affects the called `mkosi` subprocesses which already do it. This is very prone to interfere with barrage's own stderr capturing. Replace the `--debug-shell` pytest option with a `TEST_DEBUG_SHELL` env variable, as barrage doesn't have test-defined CLI options. Make the mkosi invocations in tests/__init__.py async, so that they can actually run in parallel. Remove installation and remaining traces of pytest.
|
#4376 landed, so once again this is unblocked. I rebased. |
The mere installation of barrage already involved some decisions and will probably trigger some discussion.
I split out the barrage install, unit+install, and the integration test porting into three separate commits to make the review slightly easier. If you prefer, I can eventually all squash it.
test_addonregression log1, log2, log3: committed; needs de-sloping and moving to tests: Fix parallel runs #4360Fix-- it's in fact the same race astest_confextfailure on centos/fedora or opensuse/debian (this is a flake)test_addonFix-- it's also the same race astest_bootloader_grubfailure on centos/fedoratest_addon