Skip to content
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

Broken tests after upgrading to Rails 6.1 #896

Open
OndrejKu opened this issue Mar 14, 2023 · 1 comment
Open

Broken tests after upgrading to Rails 6.1 #896

OndrejKu opened this issue Mar 14, 2023 · 1 comment

Comments

@OndrejKu
Copy link

If I run the test suite by using rspec, I'm getting everything green, but when I use parallel_spec, I'm getting random errors.

In my test setup, I'm using database cleaner and transactional fixtures. After running bisect I was able to identify tests that are failing more precisely. The main issue happens after I added to my database configuration reader and replicas. The transaction on test side of things has all the data, but when I access the application side, there are no data. This doesn't happen on every file. For example now I have 2091 test cases, but only 7 of them are random failures.

I went back to the database settings and change the code to following:

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true

  connects_to database: { writing: :primary, reading: :primary_replica } unless Rails.env.test?
  connects_to database: { writing: :primary, reading: :primary } if Rails.env.test?
end

But this didn't help as I expected. Could this be a parallel_spec bug or Rails bug or am I doing something wrong?

@grosser
Copy link
Owner

grosser commented Mar 15, 2023

  • database cleaner should not be needed when using transactional fixtures ... so try removing to simplify setup
  • run with --verbose to get a printout of the the files parallel_rspec runs and run them manually ... that should reproduce the issue and you can bisect from there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants