Skip to content

CI tests extremely slow on multi-tenant setup with unique databases #1433

@dasundev

Description

@dasundev

Bug description

we have around 500 tests in the project. running the tests on ci is very slow; it takes about 30 minutes to complete on github actions. however, on my local machine (macbook m4 pro), it only takes around 4 minutes.

Steps to reproduce

in every test case, we create new tenants, each tenant creates a new database. we create unique databases for each tenant using uuid(), which means we do not reuse databases among all tests to make tests more practical.

to reproduce this performance issue:

git clone https://github.com/dasundev/tenancy-testing
cd tenancy-testing
cp .env.example .env
composer install
php artisan key:generate
# create a new database called "testing" in your local
./vendor/bin/pest --parallel

Expected behavior

Expected behavior

all tests must run fast on CI and local.


Current behavior

on macbook pro m4 pro:

tests: 501 passed (501 assertions)
duration: 277.32s
parallel: 14 processes

ci:

https://github.com/dasundev/tenancy-testing/actions/runs/21037124353/job/60488094594 (if the job is still running, you may check it later)

performance varies with tenant migrations

Laravel version

12.47.0

stancl/tenancy version

3.9.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions