Unit testing: “Too many open files” and “Too many

2019-06-09 01:51发布

It looks like some system resources are holding in Symfony 2.5 while tests are running.

I have a Symfony2 project with more than 200 functional tests. With Symfony 2.3 and 2.4 everything worked, but after upgrade to 2.5 I began receiving an error (I use Mac OS X):

failed to open stream: Too many open files

I googled a little and changed max_files parameter in system config.

After that I began receiving another error:

Uncaught exception 'PDOException' with message 'SQLSTATE[08004] [1040] Too many connections'

OK, I changed the max-connections parameter in MySQL, but it looks like something is wrong after upgrade. Like some system resources are holding.

After downgrade back to 2.4 everything becomes OK again.

Maybe now I have to close some resources or connections manually somewhere? Or the problem is somewhere else?

UPD: I have found one more question with same problem: Too many connection during unit testing

1条回答
祖国的老花朵
2楼-- · 2019-06-09 02:33

Just execute "ulimit -n 10000" before running unit tests. Another solution (I think the best solution) is to use "in memory" database. Your tests will run faster.

查看更多
登录 后发表回答