pulse: Running test with mysql database throws too many connections or memory issue

Pulse Version

latest

Laravel Version

10.32

PHP Version

8.1.9

Livewire Version

dont know

Database Driver & Version

MySQL 8.0.31 for macOS 14.0 on arm64 (Docker)

Description

Hello,

When I run tests using the MySQL database with --parallel, even with Redis, the tests stop in the middle, giving me the error message: “Too many connections.”

[1040] Too many connections (Connection: mysql, SQL: drop database if exists `project_testing_test_2`))

If i run without --parallel, it’s giving me the memory limit exception

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vendor/laravel/framework/src/Illuminate/Collections/Arr.php on line 565

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vendor/laravel/framework/src/Illuminate/Collections/Arr.php on line 565
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /var/www/vendor/pestphp/pest/src/Plugins/Actions/CallsShutdown.php on line 1

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /var/www/vendor/pestphp/pest/src/Plugins/Actions/CallsShutdown.php on line 1

Am I doing something wrong?

Steps To Reproduce

Configure tests to use mysql

  • php artisan test --parallel (too many connections)
  • php artisan test (throws memory exception)

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 2
  • Comments: 44 (21 by maintainers)

Most upvoted comments

Disable Pulse in your tests. You can add PULSE_ENABLED=false in your phpunit.xml file.

@Andilutten we will tag a release next week that should allow you to update. Will keep ya posted.

@taghwo, Pulse now requires a minimum framework version of 10.34. If your application has not yet updated to 10.34 or greater you will not be able to install the latest beta.

I recommend updating at least to 10.37.3 to address the memory leak issue reported.

I’m glad to hear the memory issue was resolved.

Will try these out over the weekend and get back on Monday.

v1.0.0-beta8 has been tagged which should introduce these fixes.

Hey folks,

The memory issue should be resolved with a buffer limit introduced in #250

The DB connection issue in testsuites will be resolved using the 'null' Ingest driver introduced in #245

This means that you can put a cap on the amount of memory Pulse will capture in it’s buffer and also keep your tests fast by not requiring Pulse to actually write to the DB during tests - but keep it enabled to reflect production.

All ingesting is wrapped in rescue calls, so having it write to the database doesn’t really serve much purpose in a testsuite IMO.

Hello @timacdonald

I’ve done a composer update but the package was not updated. Tried composer remove laravel/pulse and composer require laravel/pulse too

What i`m doing wrong?

Thanks

Hi, I have same issue here, tested with v1.0.0-beta5 and v1.0.0-beta7

There are 800 tests in my project, test are running on mysql, phpunit.xml file with PULSE_ENABLED as false. No redis. After 400 tests I get this error:

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 266240 bytes) in … each time in different file

Hello.

I’ve already done that and the problem still persists