public void TraceWithMultipleStartupAndShutdown() { var memoryClock = new MemoryClock(); var logger = TestGlobal.Logger; var context = new Context(logger); var process1StartupTime = memoryClock.UtcNow; memoryClock.AddSeconds(10); using var testDirectory = new DisposableDirectory(_fileSystem); LifetimeTracker.ServiceStarting(context, serviceRunningLogInterval: TimeSpan.FromMinutes(10), testDirectory.Path, memoryClock, process1StartupTime); memoryClock.AddSeconds(10); LifetimeTracker.ServiceStarted(context, memoryClock); memoryClock.AddSeconds(10); LifetimeTracker.ServiceReadyToProcessRequests(context); // Offline time should be unavailable. GetFullOutput().Should().Contain(UnavailableOfflineTime); LifetimeTracker.ServiceStopped(context, BoolResult.Success); // Now we're running the same stuff the second time, like after the process restart. memoryClock.AddSeconds(300); var process2StartupTime = memoryClock.UtcNow; memoryClock.AddSeconds(10); LifetimeTracker.ServiceStarting(context, serviceRunningLogInterval: TimeSpan.FromMinutes(10), testDirectory.Path, memoryClock, process2StartupTime); GetFullOutput().Should().Contain("LastHeartBeatTime"); memoryClock.AddSeconds(10); LifetimeTracker.ServiceStarted(context, memoryClock); memoryClock.AddSeconds(10); LifetimeTracker.ServiceReadyToProcessRequests(context); GetFullOutput().Should().Contain("OfflineTime=[00:05:50"); }
public void ReadyBeforeStartup() { var logger = TestGlobal.Logger; var context = new Context(logger); using var testDirectory = new DisposableDirectory(_fileSystem); try { LifetimeTracker.ServiceStarting(context, serviceRunningLogInterval: TimeSpan.FromMinutes(10), testDirectory.Path); LifetimeTracker.ServiceReadyToProcessRequests(context); GetFullOutput().Should().NotContain(FullyInitializedMessage); LifetimeTracker.ServiceStarted(context); var output = GetFullOutput(); output.Should().Contain(FullyInitializedMessage); output.Should().Contain(UnavailableOfflineTime); } finally { LifetimeTracker.ServiceStopped(context, BoolResult.Success); } }
private static void ReportServiceStopped(Context context, IDistributedCacheServiceHost host, BoolResult result) { CacheActivityTracker.Stop(); LifetimeTracker.ServiceStopped(context, result); host.OnTeardownCompleted(); }