foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Database not resetting and throws error in CI

Open dugajean opened this issue 5 years ago • 6 comments

In my CI environment (Gitlab) when I run my tests, I get the following error:

RuntimeException: Error running "doctrine:database:drop": Could not drop database "postgres" for connection named default
An exception occurred while executing 'DROP DATABASE "postgres"':
SQLSTATE[55006]: Object in use: 7 ERROR:  cannot drop the currently open database

I'm using PostgreSQL 12. Not sure how to get around this.

Advice appreciated!

dugajean avatar Oct 29 '20 02:10 dugajean

Hey @dugajean, as you can see in #51, I've been having trouble getting this library's test suite working with PostgreSQL.

Are you using DAMADoctrineTestBundle by chance?

kbond avatar Oct 29 '20 12:10 kbond

@kbond No I don't use that.

I didn't check the source code of Foundry and how this could be implemented, but Postgres allows you to unlock the db which gives you the power to drop it. I may have a look, but it would be great if you could point me in a direction to speed things up.

Thanks for this great package!

dugajean avatar Oct 29 '20 22:10 dugajean

Damn, that was the problem with #51. I'm at a loss here... I've never used postgres so I'm not sure what's causing the problem.

One thing you could try is creating the database/schema manually before your test suite is run and disabling the drop/create in foundry by setting this env var: FOUNDRY_DISABLE_DATABASE_RESET=1. The schema will still be dropped/created before each test.

kbond avatar Oct 30 '20 11:10 kbond

@dugajean, did the above work for you (FOUNDRY_DISABLE_DATABASE_RESET=1)?

kbond avatar Nov 04 '20 15:11 kbond

Closing as stale. Feel free to ping me to reopen if desired.

kbond avatar Dec 10 '20 19:12 kbond

Hello @kbond

we're trying to use foundry with dama & postgre here, and we have the same error, with (and without) the env var FOUNDRY_DISABLE_DATABASE_RESET

Could not drop database "app_test" for connection named default
An exception occurred while executing a query: SQLSTATE[55006]: Object in use: 7 ERROR:  database "app_test" is being accessed by other users
DETAIL:  There is 1 other session using the database.

nikophil avatar Jan 20 '22 10:01 nikophil

I'm closing this, because the problem no longer occurs.

nikophil avatar Nov 07 '22 14:11 nikophil