Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
add instrumentation for intermittent DNS failures (#34934)
Browse files Browse the repository at this point in the history
* add instrumentation for #32797

* actually retry the lookup

* use PlatformID.Unix
  • Loading branch information
wfurt committed Jan 30, 2019
1 parent 9df6657 commit 673fe78
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public void TryGetAddrInfo_LocalHost()
Assert.NotNull(hostEntry.Aliases);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process))] // [ActiveIssue(32797)]
public void TryGetAddrInfo_HostName()
{
string hostName = NameResolutionPal.GetHostName();
Expand All @@ -50,6 +49,16 @@ public void TryGetAddrInfo_HostName()
// 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);
Expand Down Expand Up @@ -92,7 +101,6 @@ public void TryGetAddrInfo_LocalHost_TryGetNameInfo()
Assert.NotNull(name);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process))] // [ActiveIssue(32797)]
public void TryGetAddrInfo_HostName_TryGetNameInfo()
{
string hostName = NameResolutionPal.GetHostName();
Expand All @@ -109,6 +117,16 @@ public void TryGetAddrInfo_HostName_TryGetNameInfo()
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);

Expand Down

0 comments on commit 673fe78

Please sign in to comment.