private async Task <IpcEndpointInfo> AcceptAsync(EndpointInfoAccepter accepter) { using (var cancellationSource = new CancellationTokenSource(TimeSpan.FromSeconds(3))) { return(await accepter.AcceptAsync(cancellationSource.Token)); } }
/// <summary> /// Checks that the accepter does not provide a new endpoint info. /// </summary> private async Task VerifyNoNewEndpointInfos(EndpointInfoAccepter accepter) { _outputHelper.WriteLine("Verifying there are no more connections."); using var cancellationSource = new CancellationTokenSource(TimeSpan.FromSeconds(1)); Task acceptTask = accepter.AcceptAsync(cancellationSource.Token); await Assert.ThrowsAsync <OperationCanceledException>(() => acceptTask); Assert.True(acceptTask.IsCanceled); _outputHelper.WriteLine("Verified there are no more connections."); }
public async Task ReversedServerSingleTargetExitsClientInviableTest() { using var server = StartReversedServer(out string transportName); await using var accepter = new EndpointInfoAccepter(server, _outputHelper); TestRunner runner = null; IpcEndpointInfo info; try { // Start client pointing to diagnostics server runner = StartTracee(transportName); // Get client connection info = await AcceptAsync(accepter); await VerifyEndpointInfo(runner, info); // There should not be any new endpoint infos await VerifyNoNewEndpointInfos(accepter); ResumeRuntime(info); await VerifyWaitForConnection(info); } finally { _outputHelper.WriteLine("Stopping tracee."); runner?.Stop(); } // Wait some time for the process to exit await Task.Delay(TimeSpan.FromSeconds(1)); // Process exited so the endpoint should not have a valid transport anymore. await VerifyWaitForConnection(info, expectValid : false); Assert.True(server.RemoveConnection(info.RuntimeInstanceCookie), "Expected to be able to remove connection from server."); // There should not be any more endpoint infos await VerifyNoNewEndpointInfos(accepter); }