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

Allow setting db with use_postgresql tests #45178

Merged
merged 1 commit into from May 26, 2022

Conversation

eileencodes
Copy link
Member

If more than one test is using use_postgresql for it's tests and both
need to create db:create those tests will fail often due to them
running in parallel. I tried turning off parallelization for these tests
and they still ran in separate processes. Ultimately though, turning off
parallelization means we don't get to test parallelization. Instead I've
added the ability to set a database_name so that in files that require
dropping/creating the same db, we can set up a new db for those.

Fixes #45114
Fixes #45158

If more than one test is using `use_postgresql` for it's tests and both
need to run `db:create` those tests will fail often due to them
running in parallel. I tried turning off parallelization for these tests
and they still ran in separate processes. Ultimately though, turning off
parallelization means we don't aren't testing parallelization. Instead I've
added `Process.pid` to the database name so it creates a database
specifically for that test. For cases where we need to set an explict
name a name can be passed in.

I also added an ensure to one of the tests so that the databases get
cleaned up and not left behind.

Fixes rails#45114
Fixes rails#45158
@eileencodes eileencodes force-pushed the allow-setting-db-with-postgres branch from 8e3a07b to 58f6710 Compare May 26, 2022 15:09
@eileencodes eileencodes merged commit 008b85e into rails:main May 26, 2022
@eileencodes eileencodes deleted the allow-setting-db-with-postgres branch May 26, 2022 15:46
eileencodes added a commit that referenced this pull request May 26, 2022
…gres

Allow setting db with use_postgresql tests
eileencodes added a commit that referenced this pull request May 26, 2022
If more than one test is using `use_postgresql` for it's tests and both
need to run `db:create` those tests will fail often due to them
running in parallel. I tried turning off parallelization for these tests
and they still ran in separate processes. Ultimately though, turning off
parallelization means we don't aren't testing parallelization. Instead I've
added `Process.pid` to the database name so it creates a database
specifically for that test. For cases where we need to set an explict
name a name can be passed in.

I also added an ensure to one of the tests so that the databases get
cleaned up and not left behind.

Fixes #45114
Fixes #45158

Manual backport of #45178
@eileencodes
Copy link
Member Author

I backported this to 7-0-stable and 6-1-stable

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