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

[10.x] Fix parallel testing without any database connection #47705

Merged
merged 2 commits into from
Jul 10, 2023

Conversation

deleugpn
Copy link
Contributor

@deleugpn deleugpn commented Jul 10, 2023

When running Parallel Testing, one of the checks that happens within the framework is whether we're using SQLite or not. However, this check is done via DB::getConfig(). What truly happens here is:

  • DB Facade is invoked
  • DatabaseManager class is resolved
  • DatabaseManager::__call() is invoked
  • DatabaseManager::connection() is invoked
  • The default Database configuration is loaded from database.default.
  • A new connection is established on this database.
  • A verification of whether getConfig() returns :memory: is performed.

As we can see, even if we specify without-databases, the ParallelTesting class is still establishing a database connection.

The added test goes to show that if we create a Laravel Application and delete the database.default configuration in our project skeleton, then php artisan test --parallel --without-databases will still crash because it cannot establish a database connection to check if it's SQLite or not.

The code change partially mitigates the problem. I think a deeper issue is the fact that a complete database connection is being established just to check whether the developer is using SQLite or not. However, for the sake of simplicity and brevity, we can at least use the without-databases flag to decide to not even try connecting to any database.

@taylorotwell taylorotwell merged commit 33ca6fc into laravel:10.x Jul 10, 2023
@deleugpn deleugpn deleted the parallel-testing branch July 10, 2023 19:33
@deleugpn
Copy link
Contributor Author

I'm not sure what's going on with GitHub Actions here. I tried installing PHP 8.1 and running the tests, but they are working fine

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

Successfully merging this pull request may close these issues.

2 participants