The current stress test relies on inefficient primitives that cause contention in the test. We should re-host the test on top of a framework that does the following, rather than using Deferred:
- test contains a mutex, a cond var, an array of N task results, and a count of completed tasks
- launch N networking tasks, then wait on the cond var
- when each task finishes, in its callback it:
--> places its result within the results array
--> updates the count of completed tasks
--> if all tasks are complete, wakes up the main thread
Then, the main thread can go through the array of results and assert that each result is as expected. This should reduce flakiness in the test, in particular tasks that exceed the time limit because of contention in Deferred.