Powershell: Test-Connection test setup fails on macOS due to DNS issue

Created on 10 Jun 2020  路  19Comments  路  Source: PowerShell/PowerShell

From the test output:

  Describing Test-Connection
    [-] Error occurred in Describe block 0ms
      ExtendedSocketException: nodename nor servname provided, or not known
      MethodInvocationException: Exception calling "GetHostEntry" with "1" argument(s): "nodename nor servname provided, or not known"
      at <ScriptBlock>, /Users/runner/runners/2.170.1/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1: line 15
      at Invoke-Blocks, /Users/runner/runners/2.170.1/work/1/a/bins/publish/Modules/Pester/4.10.1/Functions/SetupTeardown.ps1: line 135
      at Invoke-TestGroupSetupBlocks, /Users/runner/runners/2.170.1/work/1/a/bins/publish/Modules/Pester/4.10.1/Functions/SetupTeardown.ps1: line 121
      at DescribeImpl, /Users/runner/runners/2.170.1/work/1/a/bins/publish/Modules/Pester/4.10.1/Functions/Describe.ps1: line 209

Based on https://github.com/dotnet/runtime/issues/29780#issuecomment-499084660, this seems to be a DNS resolution issue, and seems to be common on macOS.

I don't know enough about these tests or networking configuration to be a good judge of whether we should try to fix this or how, but want to discuss here if possible.

In particular:

  • Is this something we think we could fix or workaround in our code? The Test-Connection tests on macOS seem to have been flaky for some time.
  • Do we think there's some way we could improve the way the CI instance is configured to mitigate?
  • Otherwise, is there some other way we could perform test setup here that wouldn't hit this issue? Or possibly we could identify when we've hit this issue and handle it somehow?

/cc @JamesWTruher @SteveL-MSFT @iSazonov

Area-Maintainers-Build Issue-Bug Resolution-Fixed WG-Quality-Test

All 19 comments

I don't have high hopes for this. There are _tons_ of issues with the cmdlet on both MacOS and Linux, mainly because the basic .NET API for pings and just pretty much everything is... incomplete at best, and completely broken in some cases. (Try running a trace on Unix with the cmdlet; 99% of the data is unusable.) I filed an issue on the main ones that bothered me as I was (re)writing parts of the cmdlet last time around, and it's been largely ignored.

At best, it looks like the .NET team don't have the more barebones networking APIs high on the priority list.

I would consider marking the test as pending if it fails a lot.

Test is passing again for now. We have an issue at least now that we can refer back to. I'll close it for now, since it seems like there's not much we can do. But if repeated test failures prove to be a problem, we should consider making these tests -Pending

some kind of DNS resolution problem.

Is not very specific and $hostName = [System.Net.Dns]::GetHostName() should not really rely on a DNS server. I'm certain on my machine that it does not.

I would consider marking the test as pending if it fails a lot.

This is in a describe block, so pending the tests is not enough.

Is not very specific

See:

I don't know enough about these tests or networking configuration to be a good judge of whether we should try to fix this or how, but want to discuss here if possible.

I invite further discussion by any who are more familiar with the functionality here

We have a tracking issue here and in .Net Runtime repository. Can PowerShell team ping .Net team to fix the API? It is absolutely impossible to use the API on Unix-s _for years_. If they can not fix in .Net 5.0 maybe we switch to an alternative library to get Test-Connection working on Unix-s?

Looks like this is continuing to occur

Maybe MacOS image was updated?

Yeah, this wasn't happening when this code was introduced, nor when I was refactoring the cmdlet. Something appears to have changed there, for sure. 馃

Two possibilities I see:

  • the macOS host configuration has changed
  • we've taken a regression in .NET

We haven't updated .Net in last days.

Opened https://github.com/dotnet/runtime/issues/37766, since ifconfig is succeeding when .NET fails.

Looks like we might be able to attribute this to https://github.com/dotnet/runtime/issues/36849

Testing in my PR indicates that nslookup also fails on macOS, meaning this issue is external to macOS

Will we track actions/virtual-environments#1042 here?

:tada:This issue was addressed in #12943, which has now been successfully released as v7.1.0-preview.4.:tada:

Handy links:

:tada:This issue was addressed in #12943, which has now been successfully released as v7.0.3.:tada:

Handy links:

Was this page helpful?
0 / 5 - 0 ratings