コード例 #1
0
ファイル: SmokeTests.cs プロジェクト: MatthewMWR/MeasureTrace
        public void BasicCalipersRunningTest(string relativePath)
        {
            var expectedCompletionSeconds = 45;
            var expectedCompletionTime = DateTime.UtcNow.AddSeconds(expectedCompletionSeconds);
            var sourcePath = Path.Combine(Environment.CurrentDirectory, relativePath);
            var destPath = Path.Combine(Path.GetTempPath(), nameof(BasicCalipersRunningTest) + ".zip");
            File.Copy(sourcePath, destPath, true);
            using (var tj = new TraceJob(destPath))
            {
                tj.StageForProcessing();
                tj.RegisterCaliperByType<CpuSampled>(null);
                tj.RegisterCaliperByType<BootPhase>();
                tj.RegisterProcessorByType<WinlogonSubscriberProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                tj.RegisterProcessorByType<GroupPolicyActionProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                tj.RegisterProcessorByType<DiskIoProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                tj.RegisterProcessorByType<NetworkInterfaceProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                tj.RegisterProcessorByType<ProcessLifetimeProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                //tj.RegisterProcessorByType<BootPhaseProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                tj.RegisterProcessorByType<SystemSleepProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                tj.RegisterProcessorByType<ServiceTransitionProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                tj.RegisterProcessorByType<NetworkInterfaceProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                tj.RegisterProcessorByType<DiskProcessor>(ProcessorTypeCollisionOption.UseExistingIfFound);
                var t = tj.Measure();
                Assert.NotNull(t);
                Assert.True(expectedCompletionTime > DateTime.UtcNow);
                Assert.NotEmpty(t.GetMeasurements<IMeasurement>());
                Assert.NotEmpty(t.GetMeasurements<WinlogonSubscriberTask>());
                Assert.NotEmpty(t.GetMeasurements<GroupPolicyAction>());
                Assert.NotEmpty(t.GetMeasurements<DiskIo>());
                Assert.NotEmpty(t.GetMeasurements<MeasureTrace.TraceModel.CpuSampled>());
                Assert.NotEmpty(t.GetMeasurements<ProcessLifetime>());
                Assert.NotEmpty(t.GetMeasurements<MeasureTrace.TraceModel.BootPhase>());
                Assert.NotEmpty(t.GetMeasurements<ServiceTransition>());
                Assert.NotEmpty(t.GetMeasurements<TerminalSession>());
                Assert.NotEmpty(t.GetMeasurements<NetworkInterface>());
                Assert.NotEmpty(t.GetMeasurements<PhysicalDisk>());
                Assert.NotEmpty(t.GetMeasurements<LogicalDisk>());
                Assert.False(t.GetMeasurements<SystemSleep>().Any());
                Assert.True(string.Equals(t.PackageFileNameFull, destPath, StringComparison.OrdinalIgnoreCase));
                var packageRelName = Path.GetFileName(destPath);
                Assert.True(string.Equals(t.PackageFileNameFull, destPath, StringComparison.OrdinalIgnoreCase));
                Assert.True(string.Equals(Path.GetFileName(t.PackageFileNameFull), packageRelName, StringComparison.OrdinalIgnoreCase));

            }
        }
コード例 #2
0
 public void CpuSampledCaliperTest(string relativePath)
 {
     var sourcePath = Path.Combine(Environment.CurrentDirectory, relativePath);
     var destPath = Path.Combine(Path.GetTempPath(), nameof(CpuSampledCaliperTest) + ".zip");
     File.Copy(sourcePath, destPath, true);
     using (var tj = new TraceJob(destPath))
     {
         tj.RegisterCaliperByType<CpuSampled>(null);
         var t = tj.Measure();
         Assert.NotNull(t);
         Assert.True(
             t.GetMeasurements<MeasureTrace.TraceModel.CpuSampled>().OrderBy(m => m.Weight).Last().ProcessName ==
             "mscorsvw");
         Assert.True(
             t.GetMeasurements<MeasureTrace.TraceModel.CpuSampled>()
                 .Where(q => q.ProcessName == "MonitoringHost" && q.Weight > 0.03)
                 .Any());
     }
 }