public async Task <ServerSourceHolder> StartServerAsync(EndpointInfoSourceCallback sourceCallback = null, IDumpService dumpService = null, OperationTrackerService operationTrackerService = null) { DiagnosticPortHelper.Generate(DiagnosticPortConnectionMode.Listen, out _, out string transportName); _outputHelper.WriteLine("Starting server endpoint info source at '" + transportName + "'."); List <IEndpointInfoSourceCallbacks> callbacks = new(); if (null != sourceCallback) { callbacks.Add(sourceCallback); if (null != dumpService) { callbacks.Add(new OperationTrackerServiceEndpointInfoSourceCallback(operationTrackerService)); } } IOptions <DiagnosticPortOptions> portOptions = Extensions.Options.Options.Create( new DiagnosticPortOptions() { ConnectionMode = DiagnosticPortConnectionMode.Listen, EndpointName = transportName }); ServerEndpointInfoSource source = new(portOptions, callbacks, operationTrackerService); await source.StartAsync(CancellationToken.None); return(new ServerSourceHolder(source, transportName)); }
public CollectTraceAction(IServiceProvider serviceProvider, IEndpointInfo endpointInfo, CollectTraceOptions options) : base(endpointInfo, options) { _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _counterOptions = _serviceProvider.GetRequiredService <IOptionsMonitor <GlobalCounterOptions> >(); _operationTrackerService = _serviceProvider.GetRequiredService <OperationTrackerService>(); }
public DiagController(ILogger <DiagController> logger, IServiceProvider serviceProvider) { _logger = logger; _diagnosticServices = serviceProvider.GetRequiredService <IDiagnosticServices>(); _diagnosticPortOptions = serviceProvider.GetService <IOptions <DiagnosticPortOptions> >(); _operationsStore = serviceProvider.GetRequiredService <EgressOperationStore>(); _dumpService = serviceProvider.GetRequiredService <IDumpService>(); _counterOptions = serviceProvider.GetRequiredService <IOptionsMonitor <GlobalCounterOptions> >(); _operationTrackerService = serviceProvider.GetRequiredService <OperationTrackerService>(); }
public async Task ServerSourceNoPruneDuringDumpTest(TargetFrameworkMoniker appTfm) { EndpointInfoSourceCallback callback = new(_outputHelper); var operationTrackerService = new OperationTrackerService(); MockDumpService dumpService = new(operationTrackerService); await using ServerSourceHolder sourceHolder = await _endpointUtilities.StartServerAsync(callback, dumpService, operationTrackerService); AppRunner runner = _endpointUtilities.CreateAppRunner(sourceHolder.TransportName, appTfm); Task <IEndpointInfo> addedEndpointTask = callback.WaitAddedEndpointInfoAsync(runner, CommonTestTimeouts.StartProcess); Task <IEndpointInfo> removedEndpointTask = callback.WaitRemovedEndpointInfoAsync(runner, CommonTestTimeouts.StartProcess); Task <Stream> dumpTask = null; IEndpointInfo endpointInfo = null; await runner.ExecuteAsync(async() => { _outputHelper.WriteLine("Waiting for added endpoint notification."); endpointInfo = await addedEndpointTask; _outputHelper.WriteLine("Received added endpoint notifications."); // Start a dump operation; the process should not be pruned until the operation is completed. dumpTask = dumpService.DumpAsync(endpointInfo, DumpType.Triage, CancellationToken.None); await runner.SendCommandAsync(TestAppScenarios.AsyncWait.Commands.Continue); }); // At this point, the process should no longer exist; but since the mock dump operation is // in progress, the ServiceEndpointInfoSource should not prune the process until the operation // is complete. int processId = await runner.ProcessIdTask; // Test that the process still exists. Assert.False(removedEndpointTask.IsCompleted); IEnumerable <IEndpointInfo> endpointInfos = await _endpointUtilities.GetEndpointInfoAsync(sourceHolder.Source); endpointInfo = Assert.Single(endpointInfos); Assert.Equal(processId, endpointInfo.ProcessId); // Signal and wait for mock dump operation to complete. dumpService.CompleteOperation(); await dumpTask; // Process should no longer exist endpointInfos = await _endpointUtilities.GetEndpointInfoAsync(sourceHolder.Source); Assert.Empty(endpointInfos); // Test that process removal sent notification endpointInfo = await removedEndpointTask; Assert.Equal(processId, endpointInfo.ProcessId); }
public OperationTrackerServiceEndpointInfoSourceCallback(OperationTrackerService operationTrackerService) { _operationTrackerService = operationTrackerService ?? throw new ArgumentNullException(nameof(operationTrackerService)); }
public MockDumpService(OperationTrackerService operationTrackerService) { _operationTrackerService = operationTrackerService; }