File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
src/libraries/System.Net.NameResolution/tests/FunctionalTests Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,6 @@ public void GetHostEntry_InvalidHost_LogsError()
63
63
}
64
64
65
65
[ ConditionalFact ]
66
- [ PlatformSpecific ( ~ TestPlatforms . Windows ) ] // Unreliable on Windows.
67
66
public async Task GetHostEntryAsync_InvalidHost_LogsError ( )
68
67
{
69
68
using ( var listener = new TestEventListener ( "Private.InternalDiagnostics.System.Net.NameResolution" , EventLevel . Error ) )
@@ -79,8 +78,7 @@ await listener.RunWithCallbackAsync(ev => events.Enqueue(ev), async () =>
79
78
}
80
79
catch ( SocketException e ) when ( e . SocketErrorCode == SocketError . HostNotFound )
81
80
{
82
- // Wait a bit to let the event source write it's log
83
- await Task . Delay ( 100 ) . ConfigureAwait ( false ) ;
81
+ await WaitForErrorEventAsync ( events ) ;
84
82
}
85
83
catch ( Exception e )
86
84
{
@@ -97,6 +95,20 @@ await listener.RunWithCallbackAsync(ev => events.Enqueue(ev), async () =>
97
95
Assert . NotNull ( ev . Payload [ 2 ] ) ;
98
96
}
99
97
}
98
+
99
+ static async Task WaitForErrorEventAsync ( ConcurrentQueue < EventWrittenEventArgs > events )
100
+ {
101
+ const int ErrorEventId = 5 ;
102
+ DateTime startTime = DateTime . UtcNow ;
103
+
104
+ while ( ! events . Any ( e => e . EventId == ErrorEventId ) )
105
+ {
106
+ if ( DateTime . UtcNow . Subtract ( startTime ) > TimeSpan . FromSeconds ( 30 ) )
107
+ throw new TimeoutException ( "Timeout waiting for error event" ) ;
108
+
109
+ await Task . Delay ( 100 ) ;
110
+ }
111
+ }
100
112
}
101
113
102
114
[ ConditionalFact ]
You can’t perform that action at this time.
0 commit comments