orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Add IHostApplicationLifetime support

Open fuocor opened this issue 7 years ago • 2 comments

I think it would be a good idea to add IHostApplicationLifetime to TestCluster so that it can be monitored from outside rather than using the ILifecycleObservable startup tasks.

when testing a service fixture we can do the following before returning the client service provider to the test:

var t = Task.Run(() => testCluster.Deploy());
var lifetime = serverHost.ServiceProvider.GetService<IHostApplicationLifetime>();
if (lifetime != null)
{
    // This only happens once per fixture, so we can afford to wait a little bit on it.
    if (!lifetime.ApplicationStarted.WaitHandle.WaitOne(TimeSpan.FromSeconds(20)))
    {
        ///t probably faulted
        if (t.IsFaulted)
        {
            throw t.Exception.InnerException;
        }
        throw new TimeoutException(
            $"Timed out waiting for client application to start.{Environment.NewLine}Startup Logs:{Environment.NewLine}");
    }
}

fuocor avatar May 17 '19 18:05 fuocor

Hey I think ISiloHost itself has support for IApplicationLifetime, which provides similar functionality with IHostApplicationLifetime. You can get it from the host's ServiceProvider. TestCluster uses ISiloHost, so this is available to TestCluster hosts as well. Is that something you are looking for?

xiazen avatar May 23 '19 18:05 xiazen

close due to inactivity. feel free to reopen.

xiazen avatar Jul 12 '19 21:07 xiazen