Skip to content

Commit 3424f66

Browse files
authored
Fix Windows test connection cleanup flakiness (#3837)
Close NpgsqlTestStore helper-opened connections after sync and async command execution to avoid accumulating idle test connections. Disable SSL in the CI test connection string to avoid Windows SSL handshake pressure during functional tests.
1 parent 9b3177a commit 3424f66

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ jobs:
115115
run: dotnet test -c ${{ matrix.config }} --logger "GitHubActions;report-warnings=false"
116116
shell: bash
117117
env:
118-
Test__Npgsql__DefaultConnection: Server=localhost;Username=npgsql_tests;Password=npgsql_tests
118+
# Disable SSL to avoid unnecessary handshake pressure in the Windows functional tests.
119+
Test__Npgsql__DefaultConnection: Server=localhost;Username=npgsql_tests;Password=npgsql_tests;SSL Mode=Disable
119120

120121
- id: analyze_tag
121122
name: Analyze tag

test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlTestStore.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ private static T ExecuteCommand<T>(
341341
}
342342
finally
343343
{
344-
if (connection.State == ConnectionState.Closed
345-
&& connection.State != ConnectionState.Closed)
344+
if (connection.State != ConnectionState.Closed)
346345
{
347346
connection.Close();
348347
}
@@ -389,8 +388,7 @@ private static async Task<T> ExecuteCommandAsync<T>(
389388
}
390389
finally
391390
{
392-
if (connection.State == ConnectionState.Closed
393-
&& connection.State != ConnectionState.Closed)
391+
if (connection.State != ConnectionState.Closed)
394392
{
395393
await connection.CloseAsync();
396394
}

0 commit comments

Comments
 (0)