-
Notifications
You must be signed in to change notification settings - Fork 781
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
Experiment, parallelize some tests #17662
base: main
Are you sure you want to change the base?
Conversation
❗ Release notes required
|
Yeah this will not do much. A lot of test cases write to stdout. We do This needs a systemic approach to deal with stdout capture, maybe xUnit have some mechanism to do this in parallel. |
@majocha guess what, I was going to try the same today :) Thanks for looking into that. Indeed, it seems like we should just damn stop printing everything to the console, it's likely an artifact of older testing approaches. I cannot see any reason to do this instead of just in memory processing. |
xUnit does not run tests from the same module in parallel. It also does not parallelize This can be mitigated by customizing xUnit in code, I think? |
By customizing xUnit you mean setting up some special runner settings and assembly attributes? We can do that. However - I am not a fan of this idea. xUnit's philosophy is really to apply good coding practices to tests. As in, write tests as you write code. Hence, e.g. compared to Nunit, it offers a very limited test platform voodoo (think fixtures, setup/teardown and so on), instead making as much as possible of the builtin language capabilities. And so I would instead prefer keeping up with this philosophy. If, by default, xUnit parallelizes execution on the module level, then we should actually split modules into smaller ones - thereby it will improve code clarity and will generally add to better code organization :) What do you think? |
By customizing I meant something like https://www.meziantou.net/parallelize-test-cases-execution-in-xunit.htm But this is not the most pressing thing and probably not needed if splitting modules would do. The biggest hurdle for now is correctly isolating the console when running tests in parallel. Redirecting with Console writes come from multiple sources:
While we can manage 1. and 2., 3. is a bit harder. |
I've been chatting with Bing / Copilot about it, and it actually proposed a not bad idea: Don't redirect the Console at all for individual tests. Instead install a custom thread splitting |
37918b1
to
932d12c
Compare
Thanks for the further investigations here. In the spirit of my comment above - I just vote for reinventing as few wheels as possible and removing those we've already reinvented here :) Unit tests rarely need any output at all, but if they do - it's good to use those few means that xUnit provides for this, which are basically "plug in the writer if and when you need to". I think it aligns with your thoughts above? It's important to make gradual changes here, probably actually in the way you outline it above. The current direction you're taking (removing stuff) looks promising! Note, I am off until Monday with limited internet connection so cannot play with the code myself. Also, we've discussed this PR internally yesterday and were all very happy that things are moving in this space! |
This is at a state that can be run locally in VS test explorer or from the console with In the CI there's that weird Still, there are some minor fixes here that I'll try to extract to another PR. |
Which ones do you mean in particular? Maybe I can try hacking something locally. |
In the previous ci run, I think. I'm on the phone right now, so I can't easily find the link, sorry 🙂 |
Well I guess eventually, all the problems we might be getting here would be due to the fact that we are running in parallel something that shouldn't or cannot work like that yet. So disabling parallelization should heal this as well? Or I am looking at the wrong place? |
It's a bit worse than that, the failures in CI I usually cannot repro locally. But you're right, I should put a strictly maxthreads: 1 run from time to time as a sanity check :D |
@T-Gro, I changed the build script to disable parallelization in ci. I'll try to solidify the work here. Concentrating on cleaning this up, reenabling the skipped tests, extracting the ones I modified into separate PRs. |
Thanks Jakub, we're following this :) |
Just to see if it works and if it's worth it.