Codeception: [Yii2] Used database connections are not getting closed

What are you trying to achieve?

Trying to run suite of tests

What do you get instead?

Failures

Provide console output if related. Use -vvv mode for more details.

- ManagerTest: Check oem company monitor  Destroying application
  Starting application
  [Fixtures] Loading fixtures
  [yii\db\Connection::open] 'Opening DB connection: pgsql:host=localhost;port=5432;dbname=front_test'
  [Fixtures] Opened database connection: pgsql:host=localhost;port=5432;dbname=front_test
  [yii\db\Connection::open] 'Opening DB connection: pgsql:host=localhost;port=5432;dbname=back_test'
  [Fixtures] Opened database connection: pgsql:host=localhost;port=5432;dbname=back_test
  [Fixtures] Closing database connection: pgsql:host=localhost;port=5432;dbname=front_test
  [Fixtures] Closing database connection: pgsql:host=localhost;port=5432;dbname=back_test
  [Fixtures] Done
  [yii\db\Connection::open] 'Opening DB connection: pgsql:host=localhost;port=5432;dbname=front_test'
  [yii\web\Session::open] 'Session started'
  [yii\web\User::login] 'User \'1256\' logged in from  with duration 86400.'

Eventually get this

---------
300) ApiUserTesterCest: Test the forgot password request
 Test  tests/api/ApiUserTesterCest.php:ForgotPasswordRequest
                                                                                  
  [yii\db\Exception] SQLSTATE[08006] [7] FATAL:  sorry, too many clients already  
                                                                                  
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:624
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:687
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:613
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:996
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:983
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Schema.php:463
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:881
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:209
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:1099
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:1120
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:442
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/pgsql/Schema.php:182
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Schema.php:237
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/pgsql/QueryBuilder.php:200
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:959
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/test/InitDbFixture.php:96
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/test/InitDbFixture.php:78
/srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/test/FixtureTrait.php:117
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Module/Yii2.php:467
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Module/Yii2.php:285
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Module/Yii2.php:259
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Subscriber/Module.php:56
/srv/www/xyzweb/src/private/protected/vendor/symfony/event-dispatcher/EventDispatcher.php:212
/srv/www/xyzweb/src/private/protected/vendor/symfony/event-dispatcher/EventDispatcher.php:44
/srv/www/xyzweb/src/private/protected/vendor/codeception/phpunit-wrapper/src/Listener.php:133
/srv/www/xyzweb/src/private/protected/vendor/codeception/phpunit-wrapper/src/Listener.php:102
/srv/www/xyzweb/src/private/protected/vendor/phpunit/phpunit/src/Framework/TestResult.php:395
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Test/Test.php:75
/srv/www/xyzweb/src/private/protected/vendor/phpunit/phpunit/src/Framework/TestSuite.php:755
/srv/www/xyzweb/src/private/protected/vendor/codeception/phpunit-wrapper/src/Runner.php:106
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/SuiteManager.php:157
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Codecept.php:189
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Codecept.php:158
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Command/Run.php:466
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Command/Run.php:361
/srv/www/xyzweb/src/private/protected/vendor/symfony/console/Command/Command.php:252
/srv/www/xyzweb/src/private/protected/vendor/symfony/console/Application.php:946
/srv/www/xyzweb/src/private/protected/vendor/symfony/console/Application.php:248
/srv/www/xyzweb/src/private/protected/vendor/symfony/console/Application.php:148
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Application.php:108
/srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/codecept:42

