public async Task DisposeAsync() { await _session.StopHostAsync(); _session.Dispose(); _brokerConnector.Dispose(); }
public async Task DisposeAsync() { await _session.StopHostAsync(); _session.Dispose(); _brokerClient.Dispose(); }
public async Task DisposeAsync() { await _session.StopHostAsync().Should().BeCompletedAsync(); _session.Dispose(); _brokerClient.Dispose(); }
public async Task StopReentrantLoop() { var callback = new RSessionCallbackStub(); var session = new RSession(0, _testMethod.FileSystemSafeName, _brokerClient, new AsyncReaderWriterLock().CreateExclusiveReaderLock(), () => { }); await session.StartHostAsync(new RHostStartupInfo(), callback, 50000); var testMrs = new AsyncManualResetEvent(); callback.PlotHandler = (message, ct) => { testMrs.Set(); return(session.EvaluateAsync("x <- 1\n")); }; Task responceTask; using (var interaction = await session.BeginInteractionAsync()) { responceTask = interaction.RespondAsync("plot(1)\n"); } await testMrs.WaitAsync().Should().BeCompletedAsync(); await session.StopHostAsync().Should().BeCompletedAsync(20000); session.IsHostRunning.Should().BeFalse(); await responceTask.Should().BeCanceledAsync(); }
public async Task StartStop() { var session = new RSession(0, _brokerClient, () => { }); session.HostStarted.Status.Should().Be(TaskStatus.WaitingForActivation); session.IsHostRunning.Should().BeFalse(); await session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, null, 50000); session.HostStarted.Status.Should().Be(TaskStatus.RanToCompletion); session.IsHostRunning.Should().BeTrue(); await session.StopHostAsync(); session.HostStarted.Status.Should().Be(TaskStatus.WaitingForActivation); session.IsHostRunning.Should().BeFalse(); await session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, null, 50000); session.HostStarted.Status.Should().Be(TaskStatus.RanToCompletion); session.IsHostRunning.Should().BeTrue(); }
public async Task StopBeforeInitialized() { var session = new RSession(0, _testMethod.FileSystemSafeName, _brokerClient, new AsyncReaderWriterLock().CreateExclusiveReaderLock(), () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo(), null, 10000); var startTask = Task.Run(start); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); await startTask; }
public async Task StopBeforeInitialized() { var session = new RSession(0, () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name, RHostDirectory = Environment.SystemDirectory }, null, 10000); Task.Run(start).DoNotWait(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); }
public async Task StopBeforeInitialized_RHostMissing() { var brokerClient = new LocalBrokerClient(nameof(RSessionTest), BrokerConnectionInfo.Create(null, "C", @"C:\"), _services, new NullConsole(), Environment.SystemDirectory); var session = new RSession(0, _testMethod.FileSystemSafeName, brokerClient, new AsyncReaderWriterLock().CreateExclusiveReaderLock(), () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo(), null, 10000); var startTask = Task.Run(start).SilenceException <RHostBinaryMissingException>(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); await startTask; }
public async Task StopBeforeInitialized() { var session = new RSession(0, _brokerConnector, () => { }); session.BrokerConnector.SwitchToLocalBroker(nameof(RSessionTest), @"C:\", Environment.SystemDirectory); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, null, 10000); Task.Run(start).DoNotWait(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); }
public async Task StopBeforeInitialized() { var session = new RSession(0, _brokerClient, () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, null, 10000); var startTask = Task.Run(start); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); await startTask; }
public async Task StopBeforeInitialized_RHostMissing() { var brokerClient = new LocalBrokerClient(nameof(RSessionTest), @"C:\", TestCoreServices.CreateReal(), new NullConsole(), Environment.SystemDirectory); var session = new RSession(0, brokerClient, () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, null, 10000); var startTask = Task.Run(start).SilenceException <RHostBrokerBinaryMissingException>(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); await startTask; }
public async Task DoubleStart() { var session = new RSession(0, _testMethod.FileSystemSafeName, _brokerClient, new AsyncReaderWriterLock().CreateExclusiveReaderLock(), () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo(), null, 50000); var tasks = await ParallelTools.InvokeAsync(4, i => start(), 50000); tasks.Should().ContainSingle(t => t.Status == TaskStatus.RanToCompletion); await session.HostStarted; session.IsHostRunning.Should().BeTrue(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); }
public async Task DoubleStart() { var session = new RSession(0, _brokerClient, () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, null, 50000); var tasks = await ParallelTools.InvokeAsync(4, i => start(), 50000); tasks.Should().ContainSingle(t => t.Status == TaskStatus.RanToCompletion); await session.HostStarted; session.IsHostRunning.Should().BeTrue(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); }
public async Task DoubleStart() { var session = new RSession(0, _brokerConnector, () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, null, 50000); Func <Task> f = () => ParallelTools.InvokeAsync(4, i => start()); f.ShouldThrow <InvalidOperationException>(); await session.HostStarted; session.IsHostRunning.Should().BeTrue(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); }
public async Task StartStop() { var session = new RSession(0, () => { }); session.HostStarted.Status.Should().Be(TaskStatus.Canceled); session.IsHostRunning.Should().BeFalse(); await session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name, RBasePath = RUtilities.FindExistingRBasePath() }, null, 50000); session.HostStarted.Status.Should().Be(TaskStatus.RanToCompletion); session.IsHostRunning.Should().BeTrue(); await session.StopHostAsync(); session.HostStarted.Status.Should().Be(TaskStatus.Canceled); session.IsHostRunning.Should().BeFalse(); }
public async Task DoubleStart() { var session = new RSession(0, null, () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name, RBasePath = RUtilities.FindExistingRBasePath() }, 50000); Func <Task> f = () => ParallelTools.InvokeAsync(4, i => start()); f.ShouldThrow <InvalidOperationException>(); await session.HostStarted; session.IsHostRunning.Should().BeTrue(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); }
public async Task StartStop() { var session = new RSession(0, _testMethod.FileSystemSafeName, _brokerClient, new AsyncReaderWriterLock().CreateExclusiveReaderLock(), () => { }); session.HostStarted.Should().NotBeCompleted(); session.IsHostRunning.Should().BeFalse(); await session.StartHostAsync(new RHostStartupInfo(), null, 50000); session.HostStarted.Should().BeRanToCompletion(); session.IsHostRunning.Should().BeTrue(); await session.StopHostAsync(); session.HostStarted.Should().NotBeCompleted(); session.IsHostRunning.Should().BeFalse(); await session.StartHostAsync(new RHostStartupInfo(), null, 50000); session.HostStarted.Should().BeRanToCompletion(); session.IsHostRunning.Should().BeTrue(); }
public Task StopSessionAsync() => RSession?.StopHostAsync(waitForShutdown: false) ?? Task.CompletedTask;