Re-enable hostname resolution test on Linux, but skip under certain conditions#28324
Conversation
| { | ||
| // On Unix, we are not guaranteed to be able to resove the local host. The ability to do so depends on the | ||
| // machine configurations, which varies by distro and is often inconsistent. | ||
| Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)); |
There was a problem hiding this comment.
Not: I wonder if it would be "better" to move OS check into the if-condition. If we ever get HostNotFound on Windows, it should ideally fail on the Assert.Equal(SocketError.Succes, error); line.
If this is established pattern in other tests, I'm fine leaving it as is.
There was a problem hiding this comment.
I would rather see the OS checks in the if-condition. This is usually how we do OS platform-specific tests using 'ifs'. It makes the code easier to read if we see things like this:
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// Test setup and assertions specific to Linux
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
// Test setup and assertions specific to OSX
}
// ...There was a problem hiding this comment.
This is really not specific to OS but given environment. Linux can resolve the names if configured as such. Add it will in most cases.
There was a problem hiding this comment.
Do you think it's better to do things this way, or to set up a capability as mentioned by @wfurt below?
There was a problem hiding this comment.
Capabilities are not used for this kind of thing. This is basically a platform difference in behavior that you want to capture in a test.
There was a problem hiding this comment.
Made this change. I agree that it's an improvement over the check I initially added -- it should make failures a lot more clear.
|
Can we turn this into test Capability? |
Long-term, why not if it is possible. Short-term, let's just disable the test on Linux / skip the testing as @rmkerr proposes. |
|
I can't see why the Linux build failed, so I'm rerunning it. The Windows failures are unrelated, but I'm rerunning them anyways since I have the chance. @dotnet-bot test Linux x64 Release Build |
…onditions (dotnet/corefx#28324) This test assumed that the host name can always be resolved, which isn't guaranteed on Unix. In the interest of "testing as much as we can" this change enables the test, but passes it if we get the specific error that indicates we haven't been able to resolve the localhost on Unix. That way we'll hopefully still see failures if things go wrong somewhere else. Fixes: dotnet/corefx#20245 Commit migrated from dotnet/corefx@69ba7ef
This test assumed that the host name can always be resolved, which isn't guaranteed on Unix.
In the interest of "testing as much as we can" I'm going to enable the test, but pass it if we get the specific error that indicates we haven't been able to resolve the localhost on Unix. That way we'll hopefully still see failures if things go wrong somewhere else.
The logic to skip the test is taken from another test in the same file:
corefx/src/System.Net.NameResolution/tests/PalTests/NameResolutionPalTests.cs
Lines 89 to 104 in 643bccc
Fixes: #20245