Skip to content

Commit f3b7349

Browse files
committed
Clear pool to make test more reliable.
1 parent dda9c3d commit f3b7349

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionFailoverTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,8 @@ public void TransientFault_IgnoreServerProvidedFailoverPartner_ShouldConnectToUs
566566
// Ensure pooling is enabled so that the failover partner information
567567
// is persisted in the pool group. If pooling is disabled, the server
568568
// provided failover partner will never be used.
569-
Pooling = true
569+
Pooling = true,
570+
MinPoolSize = 1
570571
};
571572
SqlConnection connection = new(builder.ConnectionString);
572573

@@ -577,14 +578,17 @@ public void TransientFault_IgnoreServerProvidedFailoverPartner_ShouldConnectToUs
577578
// Close the connection to return it to the pool
578579
connection.Close();
579580

580-
581581
// Act
582582
// Dispose of the server to trigger a failover
583583
server.Dispose();
584584

585585
// Opening a new connection will use the failover partner stored in the pool group.
586586
// This will fail if the server provided failover partner was stored to the pool group.
587587
using SqlConnection failoverConnection = new(builder.ConnectionString);
588+
589+
// Clear the pool to ensure a new physical connection is created
590+
// Pool group info such as failover partner will still be retained
591+
SqlConnection.ClearPool(connection);
588592
failoverConnection.Open();
589593

590594
// Assert

0 commit comments

Comments
 (0)