-
Notifications
You must be signed in to change notification settings - Fork 947
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
Parallelize pytest with pytest-xdist #1247
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this is a good idea, at least you either:
- need to exclude all tests that starts the server
- assign different ports to different tests that open a listener.
@@ -47,7 +47,7 @@ jobs: | |||
cmd: make -C doc/ html | |||
type: lint | |||
- name: pytest | |||
cmd: pytest --cov=pymodbus --cov=test --cov-report=term-missing --cov-report=xml -v --full-trace --timeout=20 | |||
cmd: pytest --cov=pymodbus --cov=test --cov-report=term-missing --cov-report=xml -v --full-trace --timeout=20 --numprocesses auto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this works it is pr accident. Multiple tests open a listener on port 5020, if they run in parallel they will fail.
Sorry for not understanding the full test suite. However, is the port not already randomized? If I change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why this works, it should not but since it does...
random_port is a special test used only in test_server_asyncio.py, but that does not solve problem. There are not much to understand about the test suite, a lot of the tests spin up a server which listens on a given port (typically 5020), then in the same test the client connects to port 5020 and do whatever the purpose of the test is. Running several of these tests in parallel is impossible, because on 1 system only 1 process can listen to 1 port. Look at test_examples.py as an example. |
Merged, due to my lack of understanding why this works. Thanks for the PRs, looking forward to see more PRs from your side. |
I do not either 😂. My understanding of the expected problem matches yours. I was expecting to have to use Glad to be able to contribute in a small way. My employer maintains several FOSS packages dependant on pymodbus, and I ported them from 2.5.3 to 3.x. I'm still trying to understand a problem that port introduced regarding reconnecting, which means I need to understand pymodbus better. |
Let me know if I can help with your understanding….open a discussion if there are things you do not understand. I am not a big expert, I have only been working directly on pymodbus for about a year, but I think I have been in nearly all parts of the code. |
also let me know if I can help persuade your employer to use more time on pymodbus. I have seen that a company depends on a project if often want to have an employe connected to the project. You have earned committer status, if you want it, being the fifth most active on the project: https://github.com/riptideio/pymodbus/graphs/contributors Please let me know what you think. |
Consider adding this requirement for
pytest-xdist
to speed up pytest runs by running them inparallel.
Pros:
+50% speedup on my laptop
Cons: