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

Possible incompatibility w/ other gems that work using "parallel_tests" #4

Open
spemmons opened this issue Nov 24, 2020 · 6 comments
Open

Comments

@spemmons
Copy link

spemmons commented Nov 24, 2020

Seems like a nice approach, but I'm wondering if it is incompatible with some test gems.

In my case, I'm seeing errors like this

An error occurred in a `before(:suite)` hook.
Failure/Error: DatabaseCleaner.clean_with(:truncation)

ActiveRecord::Deadlocked:
  PG::TRDeadlockDetected: ERROR:  deadlock detected
  DETAIL:  Process 19585 waits for AccessExclusiveLock on relation 2032669 of database 2025375; blocked by process 19581.
  Process 19581 waits for AccessShareLock on relation 2033561 of database 2025375; blocked by process 19585.
  HINT:  See server log for query details.

A gem called database_cleaner seems to be at fault. Need to review this gem to see if we can do something else...

Thoughts?

@spemmons spemmons changed the title See Possible incompatibility w/ other gems that work using "parallel_tests" Nov 24, 2020
@spemmons
Copy link
Author

I removed usage of database_cleaner and still get the error, but less often AND I get a bonus error about not having permission to disable referential integrity on my localhost PG?? weird...

WARNING: Rails was not able to disable referential integrity.

This is most likely caused due to missing permissions.
Rails needs superuser privileges to disable referential integrity.

@ioquatix
Copy link
Owner

Thanks for reporting this issue.

Are you using a single database for all workers?

@alaroia-cfa
Copy link

@spemmons For me, I was able to get turbo_test to run successfully by making a turbo_test.rb file at the top of my project, and having it contain:

worker do |index|
  puts "debugging index=#{index}"
  index = index + 1
  ENV['TEST_ENV_NUMBER'] = index == 1 ? "" : index.to_s
end

Naturally you can remove the puts.

parallel_tests assumes there's a TEST_ENV_NUMBER env var which starts at the empty string, then 2, 3, 4, etc.

@ioquatix
Copy link
Owner

ioquatix commented Mar 7, 2021

In my experience there is enough variation in how to structure tests that I think providing a hook is probably the most generic option. Not all tests require separate databases or a test index. However we could consider providing it by default... I don't think we should expose this by default if it means people come to rely on it though.

@aaronchi
Copy link

@ioquatix How would you configure workers to use separate databases currently?

@dmitry
Copy link

dmitry commented Mar 19, 2021

@aaronchi as I understood similar to the parallel_tests (https://github.com/grosser/parallel_tests#add-to-configdatabaseyml), you have to add set env variable: #4 (comment) and then use it in the database.yml (for activerecord).

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

5 participants