@@ -19,8 +19,8 @@ public class ConnectionFailoverTests
1919 [ Trait ( "Category" , "flaky" ) ]
2020 [ Theory ]
2121 [ InlineData ( 40613 ) ]
22- [ InlineData ( 42108 ) ]
23- [ InlineData ( 42109 ) ]
22+ [ InlineData ( 42108 ) ] // Flaky: [errorcode: 42108] Assert.Equal() Failure: Strings differ | Assert.Equal() Failure: Values differ
23+ [ InlineData ( 42109 ) ] // Flaky: [errorcode: 42109] Assert.Equal() Failure: Strings differ
2424 public void TransientFault_NoFailover_DoesNotClearPool ( uint errorCode )
2525 {
2626 // When connecting to a server with a configured failover partner,
@@ -67,16 +67,29 @@ public void TransientFault_NoFailover_DoesNotClearPool(uint errorCode)
6767 // Assert
6868 Assert . Equal ( ConnectionState . Open , connection . State ) ;
6969 Assert . Equal ( ConnectionState . Open , secondConnection . State ) ;
70+
71+ /* TODO: Fix flaky Assert.Equal() in this test method;
72+ Assert.Equal() Failure: Strings differ
73+ ↓ (pos 14)
74+ Expected: "localhost,51966"
75+ Actual: "localhost,51965"
76+ ↑ (pos 14)
77+ */
7078 Assert . Equal ( $ "localhost,{ initialServer . EndPoint . Port } ", connection . DataSource ) ;
7179 Assert . Equal ( $ "localhost,{ initialServer . EndPoint . Port } ", secondConnection . DataSource ) ;
7280
7381 // 1 for the initial connection, 2 for the second connection
82+ /* TODO: Fix flaky test failure for errorcode 42108:
83+ Assert.Equal() Failure: Values differ
84+ Expected: 3
85+ Actual: 4
86+ */
7487 Assert . Equal ( 3 , initialServer . PreLoginCount - initialServer . AbandonedPreLoginCount ) ;
7588 // A failover should not be triggered, so prelogin count to the failover server should be 0
7689 Assert . Equal ( 0 , failoverServer . PreLoginCount ) ;
7790 }
7891
79- [ Trait ( "Category" , "flaky" ) ]
92+ [ Trait ( "Category" , "flaky" ) ] // Assert.Equal() Failure: Values differ | System.ComponentModel.Win32Exception : The wait operation timed out.
8093 [ Fact ]
8194 public void NetworkError_TriggersFailover_ClearsPool ( )
8295 {
@@ -115,6 +128,13 @@ public void NetworkError_TriggersFailover_ClearsPool()
115128 // Open the initial connection to warm up the pool and populate failover partner information
116129 // for the pool group.
117130 using SqlConnection connection = new ( builder . ConnectionString ) ;
131+
132+ /* TODO: Fix flaky test failure:
133+ Microsoft.Data.SqlClient.SqlException : A network-related or instance-specific error occurred while establishing a connection to SQL Server.
134+ The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured
135+ to allow remote connections. (provider: TCP Provider, error: 0 - The wait operation timed out.)
136+ ---- System.ComponentModel.Win32Exception : The wait operation timed out.
137+ */
118138 connection . Open ( ) ;
119139 Assert . Equal ( ConnectionState . Open , connection . State ) ;
120140 Assert . Equal ( $ "localhost,{ initialServer . EndPoint . Port } ", connection . DataSource ) ;
@@ -131,8 +151,13 @@ public void NetworkError_TriggersFailover_ClearsPool()
131151 Assert . Equal ( ConnectionState . Open , secondConnection . State ) ;
132152 Assert . Equal ( $ "localhost,{ failoverServer . EndPoint . Port } ", secondConnection . DataSource ) ;
133153 Assert . Equal ( 1 , initialServer . PreLoginCount ) ;
134- Assert . Equal ( 1 , failoverServer . PreLoginCount ) ;
135154
155+ /* TODO: Fix flaky Assert.Equal() in this test method;
156+ Assert.Equal() Failure: Values differ
157+ Expected: 1
158+ Actual: 2
159+ */
160+ Assert . Equal ( 1 , failoverServer . PreLoginCount ) ;
136161
137162 // Act
138163 // Request a new connection, should initiate a fresh connection attempt if the pool was cleared.
@@ -242,7 +267,7 @@ public void NetworkDelay_ShouldConnectToPrimary()
242267 }
243268
244269 [ Fact ]
245- [ Trait ( "Category" , "flaky" ) ]
270+ [ Trait ( "Category" , "flaky" ) ] // Assert.Equal() Failure: Values differ | System.ComponentModel.Win32Exception : The wait operation timed out
246271 public void NetworkError_WithUserProvidedPartner_RetryDisabled_ShouldConnectToFailoverPartner ( )
247272 {
248273 using TdsServer failoverServer = new (
@@ -277,6 +302,15 @@ public void NetworkError_WithUserProvidedPartner_RetryDisabled_ShouldConnectToFa
277302 using SqlConnection connection = new ( builder . ConnectionString ) ;
278303
279304 // Act
305+ /* TODO: Fix flaky test failure:
306+ Microsoft.Data.SqlClient.SqlException : Connection Timeout Expired. The timeout period elapsed during the post-login phase.
307+ The connection could have timed out while waiting for server to complete the login process and respond;
308+ Or it could have timed out while attempting to create multiple active connections.
309+ This failure occurred while attempting to connect to the Principle server.
310+ The duration spent while attempting to connect to this server was - [Pre-Login] initialization=6; handshake=80;
311+ [Login] initialization=0; authentication=0; [Post-Login] complete=5443;
312+ ---- System.ComponentModel.Win32Exception : The wait operation timed out
313+ */
280314 connection . Open ( ) ;
281315
282316
@@ -285,12 +319,18 @@ public void NetworkError_WithUserProvidedPartner_RetryDisabled_ShouldConnectToFa
285319 // so the connection will retry on the failover server.
286320 Assert . Equal ( ConnectionState . Open , connection . State ) ;
287321 Assert . Equal ( $ "localhost,{ failoverServer . EndPoint . Port } ", connection . DataSource ) ;
322+
323+ /* TODO: Fix flaky Assert.Equal() in this test method;
324+ Assert.Equal() Failure: Values differ
325+ Expected: 1
326+ Actual: 2
327+ */
288328 Assert . Equal ( 1 , failoverServer . PreLoginCount ) ;
289329 Assert . Equal ( 1 , server . PreLoginCount ) ;
290330 }
291331
292332 [ Fact ]
293- [ Trait ( "Category" , "flaky" ) ]
333+ [ Trait ( "Category" , "flaky" ) ] // Assert.Equal() Failure: Values differ | System.ComponentModel.Win32Exception : The wait operation timed out
294334 public void NetworkError_WithUserProvidedPartner_RetryEnabled_ShouldConnectToFailoverPartner ( )
295335 {
296336 using TdsServer failoverServer = new (
@@ -325,13 +365,36 @@ public void NetworkError_WithUserProvidedPartner_RetryEnabled_ShouldConnectToFai
325365 } ;
326366 using SqlConnection connection = new ( builder . ConnectionString ) ;
327367 // Act
368+ /* TODO: Fix flaky test failure:
369+ Microsoft.Data.SqlClient.SqlException : Connection Timeout Expired.
370+ The timeout period elapsed during the post-login phase.
371+ The connection could have timed out while waiting for server to complete the login process and respond;
372+ Or it could have timed out while attempting to create multiple active connections.
373+ This failure occurred while attempting to connect to the Principle server.
374+ The duration spent while attempting to connect to this server was - [Pre-Login] initialization=4; handshake=68;
375+ [Login] initialization=0; authentication=0; [Post-Login] complete=5443;
376+ ---- System.ComponentModel.Win32Exception : The wait operation timed out
377+ */
378+ /* TODO: Fix flaky test failure:
379+ Microsoft.Data.SqlClient.SqlException : Connection Timeout Expired.
380+ The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement.
381+ This could be because the pre-login handshake failed or the server was unable to respond back in time.
382+ This failure occurred while attempting to connect to the Principle server.
383+ The duration spent while attempting to connect to this server was - [Pre-Login] initialization=0; handshake=5285;
384+ ---- System.ComponentModel.Win32Exception : The wait operation timed out.
385+ */
328386 connection . Open ( ) ;
329387
330388 // Assert
331389 // On the first connection attempt, failover partner information is available in the connection string,
332390 // so the connection will retry on the failover server.
333391 Assert . Equal ( ConnectionState . Open , connection . State ) ;
334392 Assert . Equal ( $ "localhost,{ failoverServer . EndPoint . Port } ", connection . DataSource ) ;
393+ /* TODO: Fix flaky Assert.Equal() in this test method;
394+ Assert.Equal() Failure: Values differ
395+ Expected: 1
396+ Actual: 2
397+ */
335398 Assert . Equal ( 1 , server . PreLoginCount ) ;
336399 Assert . Equal ( 0 , server . Login7Count ) ;
337400 Assert . Equal ( 1 , failoverServer . PreLoginCount - failoverServer . AbandonedPreLoginCount ) ;
@@ -448,7 +511,7 @@ public void TransientFault_RetryDisabled_ShouldFail(uint errorCode)
448511 [ InlineData ( 40613 ) ]
449512 [ InlineData ( 42108 ) ]
450513 [ InlineData ( 42109 ) ]
451- [ Trait ( "Category" , "flaky" ) ]
514+ [ Trait ( "Category" , "flaky" ) ] // [errorcode: 40613] Assert.Equal() Failure: Values differ
452515 public void TransientFault_WithUserProvidedPartner_ShouldConnectToPrimary ( uint errorCode )
453516 {
454517 // Arrange
@@ -490,17 +553,21 @@ public void TransientFault_WithUserProvidedPartner_ShouldConnectToPrimary(uint e
490553 Assert . Equal ( $ "localhost,{ server . EndPoint . Port } ", connection . DataSource ) ;
491554
492555 // Failures should prompt the client to return to the original server, resulting in a login count of 2
556+ /* TODO: Fix flaky Assert.Equal() in this test method;
557+ Assert.Equal() Failure: Values differ
558+ Expected: 2
559+ Actual: 3
560+ */
493561 Assert . Equal ( 2 , server . PreLoginCount - server . AbandonedPreLoginCount ) ;
494562 // Login-phase errors must NOT trigger failover alternation
495563 Assert . Equal ( 0 , failoverServer . PreLoginCount ) ;
496564 }
497565
498- [ Trait ( "Category" , "flaky" ) ]
566+ [ Trait ( "Category" , "flaky" ) ] // [errorcode: 42109] Assert.Fail() Failure
499567 [ Theory ]
500568 [ InlineData ( 40613 ) ]
501569 [ InlineData ( 42108 ) ]
502570 [ InlineData ( 42109 ) ]
503- [ Trait ( "Category" , "flaky" ) ]
504571 public void TransientFault_WithUserProvidedPartner_RetryDisabled_ShouldFail ( uint errorCode )
505572 {
506573 // Arrange
@@ -542,12 +609,13 @@ public void TransientFault_WithUserProvidedPartner_RetryDisabled_ShouldFail(uint
542609 Assert . Equal ( ( int ) errorCode , e . Number ) ;
543610 return ;
544611 }
545-
612+ // TODO: Fix flaky Assert.Fail() in this test method;
613+ // [errorcode: 42109] Assert.Fail() Failure
546614 Assert . Fail ( ) ;
547615 }
548616
549617 [ Fact ]
550- [ Trait ( "Category" , "flaky" ) ]
618+ [ Trait ( "Category" , "flaky" ) ] // Assert.Equal() Failure: Values differ | System.ComponentModel.Win32Exception : The wait operation timed out
551619 public void TransientFault_IgnoreServerProvidedFailoverPartner_ShouldConnectToUserProvidedPartner ( )
552620 {
553621 // Arrange
@@ -585,6 +653,12 @@ public void TransientFault_IgnoreServerProvidedFailoverPartner_ShouldConnectToUs
585653 SqlConnection connection = new ( builder . ConnectionString ) ;
586654
587655 // Connect once to the primary to trigger it to send the failover partner
656+ /* TODO: Fix flaky test failure:
657+ Microsoft.Data.SqlClient.SqlException : A network-related or instance-specific error occurred while establishing a connection to SQL Server.
658+ The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
659+ (provider: TCP Provider, error: 0 - The wait operation timed out.)
660+ ---- System.ComponentModel.Win32Exception : The wait operation timed out.
661+ */
588662 connection . Open ( ) ;
589663 Assert . Equal ( "invalidhost" , ( connection . InnerConnection as SqlConnectionInternal ) ! . ServerProvidedFailoverPartner ) ;
590664
@@ -606,8 +680,21 @@ public void TransientFault_IgnoreServerProvidedFailoverPartner_ShouldConnectToUs
606680
607681 // Assert
608682 Assert . Equal ( ConnectionState . Open , failoverConnection . State ) ;
683+
684+ /* TODO: Fix flaky Assert.Equal() in this test method;
685+ Assert.Equal() Failure: Strings differ
686+ ↓ (pos 13)
687+ Expected: "localhost,51479"
688+ Actual: "localhost,51480"
689+ ↑ (pos 13)
690+ */
609691 Assert . Equal ( $ "localhost,{ failoverServer . EndPoint . Port } ", failoverConnection . DataSource ) ;
610692 // 1 for the initial connection
693+ /* TODO: Fix flaky Assert.Equal() in this test method;
694+ Assert.Equal() Failure: Values differ
695+ Expected: 1
696+ Actual: 2
697+ */
611698 Assert . Equal ( 1 , server . PreLoginCount - server . AbandonedPreLoginCount ) ;
612699 // 1 for the failover connection
613700 Assert . Equal ( 1 , failoverServer . PreLoginCount - failoverServer . AbandonedPreLoginCount ) ;
@@ -789,6 +876,7 @@ public void TransientFault_WithUserProvidedPartner_Pooling_ShouldNotClearPool_No
789876 /// and never attempts failover alternation.
790877 /// </summary>
791878 [ Theory ]
879+ [ Trait ( "Category" , "flaky" ) ] // Assert.Throws() Failure: No exception was thrown
792880 [ InlineData ( 40613 ) ]
793881 [ InlineData ( 42108 ) ]
794882 [ InlineData ( 42109 ) ]
@@ -827,6 +915,8 @@ public void TransientFault_RetryDisabled_WithUserProvidedPartner_ShouldFail_NotF
827915 using SqlConnection connection = new ( builder . ConnectionString ) ;
828916
829917 // No outer connect retry is allowed, so the first transient error should surface.
918+ // TODO: Fix flakiness of Assert.Throws() in this test method; currently, if the exception is not thrown as expected,
919+ // Assert.Throws will fail the test with an assertion failure ("No exception was thrown").
830920 SqlException ex = Assert . Throws < SqlException > ( ( ) => connection . Open ( ) ) ;
831921
832922 Assert . Equal ( ( int ) errorCode , ex . Number ) ;
0 commit comments