Summer Sale! All accounts are 50% off this week.

arkadiy's avatar

Parallel testing with DB seed

Can someone share success story of setting up Laravel Parallel Testing with correct seeding of all DBs created for testing?

I've set up hook as described in docs:

        ParallelTesting::setUpTestDatabase(function ($database, $token) {
			// I log from this line
            Artisan::call('db:seed');
        });

Then when I run

php artisan test --parallel --recreate-databases

I see log messages for each of 8 DBs, also I have log from beginning of my main DatabaseSeeder and begging of first "real seeder" class, which is called from DatabaseSeeder. And nothing more: no seeders finished and no changes in each of DBs.

All 8 DBs migrate successfully.

0 likes
10 replies
martinbean's avatar

@arkadiy Maybe reply to the Discord thread you had running on this topic, instead of ignoring, trying to create yet another help forum post asking the same thing again, and now creating a Laracasts forum thread on the same thing yet again.

https://discord.com/channels/297040613688475649/486983156411400202/1048235502899302491

No one’s going to put time into helping you if you’re just going to ignore them. If you still had questions, you should have asked for clarification in that thread instead of creating two entirely new threads in different locations.

arkadiy's avatar

What exactly did I ignore? I answered all questions in this thread. Maybe I'm missing something but I see only messages from Dan.

Asking same question in different places is reasonable because audience is different in all places.

cwhite's avatar

@arkadiy,

It sounds like something in your Seeders is failing in parallel and causing the entire artisan command to fail. Debugging in parallel can be difficult, but I would recommend going through all the seeders (commenting sections out) until you find the culprit.

arkadiy's avatar

@cwhite I tried to run my project without docker and all seeders successfully finished. Unfortunately I have to use Docker in my work, so I’m trying to find difference between running multiple processes locally and in Docker.

I understand that Docker philosophy is to have one process per container so maybe this behavior is expected.

I commented seeders by one and by big chunks, looks like process is freezing in first not-commented seeder.

cwhite's avatar

@arkadiy, I use Docker as well. What does your docker-compose look like and how exactly are you running the artisan test command?

arkadiy's avatar

@cwhite we use custom docker-composer in company. At Monday I will try to run app with Laravel Sail to check if problem is with our custom docker setup and will have more info. Thanks!

I'm trying to run test in parallel with php artisan test --parallel --recreate-databases. Usually I run normal (nonparallel) test with PHPStorm runner, but for now I want to run tests in parallel at least in console.

cwhite's avatar

@arkadiy, well that could be your issue... are you running 'artisan tests inside the container (either through a bash prompt in the container, or using sail / docker exec)? If you're running the command outside of the container that could be causing issues.

cwhite's avatar

@arkadiy, can you try running the test in 'parallel' with only one process?

php artisan test -p --processes=1 --recreate-databases

Please or to participate in this conversation.