-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In long-running processes, allows checking the database connection by…
… pinging it, thus avoiding exceptions. Additionally, it provides the flexibility to configure the frequency of the check to be performed in the case of long-running processes.
- Loading branch information
Showing
5 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Connection; | ||
|
||
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; | ||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
|
||
use function sleep; | ||
|
||
class ConnectionReactivatedTest extends FunctionalTestCase | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::markConnectionWithHeartBeat(); | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
if ($this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform) { | ||
return; | ||
} | ||
|
||
self::markTestSkipped('Currently only supported with MySQL'); | ||
} | ||
|
||
public function testConnectionReactivated(): void | ||
{ | ||
$this->connection->executeStatement('SET SESSION wait_timeout=1'); | ||
|
||
sleep(2); | ||
|
||
$query = $this->connection->getDatabasePlatform() | ||
->getDummySelectSQL(); | ||
|
||
$this->connection->executeQuery($query); | ||
|
||
self::assertEquals(1, $this->connection->fetchOne($query)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters