Add IHostApplicationLifetime support
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}");
}
}
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?
close due to inactivity. feel free to reopen.