public async Task ServerSourceAddRemoveSingleConnectionTest(TargetFrameworkMoniker appTfm) { EndpointInfoSourceCallback callback = new(_outputHelper); await using ServerSourceHolder sourceHolder = await _endpointUtilities.StartServerAsync(callback); var endpointInfos = await _endpointUtilities.GetEndpointInfoAsync(sourceHolder.Source); Assert.Empty(endpointInfos); AppRunner runner = _endpointUtilities.CreateAppRunner(sourceHolder.TransportName, appTfm); Task addedEndpointTask = callback.WaitAddedEndpointInfoAsync(runner, CommonTestTimeouts.StartProcess); Task removedEndpointTask = callback.WaitRemovedEndpointInfoAsync(runner, CommonTestTimeouts.StartProcess); await runner.ExecuteAsync(async() => { _outputHelper.WriteLine("Waiting for added endpoint notification."); await addedEndpointTask; _outputHelper.WriteLine("Received added endpoint notifications."); endpointInfos = await _endpointUtilities.GetEndpointInfoAsync(sourceHolder.Source); var endpointInfo = Assert.Single(endpointInfos); ValidateEndpointInfo(endpointInfo); await EndpointUtilities.VerifyConnectionAsync(runner, endpointInfo); await runner.SendCommandAsync(TestAppScenarios.AsyncWait.Commands.Continue); }); _outputHelper.WriteLine("Waiting for removed endpoint notification."); await removedEndpointTask; _outputHelper.WriteLine("Received removed endpoint notifications."); endpointInfos = await _endpointUtilities.GetEndpointInfoAsync(sourceHolder.Source); Assert.Empty(endpointInfos); }
public EnvironmentVariableActionTests(ITestOutputHelper outputHelper) { _outputHelper = outputHelper; _endpointUtilities = new(_outputHelper); }
public CollectDumpActionTests(ITestOutputHelper outputHelper) { _outputHelper = outputHelper; _endpointUtilities = new(_outputHelper); }
public async Task ServerSourceAddRemoveMultipleConnectionTest(TargetFrameworkMoniker appTfm) { EndpointInfoSourceCallback callback = new(_outputHelper); await using ServerSourceHolder sourceHolder = await _endpointUtilities.StartServerAsync(callback); var endpointInfos = await _endpointUtilities.GetEndpointInfoAsync(sourceHolder.Source); Assert.Empty(endpointInfos); const int appCount = 5; AppRunner[] runners = new AppRunner[appCount]; Task[] addedEndpointTasks = new Task[appCount]; Task[] removedEndpointTasks = new Task[appCount]; // Start all app instances for (int i = 0; i < appCount; i++) { runners[i] = _endpointUtilities.CreateAppRunner(sourceHolder.TransportName, appTfm, appId: i + 1); addedEndpointTasks[i] = callback.WaitAddedEndpointInfoAsync(runners[i], CommonTestTimeouts.StartProcess); removedEndpointTasks[i] = callback.WaitRemovedEndpointInfoAsync(runners[i], CommonTestTimeouts.StartProcess); } await runners.ExecuteAsync(async() => { _outputHelper.WriteLine("Waiting for all added endpoint notifications."); await Task.WhenAll(addedEndpointTasks); _outputHelper.WriteLine("Received all added endpoint notifications."); endpointInfos = await _endpointUtilities.GetEndpointInfoAsync(sourceHolder.Source); Assert.Equal(appCount, endpointInfos.Count()); for (int i = 0; i < appCount; i++) { int processId = await runners[i].ProcessIdTask; IEndpointInfo endpointInfo = endpointInfos.FirstOrDefault(info => info.ProcessId == processId); ValidateEndpointInfo(endpointInfo); await EndpointUtilities.VerifyConnectionAsync(runners[i], endpointInfo); await runners[i].SendCommandAsync(TestAppScenarios.AsyncWait.Commands.Continue); } }); _outputHelper.WriteLine("Waiting for all removed endpoint notifications."); await Task.WhenAll(removedEndpointTasks); _outputHelper.WriteLine("Received all removed endpoint notifications."); for (int i = 0; i < appCount; i++) { Assert.True(0 == runners[i].ExitCode, $"App {i} exit code is non-zero."); } await Task.Delay(TimeSpan.FromSeconds(1)); endpointInfos = await _endpointUtilities.GetEndpointInfoAsync(sourceHolder.Source); Assert.Empty(endpointInfos); }
public EndpointInfoSourceTests(ITestOutputHelper outputHelper) { _outputHelper = outputHelper; _endpointUtilities = new EndpointUtilities(_outputHelper); }