Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests | Improve ConnectivityTest #1203

Merged

Conversation

JRahnama
Copy link
Member

@JRahnama JRahnama commented Aug 3, 2021

Based on issue #1196, I have made some improvements to that class.

I have changed the specific test to not throw an exception instead it checks for Assert.Throws
I also changed the timer to use stopwatch and TimeSpan instead of capturing current date and calculate the elapsed time after.

In general I applied the C#9 features to the entire class.

@Wraith2 can you check this with the issue as well. I just want to distinguish if this is a driver issue or test implementation.

Thanks

@Wraith2
Copy link
Contributor

Wraith2 commented Aug 3, 2021

This compiles, runs and fails in the same way as the original for me:

 Event Trace (<prov.DbConnectionHelper.ConnectionString_Set|API> 31, 'Data Source=tcp:WRAITH\SQL2017;Initial Catalog=DoesNotExist0982532435423;Integrated Security=False;User ID=testuser;Pooling=False;Connect Timeout=1').
 Event ScopeEnter (SqlConnection.Open | API | Correlation | Object Id 31, Activity Id 1266df57-f44f-4011-800d-fb051a5e6713:1).
 Event CorrelationTrace (SqlConnection.Open | API | Correlation | Object Id 31, Activity Id 1266df57-f44f-4011-800d-fb051a5e6713:1).
 Event Trace (<sc.SqlConfigurableRetryLogicManager.ConnectionProvider|INFO> Requested the ConnectionProvider value.).
 Event Trace (TdsParserStateObjectFactory.CreateTdsParserStateObject | Info | AppContext switch 'Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows' not enabled, native networking implementation will be used.).
 Event Trace (TdsParser.Connect | SEC | Connection Object Id 6, Authentication Mode: SqlPassword).
 Event Trace (<sc.TdsParser.Connect|SEC> Sending prelogin handshake).
 Event Trace (<sc.TdsParser.SendPreLoginHandshake|INFO> ClientConnectionID 4a9f1c36-bcb1-4c25-a653-6e31a6babd51, ActivityID 46fc6e74-042f-4a84-9023-4367968f506e:2).
 Event Trace (<sc.TdsParser.Connect|SEC> Consuming prelogin handshake).
 Event Trace (SqlError.ctor | ERR | Info Number 4060, Error State 1, Error Class 11, Error Message 'Cannot open database "DoesNotExist0982532435423" requested by the login. The login failed.', Procedure '', Line Number 1).
 Event Trace (SqlError.ctor | ERR | Info Number 18456, Error State 1, Error Class 14, Error Message 'Login failed for user 'testuser'.', Procedure '', Line Number 1).
 Event Trace (<sc|ActiveDirectoryAuthenticationTimeoutRetryHelper|GetCachedToken|Info>Retrieved cached token null.).
 Event Trace (<sc|ActiveDirectoryAuthenticationTimeoutRetryHelper|CheckCanRetry|Error>Cannot retry when cached token is null.).
 Event Trace (<sc.SqlInternalConnectionTds.LoginFailure|RES|CPOOL> 6).
 Event ScopeLeave (Exit Scope 1).
 Event ScopeEnter (SqlConnection.Open | API | Correlation | Object Id 31, Activity Id 46fc6e74-042f-4a84-9023-4367968f506e:2).
 Event CorrelationTrace (SqlConnection.Open | API | Correlation | Object Id 31, Activity Id 46fc6e74-042f-4a84-9023-4367968f506e:2).
 Event Trace (TdsParserStateObjectFactory.CreateTdsParserStateObject | Info | AppContext switch 'Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows' not enabled, native networking implementation will be used.).
 Event Trace (TdsParser.Connect | SEC | Connection Object Id 7, Authentication Mode: SqlPassword).
 Event Trace (<sc.TdsParser.Connect|SEC> Sending prelogin handshake).
 Event Trace (<sc.TdsParser.SendPreLoginHandshake|INFO> ClientConnectionID 59c3b6c3-5ca1-453c-bc6b-da8449230ccf, ActivityID 39379a75-50db-487e-9c2c-6ff80a77114a:3).
 Event Trace (<sc.TdsParser.Connect|SEC> Consuming prelogin handshake).
 Event Trace (SqlError.ctor | ERR | Info Number 4060, Error State 1, Error Class 11, Error Message 'Cannot open database "DoesNotExist0982532435423" requested by the login. The login failed.', Procedure '', Line Number 1).
 Event Trace (SqlError.ctor | ERR | Info Number 18456, Error State 1, Error Class 14, Error Message 'Login failed for user 'testuser'.', Procedure '', Line Number 1).
 Event Trace (<sc|ActiveDirectoryAuthenticationTimeoutRetryHelper|GetCachedToken|Info>Retrieved cached token null.).
 Event Trace (<sc|ActiveDirectoryAuthenticationTimeoutRetryHelper|CheckCanRetry|Error>Cannot retry when cached token is null.).
 Event Trace (<sc.SqlInternalConnectionTds.LoginFailure|RES|CPOOL> 7).
 Event ScopeLeave (Exit Scope 2).
 Event ScopeEnter (SqlConnection.Close | API | Object Id 31).
 Event CorrelationTrace (SqlConnection.Close | API | Correlation | Object Id 31, Activity Id 39379a75-50db-487e-9c2c-6ff80a77114a:3, Client Connection Id 00000000-0000-0000-0000-000000000000).
 Event ScopeLeave (Exit Scope 3).

@cheenamalhotra cheenamalhotra linked an issue Aug 4, 2021 that may be closed by this pull request
@cheenamalhotra cheenamalhotra added the ✔️ Tests Identifier for test related changes label Aug 20, 2021
@cheenamalhotra cheenamalhotra added this to the 4.0.0-preview1 milestone Aug 20, 2021
@cheenamalhotra cheenamalhotra merged commit e5863e9 into dotnet:main Aug 20, 2021
@JRahnama JRahnama deleted the ImproveConnectionOpenDisableRetryTest branch September 29, 2022 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✔️ Tests Identifier for test related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConnectionOpenDisableRetry test deterministically fails locally
3 participants