-
Notifications
You must be signed in to change notification settings - Fork 484
ActiveRecord::ConnectionNotEstablished in random places #716
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
Comments
We're hitting this too on CI; Haven't hit it locally yet to debug further Database cleaner boilerplate with Cucumber tests: preserved_tables = %w[ ... ]
DatabaseCleaner.strategy = :deletion, {:except => preserved_tables}
Cucumber::Rails::Database.autorun_database_cleaner = false
Before('not @no-database-cleaner') do
$stderr.puts "[database-cleaner] start"
DatabaseCleaner.start
end
After('not @no-database-cleaner') do
$stderr.puts "[database-cleaner] clean"
DatabaseCleaner.clean
end
InstallPlugin do |config, registry|
DatabaseCleaner.clean_with :truncation, {:except => preserved_tables}
end Error:
After this error occurs, the rest of the tests generally fail on either connection not established, or that database records already exist from the cleanup not working
Versions:
We are also running a worker and another service connected to the same test database which is shared with our capybara browser test application, which might be related to the problem. |
I've been running into this and assumed its because my connection setup is a bit manual, bisecting my suite properly I've found that its the memoisation of the connection wrapper that causes it for me, I'm on a legacy version of Rails for this project and the memoisation of the connection means it can be stale when accessed in a later test, simply checking for an open connection before cleaning solves it locally:
For those encountering it I've patched this like this for now:
|
Hi team, sometimes we have this error during running the tests
we run them in parallel

and I have no idea where to find roots of the problem
I tried to set
reaping_frequency: 0
setting but it didn't help (logs from runs with this setting)Versions:
Tests crash in random places and often a restart helps, we don't have something special for database cleaner, our config:
rails_helper.rb:
The text was updated successfully, but these errors were encountered: