From 06f592549b410dc6e0f0f899e2878271b751f427 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 14 Nov 2021 15:44:24 -0800 Subject: [PATCH 1/2] Optimize sharing test connection --- tests/Functional/Schema/MySQLSchemaManagerTest.php | 8 +++----- tests/Functional/Schema/PostgreSQLSchemaManagerTest.php | 2 ++ .../Functional/Schema/SchemaManagerFunctionalTestCase.php | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/Functional/Schema/MySQLSchemaManagerTest.php b/tests/Functional/Schema/MySQLSchemaManagerTest.php index 5a960a23378..5f0d722bc65 100644 --- a/tests/Functional/Schema/MySQLSchemaManagerTest.php +++ b/tests/Functional/Schema/MySQLSchemaManagerTest.php @@ -21,11 +21,6 @@ public static function setUpBeforeClass(): void Type::addType('point', PointType::class); } - protected function tearDown(): void - { - $this->markConnectionNotReusable(); - } - protected function supportsPlatform(AbstractPlatform $platform): bool { return $platform instanceof MySQLPlatform; @@ -106,6 +101,9 @@ public function testSpatialIndex(): void $this->schemaManager->dropAndCreateTable($table); + // see https://github.com/doctrine/dbal/issues/4983 + $this->markConnectionNotReusable(); + $indexes = $this->schemaManager->listTableIndexes('spatial_index'); self::assertArrayHasKey('s_index', $indexes); self::assertTrue($indexes['s_index']->hasFlag('spatial')); diff --git a/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php b/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php index 831af69c0ac..c9ce4aeb3ab 100644 --- a/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php +++ b/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php @@ -198,6 +198,8 @@ public function testFilterSchemaExpression(): void $testTable->addColumn('id', 'integer'); $this->schemaManager->createTable($testTable); + $this->markConnectionNotReusable(); + $this->connection->getConfiguration()->setSchemaAssetsFilter(static function (string $name): bool { return preg_match('#^dbal204_#', $name) === 1; }); diff --git a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php index e578e06ba3c..d5a809abc50 100644 --- a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -78,8 +78,6 @@ protected function tearDown(): void $this->connection->executeStatement('DROP SCHEMA testschema'); } catch (Exception $e) { } - - $this->markConnectionNotReusable(); } public function testDropAndCreateSequence(): void From 8fb8105902dfc6c3b87559c58462721451c4ec7d Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 7 Nov 2021 15:35:07 -0800 Subject: [PATCH 2/2] Close the non-shared connection instead of marking it non-reusable --- tests/Functional/PortabilityTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Functional/PortabilityTest.php b/tests/Functional/PortabilityTest.php index 9a11859f5b6..3fef5445a11 100644 --- a/tests/Functional/PortabilityTest.php +++ b/tests/Functional/PortabilityTest.php @@ -49,7 +49,9 @@ protected function setUp(): void protected function tearDown(): void { - $this->markConnectionNotReusable(); + // the connection that overrides the shared one has to be manually closed prior to 4.0.0 to prevent leak + // see https://github.com/doctrine/dbal/issues/4515 + $this->connection->close(); } public function testFullFetchMode(): void