Open svanoort opened 9 years ago
Simple code example: https://fragmentsofcode.wordpress.com/2011/01/22/pycurl-curlmulti-example/
No need to worry overmuch about true full-parallel. Single executor thread with CurlMulti (concurrent networking) + analyze batch --> final result.
Use a work queue and worker processes if needed to handle/interpret responses (combined again by main thread into results).
I know this issue is now years old, but I'd like to throw a +1 into the ring. With the current trend in APIs is microservices, there's a huge need arising which is the need to parallelize testing of those APIs. Currently, with a traditional "setup, do test, tear-down" approach to testing microservice APIs for larger APIs can take a (relatively) long time. PyRestTest helps in that regard and allows passing objects/artifacts/values from one to the next to have simplified shared dependencies, but it (currently) runs tests in a non-concurrent fashion. With a bit of effort, each test could be pre-loaded and evaluate what it's dependency is to generate a dependency graph, and the optimize by performing the tests with the most dependencies first, so that its dependents could fire upon its completion. This would allow for full parallelization of the tests, and in the microservice world, could allow for a full barrage of tests to complete in seconds, not minutes/hours.
Imagine the velocity gained by this approach. I've spent a few days googling for an API testing framework (or a testing framework in general) which can do this, and I haven't found any. But, this framework comes awfully close to being able to do this by allowing artifacts/values from previous steps to cascade into the next tests, and by doing things like supporting saving outputs from steps, so that we can do a cleanup afterwards based on those outputs.
I guess I don't see a ton of movement on this project lately, but if it's still active and if anyone's interested, this might be something I would approach doing a PoC of with this framework since I really see the "future" in microservices will require test parallelization.
As a pyresttest user I'd like to be able to parallelize the test execution (parallel HTTP calls).
TL;DR Summary of Analysis
Need to start working out code for the above.
Precursor: using curl reset when reusing curl handles.
Look at using CurlMulti, see example: https://github.com/Lispython/pycurl/blob/master/examples/retriever-multi.py See also: https://github.com/tornadoweb/tornado/blob/master/tornado/curl_httpclient.py
PyCurl Multi Docs: http://pycurl.sourceforge.net/doc/curlmultiobject.html#curlmultiobject LibCurl: http://curl.haxx.se/libcurl/c/libcurl-multi.html
Using multiprocessing pools for process-parallel execution: http://stackoverflow.com/questions/3842237/parallel-processing-in-python.
Concurrency should be managed at a testset level. Why below.
Config syntax:
Implementation: All initial parsing runs, then we decided how to execute (serial or concurrent). For concurrent, I see 4 levels of concurrency, with increasing concurrent resource use and performance, but increasing complexity:
Analysis:
Test overhead:
time python profile_basic_test.py
Decision Point: