Skip to content

Commit

Permalink
Cleanup SocketOptionNameTest
Browse files Browse the repository at this point in the history
One of the oldest issues #4887 was about the Windows socket option, ReuseUnicastPort.
This test was disabled several years ago because it was very difficult to test in CI since it
required not only a newer version of Windows but also specific network settings on the machine.

At this point, there is not any way to reliably test this. And the end-to-end test isn't really
of high value for .NET Core since we would really be mostly testing an OS feature.

As part of cleaning that issue up, I cleaned up the rest of the tests, some of which were marked
as Outerloop but didn't need to be.

Closes #29929
Closes #21327
Closes #4887
  • Loading branch information
davidsh committed Apr 14, 2019
1 parent 822da31 commit 0d57179
Showing 1 changed file with 7 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public partial class SocketOptionNameTest
{
private static bool SocketsReuseUnicastPortSupport => Capability.SocketsReuseUnicastPortSupport().HasValue;

[OuterLoop] // TODO: Issue #11345
[ConditionalFact(nameof(SocketsReuseUnicastPortSupport))]
public void ReuseUnicastPort_CreateSocketGetOption()
{
Expand All @@ -34,7 +33,6 @@ public void ReuseUnicastPort_CreateSocketGetOption()
}
}

[OuterLoop] // TODO: Issue #11345
[ConditionalFact(nameof(SocketsReuseUnicastPortSupport))]
public void ReuseUnicastPort_CreateSocketSetOption()
{
Expand All @@ -53,22 +51,6 @@ public void ReuseUnicastPort_CreateSocketSetOption()
}
}

// TODO: Issue #4887
// The socket option 'ReuseUnicastPost' only works on Windows 10 systems. In addition, setting the option
// is a no-op unless specialized network settings using PowerShell configuration are first applied to the
// machine. This is currently difficult to test in the CI environment. So, this test will be disabled for now
[OuterLoop] // TODO: Issue #11345
[ActiveIssue(4887)]
public void ReuseUnicastPort_CreateSocketSetOptionToOneAndGetOption_SocketsReuseUnicastPortSupport_OptionIsOne()
{
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseUnicastPort, 1);
int optionValue = (int)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseUnicastPort);
Assert.Equal(1, optionValue);
}

[OuterLoop] // TODO: Issue #11345
[Fact]
public void MulticastOption_CreateSocketSetGetOption_GroupAndInterfaceIndex_SetSucceeds_GetThrows()
{
Expand All @@ -83,18 +65,16 @@ public void MulticastOption_CreateSocketSetGetOption_GroupAndInterfaceIndex_SetS
}
}

[OuterLoop] // TODO: Issue #11345
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // ActiveIssue: dotnet/corefx #29929
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // Skip on Nano: dotnet/corefx #29929
public async Task MulticastInterface_Set_AnyInterface_Succeeds()
{
// On all platforms, index 0 means "any interface"
await MulticastInterface_Set_Helper(0);
}

[OuterLoop] // TODO: Issue #11345
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // ActiveIssue: dotnet/corefx #29929
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // Skip on Nano: dotnet/corefx #29929
[PlatformSpecific(TestPlatforms.Windows)] // see comment below
[ActiveIssue(21327, TargetFrameworkMonikers.Uap)] // UWP Apps are forbidden to send network traffic to the local Computer.
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // UWP Apps are normally blocked to send network traffic on loopback.
public async Task MulticastInterface_Set_Loopback_Succeeds()
{
// On Windows, we can apparently assume interface 1 is "loopback." On other platforms, this is not a
Expand Down Expand Up @@ -138,7 +118,6 @@ private async Task MulticastInterface_Set_Helper(int interfaceIndex)
}
}

[OuterLoop] // TODO: Issue #11345
[Fact]
public void MulticastInterface_Set_InvalidIndex_Throws()
{
Expand All @@ -150,8 +129,7 @@ public void MulticastInterface_Set_InvalidIndex_Throws()
}
}

[OuterLoop] // TODO: Issue #11345
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // ActiveIssue: dotnet/corefx #29929
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // Skip on Nano: dotnet/corefx #29929
[PlatformSpecific(~TestPlatforms.OSX)]
public async Task MulticastInterface_Set_IPv6_AnyInterface_Succeeds()
{
Expand Down Expand Up @@ -179,7 +157,7 @@ public void MulticastTTL_Set_IPv4_Succeeds()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // ActiveIssue: dotnet/corefx #29929
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // Skip on Nano: dotnet/corefx #29929
public void MulticastTTL_Set_IPv6_Succeeds()
{
using (Socket socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp))
Expand Down Expand Up @@ -208,10 +186,9 @@ public void Ttl_Set_Succeeds(AddressFamily af)
}
}

[OuterLoop] // TODO: Issue #11345
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // ActiveIssue: dotnet/corefx #29929
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // Skip on Nano: dotnet/corefx #29929
[PlatformSpecific(TestPlatforms.Windows)]
[ActiveIssue(21327, TargetFrameworkMonikers.Uap)] // UWP Apps are forbidden to send network traffic to the local Computer.
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // UWP Apps are normally blocked to send network traffic on loopback.
public async void MulticastInterface_Set_IPv6_Loopback_Succeeds()
{
// On Windows, we can apparently assume interface 1 is "loopback." On other platforms, this is not a
Expand Down Expand Up @@ -266,7 +243,6 @@ public void MulticastInterface_Set_IPv6_InvalidIndex_Throws()
}
}

[OuterLoop] // TODO: Issue #11345
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // In WSL, the connect() call fails immediately.
[InlineData(false)]
[InlineData(true)]
Expand Down Expand Up @@ -524,7 +500,6 @@ public unsafe void ReuseAddressUdp()
}
}

[OuterLoop] // TODO: Issue #11345
[Theory]
[PlatformSpecific(TestPlatforms.Windows)] // SetIPProtectionLevel not supported on Unix
[InlineData(IPProtectionLevel.EdgeRestricted, AddressFamily.InterNetwork, SocketOptionLevel.IP)]
Expand All @@ -544,7 +519,6 @@ public void SetIPProtectionLevel_Windows(IPProtectionLevel level, AddressFamily
}
}

[OuterLoop] // TODO: Issue #11345
[Theory]
[PlatformSpecific(TestPlatforms.AnyUnix)] // SetIPProtectionLevel not supported on Unix
[InlineData(IPProtectionLevel.EdgeRestricted, AddressFamily.InterNetwork)]
Expand All @@ -561,7 +535,6 @@ public void SetIPProtectionLevel_Unix(IPProtectionLevel level, AddressFamily fam
}
}

[OuterLoop] // TODO: Issue #11345
[Theory]
[InlineData(AddressFamily.InterNetwork)]
[InlineData(AddressFamily.InterNetworkV6)]
Expand Down

0 comments on commit 0d57179

Please sign in to comment.