user2225335
user2225335

Reputation: 21

Does the parallel_tests gem run your test suites in sequence?

I'm reading through the parallel_tests source but don't understand it yet, so I thought I would jump to the chase and ask my question here.

Does the parallel_tests gem run all of the tests in your sweet simultaneously or in sequence? (Is it possible for more than one test to be running at the same time)

When I run parallel tests it seems like it:

  1. finds all my tests
  2. divides them up into even piles (one for each processor)
  3. runs each pile of tests in sequence

I'm wondering this because the difference time difference between running rake parallel:test (75 minutes) and rake test (85 minutes) with four processors is slight.

The output for parallel tests makes it seem like it's running the groups of tests in sequence.

My output looks like this:

It will start by indicating it's found all my processors:

rake parallel:test[functional]

4 processes for 223 tests, ~ 55 tests per process

Then it seems to run each subset of tests in sequence:

......
841 tests, 3605 assertions, 0 failures, 3 errors, 0 skips

Test run options: --seed 15002
oaded suite -e

...............
Finished in 1928.494289 seconds.

542 tests, 2296 assertions, 0 failures, 0 errors, 0 skips

Test run options: --seed 30455
oaded suite -e
....
etc...

So, is this a trick of my output, or is it really running each set of tests one after another. I was thinking I would get better a time improvement, plus this has big implications for other stuff I need to parallelize to make my tests run.

Upvotes: 2

Views: 2197

Answers (1)

Rein Henrichs
Rein Henrichs

Reputation: 15605

If your tests require a large amount of setup/teardown code or contend for resources like IO then you may not see significant performance gains from parallelizing them. parallel_test does indeed run your tests in parallel but it buffers the output in sequence because it would be pretty difficult to understand if 4 processes were just writing directly to STDOUT and the messages were getting interleaved with each other.

If you're not convinced that the tests are running in parallel, pull up top or some other such tool (e.g., Activity Monitor on OS X) and watch what's happening.

This is not an answer to your question but you would probably have more gains optimizing your 841 tests that take a half hour to run more quickly rather than trying to parallelize them.

Upvotes: 1

Related Questions