public void EverythingAsync() { const int MaxExecTime = 24 * 3600 * 1000; var stream = new MemoryStream(); var r = new Random(0); for (int i = 0; i < 10; i++) { int seed = r.Next(100 * 1000); HistoricPerfDataTable table = new HistoricPerfDataTable(LoggingContext); XAssert.IsTrue(table.Count == 0); var s = new Random(seed); var buffer = new byte[sizeof(long)]; for (int j = 0; j < 10; j++) { s.NextBytes(buffer); long semiStableHash = BitConverter.ToInt64(buffer, 0); var execTime = (uint)s.Next(MaxExecTime); var processPipExecutionPerformance = new ProcessPipExecutionPerformance( PipExecutionLevel.Executed, DateTime.UtcNow, DateTime.UtcNow.AddMilliseconds(execTime), FingerprintUtilities.ZeroFingerprint, TimeSpan.FromMilliseconds(execTime), default(FileMonitoringViolationCounters), default(IOCounters), TimeSpan.FromMilliseconds(execTime), TimeSpan.FromMilliseconds(execTime / 2), ProcessMemoryCounters.CreateFromMb(1024, 1024, 1024, 1024), 1, workerId: 0, suspendedDurationMs: 0); ProcessPipHistoricPerfData runTimeData = new ProcessPipHistoricPerfData(processPipExecutionPerformance, execTime); table[semiStableHash] = runTimeData; } XAssert.IsTrue(table.Count == 10); stream.Position = 0; table.Save(stream); stream.Position = 0; table = HistoricPerfDataTable.Load(LoggingContext, stream); XAssert.IsTrue(table.Count == 10); s = new Random(seed); for (int j = 0; j < 10; j++) { s.NextBytes(buffer); long semiStableHash = BitConverter.ToInt64(buffer, 0); XAssert.IsTrue(table[semiStableHash].ExeDurationInMs >= (uint)s.Next(MaxExecTime)); } } }
public TestScheduler( PipGraph graph, TestPipQueue pipQueue, PipExecutionContext context, FileContentTable fileContentTable, EngineCache cache, IConfiguration configuration, FileAccessWhitelist fileAccessWhitelist, DirectoryMembershipFingerprinterRuleSet directoryMembershipFingerprinterRules = null, ITempCleaner tempCleaner = null, HistoricPerfDataTable runningTimeTable = null, JournalState journalState = null, PerformanceCollector performanceCollector = null, string fingerprintSalt = null, PreserveOutputsInfo?previousInputsSalt = null, IEnumerable <Pip> successfulPips = null, IEnumerable <Pip> failedPips = null, LoggingContext loggingContext = null, IIpcProvider ipcProvider = null, DirectoryTranslator directoryTranslator = null, VmInitializer vmInitializer = null, SchedulerTestHooks testHooks = null) : base(graph, pipQueue, context, fileContentTable, cache, configuration, fileAccessWhitelist, loggingContext, null, directoryMembershipFingerprinterRules, tempCleaner, AsyncLazy <HistoricPerfDataTable> .FromResult(runningTimeTable), performanceCollector, fingerprintSalt, previousInputsSalt, ipcProvider: ipcProvider, directoryTranslator: directoryTranslator, journalState: journalState, vmInitializer: vmInitializer, testHooks: testHooks) { m_testPipQueue = pipQueue; if (successfulPips != null) { foreach (var pip in successfulPips) { Contract.Assume(pip.PipId.IsValid, "Override results must be added after the pip has been added to the scheduler"); m_overridePipResults.Add(pip.PipId, PipResultStatus.Succeeded); } } if (failedPips != null) { foreach (var pip in failedPips) { Contract.Assume(pip.PipId.IsValid, "Override results must be added after the pip has been added to the scheduler"); m_overridePipResults.Add(pip.PipId, PipResultStatus.Failed); } } m_loggingContext = loggingContext; }
public void TimeToLive() { int execTime = 1; uint runTime = 2; var processPipExecutionPerformance = new ProcessPipExecutionPerformance( PipExecutionLevel.Executed, DateTime.UtcNow, DateTime.UtcNow.AddMilliseconds(execTime), FingerprintUtilities.ZeroFingerprint, TimeSpan.FromMilliseconds(execTime), default(FileMonitoringViolationCounters), default(IOCounters), TimeSpan.FromMilliseconds(execTime), TimeSpan.FromMilliseconds(execTime / 2), ProcessMemoryCounters.CreateFromMb(1024, 1024, 1024, 1024), 1, workerId: 0, suspendedDurationMs: 0); ProcessPipHistoricPerfData runTimeData = new ProcessPipHistoricPerfData(processPipExecutionPerformance, runTime); HistoricPerfDataTable table = new HistoricPerfDataTable(LoggingContext); var semiStableHashToKeep = 0; table[semiStableHashToKeep] = runTimeData; var semiStableHashToDrop = 1; table[semiStableHashToDrop] = runTimeData; var stream = new MemoryStream(); for (int i = 0; i < ProcessPipHistoricPerfData.DefaultTimeToLive; i++) { stream.Position = 0; table.Save(stream); stream.Position = 0; table = HistoricPerfDataTable.Load(LoggingContext, stream); Analysis.IgnoreResult(table[semiStableHashToKeep]); } stream.Position = 0; table = HistoricPerfDataTable.Load(LoggingContext, stream); XAssert.AreEqual(1u, table[semiStableHashToKeep].ExeDurationInMs); XAssert.AreEqual(0u, table[semiStableHashToDrop].ExeDurationInMs); }