@@ -355,10 +355,11 @@ private void FileServerFailoverTest(string server, FileServerType fsType, bool r
355355 if ( fsType == FileServerType . GeneralFileServer )
356356 {
357357 currentAccessIpAddr = null ;
358- this . sutController . FlushDNS ( ) ;
359- IPAddress [ ] accessIpList = Dns . GetHostEntry ( server ) . AddressList ;
358+
360359 DoUntilSucceed ( ( ) =>
361360 {
361+ this . sutController . FlushDNS ( ) ;
362+ IPAddress [ ] accessIpList = Dns . GetHostEntry ( server ) . AddressList ;
362363 foreach ( IPAddress ipAddress in accessIpList )
363364 {
364365 Smb2FunctionalClient pingClient = new Smb2FunctionalClient ( TestConfig . FailoverTimeout , TestConfig , BaseTestSite ) ;
@@ -382,34 +383,38 @@ private void FileServerFailoverTest(string server, FileServerType fsType, bool r
382383 else
383384 {
384385 currentAccessIpAddr = null ;
385- this . sutController . FlushDNS ( ) ;
386- IPAddress [ ] accessIpList = Dns . GetHostEntry ( server ) . AddressList ;
387- foreach ( IPAddress ipAddress in accessIpList )
386+ DoUntilSucceed ( ( ) =>
388387 {
389- if ( TestConfig . IsWindowsPlatform )
388+ this . sutController . FlushDNS ( ) ;
389+ IPAddress [ ] accessIpList = Dns . GetHostEntry ( server ) . AddressList ;
390+ foreach ( IPAddress ipAddress in accessIpList )
390391 {
391- // When setting failover mode to StopNodeService for Windows, SMB2 servers on two nodes can still be accessed by the client.
392- // So the client needs to get the new node to access it after failover by comparing host name.
393- if ( ! reconnectWithoutFailover && string . Compare ( currentAccessNode , Dns . GetHostEntry ( ipAddress ) . HostName , true ) == 0 )
392+ if ( TestConfig . IsWindowsPlatform )
394393 {
395- continue ;
394+ // When setting failover mode to StopNodeService for Windows, SMB2 servers on two nodes can still be accessed by the client.
395+ // So the client needs to get the new node to access it after failover by comparing host name.
396+ if ( ! reconnectWithoutFailover && string . Compare ( currentAccessNode , Dns . GetHostEntry ( ipAddress ) . HostName , true ) == 0 )
397+ {
398+ continue ;
399+ }
396400 }
397- }
398- Smb2FunctionalClient pingClient = new Smb2FunctionalClient ( TestConfig . FailoverTimeout , TestConfig , BaseTestSite ) ;
401+ Smb2FunctionalClient pingClient = new Smb2FunctionalClient ( TestConfig . FailoverTimeout , TestConfig , BaseTestSite ) ;
399402
400- try
401- {
402- pingClient . ConnectToServerOverTCP ( ipAddress ) ;
403- pingClient . Disconnect ( ) ;
404- pingClient = null ;
403+ try
404+ {
405+ pingClient . ConnectToServerOverTCP ( ipAddress ) ;
406+ pingClient . Disconnect ( ) ;
407+ pingClient = null ;
405408
406- currentAccessIpAddr = ipAddress ;
407- break ;
408- }
409- catch
410- {
409+ currentAccessIpAddr = ipAddress ;
410+ return true ;
411+ }
412+ catch
413+ {
414+ }
411415 }
412- }
416+ return false ;
417+ } , TestConfig . FailoverTimeout , "Retry to ping to server until succeed within timeout span" ) ;
413418 }
414419 }
415420 else if ( witnessType == WitnessType . SwnWitness )
0 commit comments