SEBWIN-226: Simplified timeouts for client operation.
This commit is contained in:
parent
06497258fd
commit
21d0a82b43
5 changed files with 15 additions and 20 deletions
|
@ -65,7 +65,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
sessionContext.Next = session.Object;
|
sessionContext.Next = session.Object;
|
||||||
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
|
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
|
||||||
|
|
||||||
sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0, 0);
|
sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@ -112,7 +112,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
var terminateClient = new Action(() => Task.Delay(100).ContinueWith(_ => process.Raise(p => p.Terminated += null, 0)));
|
var terminateClient = new Action(() => Task.Delay(100).ContinueWith(_ => process.Raise(p => p.Terminated += null, 0)));
|
||||||
|
|
||||||
processFactory.Setup(f => f.StartNew(It.IsAny<string>(), It.IsAny<string[]>())).Returns(process.Object).Callback(terminateClient);
|
processFactory.Setup(f => f.StartNew(It.IsAny<string>(), It.IsAny<string[]>())).Returns(process.Object).Callback(terminateClient);
|
||||||
sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, ONE_SECOND, ONE_SECOND);
|
sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, ONE_SECOND);
|
||||||
|
|
||||||
before = DateTime.Now;
|
before = DateTime.Now;
|
||||||
result = sut.Perform();
|
result = sut.Perform();
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
sessionContext.Next = session.Object;
|
sessionContext.Next = session.Object;
|
||||||
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
|
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
|
||||||
|
|
||||||
sut = new ClientTerminationOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0, 0);
|
sut = new ClientTerminationOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
|
@ -49,7 +49,6 @@ namespace SafeExamBrowser.Runtime
|
||||||
internal void BuildObjectGraph(Action shutdown)
|
internal void BuildObjectGraph(Action shutdown)
|
||||||
{
|
{
|
||||||
const int FIVE_SECONDS = 5000;
|
const int FIVE_SECONDS = 5000;
|
||||||
const int FIFTEEN_SECONDS = 15000;
|
|
||||||
const int THIRTY_SECONDS = 30000;
|
const int THIRTY_SECONDS = 30000;
|
||||||
|
|
||||||
var args = Environment.GetCommandLineArgs();
|
var args = Environment.GetCommandLineArgs();
|
||||||
|
@ -80,11 +79,11 @@ namespace SafeExamBrowser.Runtime
|
||||||
|
|
||||||
sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost, sessionContext));
|
sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost, sessionContext));
|
||||||
sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new HashAlgorithm(), logger, sessionContext));
|
sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new HashAlgorithm(), logger, sessionContext));
|
||||||
sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS, FIFTEEN_SECONDS));
|
sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
|
||||||
sessionOperations.Enqueue(new KioskModeTerminationOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
|
sessionOperations.Enqueue(new KioskModeTerminationOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
|
||||||
sessionOperations.Enqueue(new ServiceOperation(logger, serviceProxy, sessionContext));
|
sessionOperations.Enqueue(new ServiceOperation(logger, serviceProxy, sessionContext));
|
||||||
sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
|
sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
|
||||||
sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS, FIFTEEN_SECONDS));
|
sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
|
||||||
sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext));
|
sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext));
|
||||||
|
|
||||||
var bootstrapSequence = new OperationSequence(logger, bootstrapOperations);
|
var bootstrapSequence = new OperationSequence(logger, bootstrapOperations);
|
||||||
|
|
|
@ -21,8 +21,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
{
|
{
|
||||||
internal class ClientOperation : SessionOperation
|
internal class ClientOperation : SessionOperation
|
||||||
{
|
{
|
||||||
private readonly int startup_timeout_ms;
|
private int timeout_ms;
|
||||||
private readonly int shutdown_timeout_ms;
|
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private IProcessFactory processFactory;
|
private IProcessFactory processFactory;
|
||||||
private IProxyFactory proxyFactory;
|
private IProxyFactory proxyFactory;
|
||||||
|
@ -49,15 +48,13 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
IProxyFactory proxyFactory,
|
IProxyFactory proxyFactory,
|
||||||
IRuntimeHost runtimeHost,
|
IRuntimeHost runtimeHost,
|
||||||
SessionContext sessionContext,
|
SessionContext sessionContext,
|
||||||
int startup_timeout_ms,
|
int timeout_ms) : base(sessionContext)
|
||||||
int shutdown_timeout_ms) : base(sessionContext)
|
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.processFactory = processFactory;
|
this.processFactory = processFactory;
|
||||||
this.proxyFactory = proxyFactory;
|
this.proxyFactory = proxyFactory;
|
||||||
this.runtimeHost = runtimeHost;
|
this.runtimeHost = runtimeHost;
|
||||||
this.startup_timeout_ms = startup_timeout_ms;
|
this.timeout_ms = timeout_ms;
|
||||||
this.shutdown_timeout_ms = shutdown_timeout_ms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
|
@ -119,7 +116,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
ClientProcess.Terminated += clientTerminatedEventHandler;
|
ClientProcess.Terminated += clientTerminatedEventHandler;
|
||||||
|
|
||||||
logger.Info("Waiting for client to complete initialization...");
|
logger.Info("Waiting for client to complete initialization...");
|
||||||
clientReady = clientReadyEvent.WaitOne(startup_timeout_ms);
|
clientReady = clientReadyEvent.WaitOne(timeout_ms);
|
||||||
|
|
||||||
runtimeHost.AllowConnection = false;
|
runtimeHost.AllowConnection = false;
|
||||||
runtimeHost.ClientReady -= clientReadyEventHandler;
|
runtimeHost.ClientReady -= clientReadyEventHandler;
|
||||||
|
@ -132,7 +129,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
|
|
||||||
if (!clientReady)
|
if (!clientReady)
|
||||||
{
|
{
|
||||||
logger.Error($"Failed to start client within {startup_timeout_ms / 1000} seconds!");
|
logger.Error($"Failed to start client within {timeout_ms / 1000} seconds!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientTerminated)
|
if (clientTerminated)
|
||||||
|
@ -200,19 +197,19 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
ClientProxy.Disconnect();
|
ClientProxy.Disconnect();
|
||||||
|
|
||||||
logger.Info("Waiting for client to disconnect from runtime communication host...");
|
logger.Info("Waiting for client to disconnect from runtime communication host...");
|
||||||
disconnected = disconnectedEvent.WaitOne(shutdown_timeout_ms);
|
disconnected = disconnectedEvent.WaitOne(timeout_ms / 2);
|
||||||
|
|
||||||
if (!disconnected)
|
if (!disconnected)
|
||||||
{
|
{
|
||||||
logger.Error($"Client failed to disconnect within {shutdown_timeout_ms / 1000} seconds!");
|
logger.Error($"Client failed to disconnect within {timeout_ms / 2 / 1000} seconds!");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("Waiting for client process to terminate...");
|
logger.Info("Waiting for client process to terminate...");
|
||||||
terminated = terminatedEvent.WaitOne(shutdown_timeout_ms);
|
terminated = terminatedEvent.WaitOne(timeout_ms / 2);
|
||||||
|
|
||||||
if (!terminated)
|
if (!terminated)
|
||||||
{
|
{
|
||||||
logger.Error($"Client failed to terminate within {shutdown_timeout_ms / 1000} seconds!");
|
logger.Error($"Client failed to terminate within {timeout_ms / 2 / 1000} seconds!");
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeHost.ClientDisconnected -= disconnectedEventHandler;
|
runtimeHost.ClientDisconnected -= disconnectedEventHandler;
|
||||||
|
|
|
@ -22,8 +22,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
IProxyFactory proxyFactory,
|
IProxyFactory proxyFactory,
|
||||||
IRuntimeHost runtimeHost,
|
IRuntimeHost runtimeHost,
|
||||||
SessionContext sessionContext,
|
SessionContext sessionContext,
|
||||||
int startup_timeout_ms,
|
int timeout_ms) : base(logger, processFactory, proxyFactory, runtimeHost, sessionContext, timeout_ms)
|
||||||
int shutdown_timeout_ms) : base(logger, processFactory, proxyFactory, runtimeHost, sessionContext, startup_timeout_ms, shutdown_timeout_ms)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue