TalentBox / sequel-rails

A gem for using Sequel with Rails 5.x, 6.x, 7.x
http://talentbox.github.io/sequel-rails/
MIT License
324 stars 81 forks source link

Support parallel testing (coming in Rails 6) #159

Open bgentry opened 6 years ago

bgentry commented 6 years ago

Built-in parallel testing was recently merged into Rails master and will land with Rails 6: https://github.com/rails/rails/pull/31900

The PR description and the Parallel Testing Guide cover the feature pretty well from a user's point of view.

TL;DR: ActiveSupport provides some hooks in test mode that ActiveRecord now uses to create and auto-migrate n databases, creates n forks (or threads) and splits the tests between them, then drops the databases.

The implementation for ActiveRecord is really quite small at <40 LoC.

As a devout Sequel user, I'd love to see support for this feature land in this project in time for the release of Rails 6. I'm hoping to have some time of my own to work on this over the next couple months, but I of course won't be upset if somebody beats me to it 😄

One consideration that is relevant for me. It appears the ActiveRecord PR does the suite of migrations on each test database, which might take awhile. I personally use the db:test:prepare task to load my schema directly instead of running through all my migrations on the test DB. I'm assuming this would be quite a bit faster than doing a migrate for most folks? Don't know if both methods are commonly used with sequel-rails but I definitely care more about the db:load variant.

bgentry commented 6 years ago

There was some discussion in the original Rails PR about why migration is used on each test database:

I plan on replacing this with a structure load or a straight copy of the database later on but currently structure load doesn't work with multiple databases so sticking with migrate for now.

I'm guessing that will be a problem here too?