add instrumentation for intermittent DNS failures (dotnet/corefx#34934)
authorTomas Weinfurt <tweinfurt@yahoo.com>
Wed, 30 Jan 2019 03:14:29 +0000 (19:14 -0800)
committerGitHub <noreply@github.com>
Wed, 30 Jan 2019 03:14:29 +0000 (19:14 -0800)
* add instrumentation for dotnet/corefx#32797

* actually retry the lookup

* use PlatformID.Unix

Commit migrated from https://github.com/dotnet/corefx/commit/673fe7880790e79549266cea25a385af82917b6e

src/libraries/System.Net.NameResolution/tests/PalTests/NameResolutionPalTests.cs

index 639028b..21008a3 100644 (file)
@@ -35,7 +35,6 @@ namespace System.Net.NameResolution.PalTests
             Assert.NotNull(hostEntry.Aliases);
         }
 
-        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process))] // [ActiveIssue(32797)]
         public void TryGetAddrInfo_HostName()
         {
             string hostName = NameResolutionPal.GetHostName();
@@ -50,6 +49,16 @@ namespace System.Net.NameResolution.PalTests
                 // machine configurations, which varies by distro and is often inconsistent.
                 return;
             }
+
+            // Temporary instrumentation for #32797
+            if (error == SocketError.TryAgain && Environment.OSVersion.Platform == PlatformID.Unix)
+            {
+                error = NameResolutionPal.TryGetAddrInfo(hostName, out hostEntry, out nativeErrorCode);
+                if (error != SocketError.TryAgain)
+                {
+                    throw new InvalidOperationException("Name resolution failure preventable with retry");
+                }
+            }
             
             Assert.Equal(SocketError.Success, error);
             Assert.NotNull(hostEntry);
@@ -92,7 +101,6 @@ namespace System.Net.NameResolution.PalTests
             Assert.NotNull(name);
         }
 
-        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process))] // [ActiveIssue(32797)]
         public void TryGetAddrInfo_HostName_TryGetNameInfo()
         {
             string hostName = NameResolutionPal.GetHostName();
@@ -109,6 +117,16 @@ namespace System.Net.NameResolution.PalTests
                 return;
             }
 
+            // Temporary instrumentation for #32797
+            if (error == SocketError.TryAgain && Environment.OSVersion.Platform == PlatformID.Unix)
+            {
+                error = NameResolutionPal.TryGetAddrInfo(hostName, out hostEntry, out nativeErrorCode);
+                if (error != SocketError.TryAgain)
+                {
+                    throw new InvalidOperationException("Name resolution failure preventable with retry");
+                }
+            }
+
             Assert.Equal(SocketError.Success, error);
             Assert.NotNull(hostEntry);