-
Notifications
You must be signed in to change notification settings - Fork 21.8k
Use the default Capybara registered puma server configuration #30638
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
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @eileencodes (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
This issue directly impacted me, and will probably impact other Rails users as more people migrate to SystemTests. Like most people running Puma in the dev/prod stack, I had some configuration in @eileencodes in the evolution of the PR I saw you placed a big emphasis on sensible defaults and out-of-the-box functionality. To that point, it makes sense to me that SystemTests should strongly enforce a Puma configuration that takes advantage of the connection sharing (but maybe leave the port to be configurable? not sure if that will make a huge difference) |
I think this is fine because I originally meant for the port to be settable but now that I think about it that eventually got removed with a few refactorings. If we need the port to be configurable beyond the |
@twalpole can you add a changelog note for this? |
0607e28
to
ba04b58
Compare
@eileencodes Done - Also, I notice you tagged this 5.1.5 -- It does require an update to Capybara 2.15+ for the passing of the 'Silent' option to Capybaras registered puma server to work - so not sure whether backporting is acceptable or not. |
@twalpole thanks for pointing that out, I've removed it from the 5.1.5 milestone. |
Isn't possible to backport this to 5.1.x? This allow using another web servers without changing puma as the default, e.g in my app I can do something like:
|
@guilleiguaran if you look directly above in stream, we have already back-ported it in #30712 |
@maschwenk even when #30712 makes registered |
@guilleiguaran The fact that Rails registers a server shouldn't matter - you just need to make sure your setting of |
@twalpole: but Rails fails if puma isn't present in the Gemfile, so you need to add it as a dependency even if you want to use another server. See rspec/rspec-rails#1882 The current solution in RSpec 3.7 is to disable System Tests entirely if puma can't be loaded: https://github.com/rspec/rspec-rails/pull/1884/files |
@guilleiguaran So include the puma gem in the test environment, registering the server doesn't actually initialize puma until that server is used, so as long as you set an alternative before Capybara attempts to start the server puma will never be used - Note: this PR didn't remove the |
@guilleiguaran Or just stick to writing feature specs which don't have a requirement of puma and still get the connection sharing/transactional testing/remove database_cleaner benefits under Rails 5.1 |
Yup, I already removed it in Rails master: 50f6976
Didn't know about this, I think that's good enough for me. |
Is a possible temporary workaround for this to put a guard clause in config/puma.rb that skips the relevant puma cluster configuration code unless Rails.env.production?. |
The
puma_rails
"server" registered by Rails for system tests doesn't force Puma into "in process" mode. This means if the user happens to have aconfig/puma.rb
configuration file which is configuring puma in cluster mode for production it will also run Puma in cluster mode for tests. Since cluster mode runs Puma in new processes it defeats the connection sharing needed for transactional testing, and prevents Capybara from being able to monitor open connections at the end of tests.This PR changes the behavior to just use the default Capybara registered
puma
"server" which does pass the needed options, and I don't really see the benefit of Rails registering its own "server" config.