Details

  • Codeception version: 2.4.1
  • PHP Version: 7.0
  • Operating System: Ubuntu 16.04
  • Installation type: Composer
  • List of installed packages (composer show) alexandernst/yii2-device-detect 0.0.12 Yii2 extension for Mobile-Detect library behat/gherkin v4.5.1 Gherkin DSL parser for PHP 5.3 bower-asset/bootstrap v3.3.7 The most popular front-end framework for developing responsive, mobile first projects on the web. bower-asset/inputmask 3.3.11 Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jql… bower-asset/jquery 3.2.1
    bower-asset/jquery-ui 1.12.1
    bower-asset/punycode v1.3.2
    bower-asset/yii2-pjax 2.0.7.1
    braintree/braintree_php 3.30.0 Braintree PHP Client Library cebe/markdown 1.1.2 A super fast, highly extensible markdown parser for PHP codeception/codeception 2.4.1 BDD-style testing framework codeception/phpunit-wrapper 6.0.9 PHPUnit classes used by Codeception codeception/specify 1.0 BDD code blocks for PHPUnit and Codeception codeception/stub 1.0.2 Flexible Stub wrapper for PHPUnit’s Mock Builder codeception/verify 1.0.0 BDD assertion library for PHPUnit crossjoin/css v1.0.3 CSS reader and writer with full CSS3 support, already supporting huge parts of the current CSS4 spec. It supports media quer… crossjoin/pre-mailer v1.0.5 Crossjoin\PreMailer converts CSS in a given HTML source to inline styles and optimizes it for sending it via e-mail. It also… doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors ezyang/htmlpurifier v4.10.0 Standards compliant HTML filter written in PHP facebook/webdriver 1.5.0 A PHP client for Selenium WebDriver firebase/php-jwt v5.0.0 A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec. flow/jsonpath 0.4.0 JSONPath implementation for parsing, searching and flattening arrays guzzlehttp/guzzle 6.3.2 Guzzle is a PHP HTTP client library guzzlehttp/promises v1.3.1 Guzzle promises library guzzlehttp/psr7 1.4.2 PSR-7 message implementation that also provides common utility methods imagine/imagine v0.7.1 Image processing for PHP 5.3 kamranahmedse/php-geocode v2.0 A wrapper around the Google Geocoding API to get different details such as latitude, longitude, country, city, district, pos… mobiledetect/mobiledetectlib 2.8.31 Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific … myclabs/deep-copy 1.7.0 Create deep copies (clones) of your objects phar-io/manifest 1.0.1 Component for reading phar.io manifest information from a PHP Archive (PHAR) phar-io/version 1.0.1 Library for handling version information and constraints phpdocumentor/reflection-common 1.0.1 Common reflection classes used by phpdocumentor to reflect the code structure phpdocumentor/reflection-docblock 4.3.0 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is e… phpdocumentor/type-resolver 0.4.0
    phpmailer/phpmailer v5.2.26 PHPMailer is a full-featured email creation and transfer class for PHP phpoffice/phpexcel 1.8.1 PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine phpspec/prophecy 1.7.5 Highly opinionated mocking framework for PHP 5.3+ phpunit/php-code-coverage 5.3.2 Library that provides collection, processing, and rendering functionality for PHP code coverage information. phpunit/php-file-iterator 1.4.5 FilterIterator implementation that filters files based on a list of suffixes. phpunit/php-text-template 1.2.1 Simple template engine. phpunit/php-timer 1.0.9 Utility class for timing phpunit/php-token-stream 2.0.2 Wrapper around PHP’s tokenizer extension. phpunit/phpunit 6.5.7 The PHP Unit Testing framework. phpunit/phpunit-mock-objects 5.0.6 Mock Object library for PHPUnit piwik/piwik-php-tracker 1.2.0 PHP Client for Piwik Analytics Tracking API psr/http-message 1.0.1 Common interface for HTTP messages psr/log 1.0.2 Common interface for logging libraries sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or method a line of code belongs to sebastian/comparator 2.1.3 Provides the functionality to compare PHP values for equality sebastian/diff 2.0.1 Diff implementation sebastian/environment 3.1.0 Provides functionality to handle HHVM/PHP environments sebastian/exporter 3.1.0 Provides the functionality to export PHP variables for visualization sebastian/global-state 2.0.0 Snapshotting of global state sebastian/object-enumerator 3.0.3 Traverses array structures and object graphs to enumerate all referenced objects sebastian/object-reflector 1.1.1 Allows reflection of object attributes, including inherited and non-public ones sebastian/recursion-context 3.0.0 Provides functionality to recursively process PHP variables sebastian/resource-operations 1.0.0 Provides a list of PHP built-in functions that operate on resources sebastian/version 2.0.1 Library that helps with managing the version number of Git-hosted PHP projects symfony/browser-kit v3.4.8 Symfony BrowserKit Component symfony/console v3.4.8 Symfony Console Component symfony/css-selector v2.8.38 Symfony CssSelector Component symfony/debug v3.4.8 Symfony Debug Component symfony/dom-crawler v3.4.8 Symfony DomCrawler Component symfony/event-dispatcher v3.4.8 Symfony EventDispatcher Component symfony/finder v3.4.8 Symfony Finder Component symfony/polyfill-mbstring v1.7.0 Symfony polyfill for the Mbstring extension symfony/process v3.4.8 Symfony Process Component symfony/yaml v3.4.8 Symfony Yaml Component theseer/tokenizer 1.1.0 A small library for converting tokenized PHP source code into XML and potentially other formats webmozart/assert 1.3.0 Assertions to validate method input/output with nice error messages. yiidoc/yii2-redactor 2.0.1 Extension redactor for Yii2 Framework. yiisoft/yii2 2.0.15.1 Yii PHP Framework Version 2 yiisoft/yii2-bootstrap 2.0.8 The Twitter Bootstrap extension for the Yii framework yiisoft/yii2-composer 2.0.6 The composer plugin for Yii extension installer yiisoft/yii2-imagine 2.1.1 The Imagine integration for the Yii framework yiisoft/yii2-jui 2.0.7 The Jquery UI extension for the Yii framework yiisoft/yii2-redis 2.0.8 Redis Cache, Session and ActiveRecord for the Yii framework yurkinx/yii2-image dev-master 2737b1e Yii2 extension for image manipulating using Kohana Image Library.
  • Suite configuration:
class_name: UnitTester
modules:
    enabled:
        - Yii2:
            part: [orm, fixtures]
            cleanup: true
            transaction: false
coverage:
    enabled: true
    remote: false
    include:
      - models/*
      - components/*
      - forms/*

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 42 (19 by maintainers)

Commits related to this issue

Most upvoted comments

@SamMousa Done: https://github.com/Codeception/yii2-tests/pull/1 Found problems with cleanup: false. Need to open a new issue?!

@SamMousa In my case transactions are enabled, component still called ‘db’.