From becd2bfc2834f2aef7cf78dc747656c092aff130 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Wed, 1 Jun 2022 17:03:42 +0200 Subject: [PATCH 1/4] Revert "Reenable GetHostAddressesTest_Cancellation on Unix (#70009)" This reverts commit e8b95926ed9880156071ee8575a7c22f13675081. --- .../tests/FunctionalTests/GetHostAddressesTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs index a522f4f5824ce6..02cb60e610080e 100644 --- a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs +++ b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs @@ -178,6 +178,7 @@ public async Task DnsGetHostAddresses_PreCancelledToken_Throws() public class GetHostAddressesTest_Cancellation { [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/33378", TestPlatforms.AnyUnix)] // Cancellation of an outstanding getaddrinfo is not supported on *nix. public async Task DnsGetHostAddresses_PostCancelledToken_Throws() { using var cts = new CancellationTokenSource(); @@ -198,6 +199,7 @@ public async Task DnsGetHostAddresses_PostCancelledToken_Throws() // This is a regression test for https://github.com/dotnet/runtime/issues/63552 [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/33378", TestPlatforms.AnyUnix)] // Cancellation of an outstanding getaddrinfo is not supported on *nix. public async Task DnsGetHostAddresses_ResolveParallelCancelOnFailure_AllCallsReturn() { string invalidAddress = TestSettings.UncachedHost; From 7165f85602c5b5f9bedf07a252c96c8523455c50 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Wed, 1 Jun 2022 17:12:15 +0200 Subject: [PATCH 2/4] Revert "Fix flakyness of DnsGetHostAddresses_PostCancelledToken_Throws (#70044)" This reverts commit a466063cd273e88276abe9d84eb28dccaf50d633. --- .../tests/FunctionalTests/GetHostAddressesTest.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs index 02cb60e610080e..10b588ebda6c8f 100644 --- a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs +++ b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs @@ -184,17 +184,13 @@ public async Task DnsGetHostAddresses_PostCancelledToken_Throws() using var cts = new CancellationTokenSource(); Task task = Dns.GetHostAddressesAsync(TestSettings.UncachedHost, cts.Token); - cts.Cancel(); - // This test is nondeterministic, the cancellation may take too long to trigger: + // This test might flake if the cancellation token takes too long to trigger: // It's a race between the DNS server getting back to us and the cancellation processing. - // since the host does not exist, both cases throw an exception. - Exception ex = await Assert.ThrowsAnyAsync(() => task); - if (ex is OperationCanceledException oce) - { - // canceled in time - Assert.Equal(cts.Token, oce.CancellationToken); - } + cts.Cancel(); + + OperationCanceledException oce = await Assert.ThrowsAnyAsync(() => task); + Assert.Equal(cts.Token, oce.CancellationToken); } // This is a regression test for https://github.com/dotnet/runtime/issues/63552 From 496e0dcc06b43a9b547527111e4121ad8ebec88e Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Wed, 1 Jun 2022 17:12:41 +0200 Subject: [PATCH 3/4] Disable flaky tests on jitstress --- .../tests/FunctionalTests/GetHostAddressesTest.cs | 2 ++ .../tests/FunctionalTests/GetHostEntryTest.cs | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs index 10b588ebda6c8f..c7e6b44df95e5e 100644 --- a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs +++ b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs @@ -179,6 +179,7 @@ public class GetHostAddressesTest_Cancellation { [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/33378", TestPlatforms.AnyUnix)] // Cancellation of an outstanding getaddrinfo is not supported on *nix. + [SkipOnCoreClr("JitStress interferes with cancellation timing", RuntimeTestModes.JitStress | RuntimeTestModes.JitStressRegs)] public async Task DnsGetHostAddresses_PostCancelledToken_Throws() { using var cts = new CancellationTokenSource(); @@ -196,6 +197,7 @@ public async Task DnsGetHostAddresses_PostCancelledToken_Throws() // This is a regression test for https://github.com/dotnet/runtime/issues/63552 [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/33378", TestPlatforms.AnyUnix)] // Cancellation of an outstanding getaddrinfo is not supported on *nix. + [SkipOnCoreClr("JitStress interferes with cancellation timing", RuntimeTestModes.JitStress | RuntimeTestModes.JitStressRegs)] public async Task DnsGetHostAddresses_ResolveParallelCancelOnFailure_AllCallsReturn() { string invalidAddress = TestSettings.UncachedHost; diff --git a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostEntryTest.cs b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostEntryTest.cs index 69cf72e00af08f..a4a7174897a397 100644 --- a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostEntryTest.cs +++ b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostEntryTest.cs @@ -81,7 +81,7 @@ public async Task Dns_GetHostEntry_HostString_Ok(string hostName) [ConditionalTheory(nameof(GetHostEntryWorks))] [InlineData("")] [InlineData(TestSettings.LocalHost)] - public async Task Dns_GetHostEntryAsync_HostString_Ok(string hostName) + public async Task Dns_GetHostEntryAsync_HostString_Ok(string hostName) { await TestGetHostEntryAsync(() => Dns.GetHostEntryAsync(hostName)); } @@ -122,7 +122,7 @@ static void RunTest(string hostnameInner) { Assert.NotEqual(AddressFamily.InterNetworkV6, address.AddressFamily); } - } + } } [ConditionalTheory(nameof(GetHostEntry_DisableIPv6_Condition))] @@ -315,9 +315,10 @@ public async Task DnsGetHostEntry_PreCancelledToken_Throws() [Collection(nameof(DisableParallelization))] public class GetHostEntryTest_Cancellation { + [Fact] [OuterLoop] [ActiveIssue("https://github.com/dotnet/runtime/issues/33378", TestPlatforms.AnyUnix)] // Cancellation of an outstanding getaddrinfo is not supported on *nix. - [Fact] + [SkipOnCoreClr("JitStress interferes with cancellation timing", RuntimeTestModes.JitStress | RuntimeTestModes.JitStressRegs)] public async Task DnsGetHostEntry_PostCancelledToken_Throws() { // Windows 7 name resolution is synchronous and does not respect cancellation. From 53366cf1481a916ae44a531b1cb3fcc89982b682 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Wed, 1 Jun 2022 17:26:58 +0200 Subject: [PATCH 4/4] fixup! Disable flaky tests on jitstress --- .../tests/FunctionalTests/GetHostAddressesTest.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs index c7e6b44df95e5e..c5b05e7bb680e9 100644 --- a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs +++ b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs @@ -197,7 +197,6 @@ public async Task DnsGetHostAddresses_PostCancelledToken_Throws() // This is a regression test for https://github.com/dotnet/runtime/issues/63552 [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/33378", TestPlatforms.AnyUnix)] // Cancellation of an outstanding getaddrinfo is not supported on *nix. - [SkipOnCoreClr("JitStress interferes with cancellation timing", RuntimeTestModes.JitStress | RuntimeTestModes.JitStressRegs)] public async Task DnsGetHostAddresses_ResolveParallelCancelOnFailure_AllCallsReturn() { string invalidAddress = TestSettings.UncachedHost;