public void TestFailingPipDump(bool failPip)
        {
            BaseSetup();

            FileArtifact sourceArtifact      = failPip ? FileArtifact.CreateSourceFile(CreateUniqueSourcePath(SourceRootPrefix)) : CreateSourceFile();
            FileArtifact destinationArtifact = CreateOutputFileArtifact();
            var          copyFile            = CreateCopyFile(sourceArtifact, destinationArtifact);

            PipGraphBuilder.AddCopyFile(copyFile);

            var schedulerResult = RunScheduler();

            var logFolder   = Path.Combine(schedulerResult.Config.Logging.LogsDirectory.ToString(Context.PathTable), "FailedPips");
            var pipDumpFile = Path.Combine(logFolder, $"{copyFile.FormattedSemiStableHash}.json");

            if (failPip)
            {
                schedulerResult.AssertFailure();
                SetExpectedFailures(1, 0); // One error logged for the failing pip
                AssertErrorCount();

                Assert.True(Directory.Exists(logFolder));
                Assert.True(File.Exists(pipDumpFile));
                Assert.True(new FileInfo(pipDumpFile).Length > 0); //Ensure that some content was written to the file
            }
            else
            {
                schedulerResult.AssertSuccess();
                // FailedPips log folder should not have been created when we run successfully
                Assert.False(Directory.Exists(logFolder));
                Assert.False(File.Exists(pipDumpFile));
            }
        }
Exemplo n.º 2
0
        public void TestDumpPipLiteWithPassingAndFailingPips()
        {
            var passingCopyFile = new CopyFile(CreateSourceFile(), CreateOutputFileArtifact(), new List <StringId>().ToReadOnlyArray(), PipProvenance.CreateDummy(Context));
            var failingCopyFile = new CopyFile(FileArtifact.CreateSourceFile(CreateUniqueSourcePath(SourceRootPrefix)), CreateOutputFileArtifact(), new List <StringId>().ToReadOnlyArray(), PipProvenance.CreateDummy(Context));

            PipGraphBuilder.AddCopyFile(passingCopyFile);
            PipGraphBuilder.AddCopyFile(failingCopyFile);

            var schedulerResult = RunScheduler().AssertFailure();

            var logFolder          = Path.Combine(schedulerResult.Config.Logging.LogsDirectory.ToString(Context.PathTable), "FailedPips");
            var failingPipDumpFile = Path.Combine(logFolder, $"{failingCopyFile.FormattedSemiStableHash}.json");
            var passingPipDumpFile = Path.Combine(logFolder, $"{passingCopyFile.FormattedSemiStableHash}.json");


            List <Option> options = new List <Option>
            {
                new Option()
                {
                    Name = "d+"
                }
            };

            RunAnalyzer(schedulerResult, null, options);

            Assert.True(Directory.Exists(logFolder));
            Assert.True(File.Exists(failingPipDumpFile));
            Assert.True(!File.Exists(passingPipDumpFile));
        }
Exemplo n.º 3
0
        public void TestDumpPipLite()
        {
            var copyFile = new CopyFile(CreateSourceFile(), CreateOutputFileArtifact(), new List <StringId>().ToReadOnlyArray(), PipProvenance.CreateDummy(Context));

            PipGraphBuilder.AddCopyFile(copyFile);

            var schedulerResult = RunScheduler().AssertSuccess();

            var logFolder   = Path.Combine(schedulerResult.Config.Logging.LogsDirectory.ToString(Context.PathTable), "FailedPips");
            var pipDumpFile = Path.Combine(logFolder, $"{copyFile.FormattedSemiStableHash}.json");

            List <Option> options = new List <Option>
            {
                new Option()
                {
                    Name  = "o",
                    Value = schedulerResult.Config.Logging.LogsDirectory.ToString(Context.PathTable)
                },
                new Option()
                {
                    Name  = "p",
                    Value = copyFile.FormattedSemiStableHash
                }
            };

            RunAnalyzer(schedulerResult, null, options);

            Assert.True(Directory.Exists(logFolder));
            Assert.True(File.Exists(pipDumpFile));
        }
        public void TestCopyFileDump()
        {
            var sourceArtifact      = FileArtifact.CreateSourceFile(AbsolutePath.Create(Context.PathTable, GetFullPath("source")));
            var destinationArtifact = FileArtifact.CreateSourceFile(AbsolutePath.Create(Context.PathTable, GetFullPath("destination")));

            CopyFile pip = CreateCopyFile(sourceArtifact, destinationArtifact);

            PipGraphBuilder.AddCopyFile(pip);

            RunAndAssertDumpPip(pip);
        }
        public void TestLogLimit()
        {
            var failingCopyFile1 = new CopyFile(FileArtifact.CreateSourceFile(CreateUniqueSourcePath(SourceRootPrefix)), CreateOutputFileArtifact(), ReadOnlyArray <StringId> .Empty, PipProvenance.CreateDummy(Context));
            var failingCopyFile2 = new CopyFile(FileArtifact.CreateSourceFile(CreateUniqueSourcePath(SourceRootPrefix)), CreateOutputFileArtifact(), ReadOnlyArray <StringId> .Empty, PipProvenance.CreateDummy(Context));

            PipGraphBuilder.AddCopyFile(failingCopyFile1);
            PipGraphBuilder.AddCopyFile(failingCopyFile2);

            Configuration.Logging.DumpFailedPipsLogLimit = 1;

            var schedulerResult = RunScheduler().AssertFailure();

            var logFolder = Path.Combine(schedulerResult.Config.Logging.LogsDirectory.ToString(Context.PathTable), "FailedPips");

            SetExpectedFailures(2, 0);
            AssertErrorCount();
            AssertVerboseEventLogged(LogEventId.RuntimeDumpPipLiteLogLimitReached, count: 1);
            Assert.True(Directory.GetFiles(logFolder).Length == 1);
        }
        public void TestPassingAndFailingPips()
        {
            var existantCopyFileSrc  = CreateSourceFile();
            var existantCopyFileDest = CreateOutputFileArtifact();

            File.WriteAllText(existantCopyFileSrc.Path.ToString(Context.PathTable), "copy file test");

            var failingCopyFile = new CopyFile(FileArtifact.CreateSourceFile(CreateUniqueSourcePath(SourceRootPrefix)), CreateOutputFileArtifact(), ReadOnlyArray <StringId> .Empty, PipProvenance.CreateDummy(Context));
            var passingCopyFile = CreateCopyFile(existantCopyFileSrc, existantCopyFileDest);

            PipGraphBuilder.AddCopyFile(failingCopyFile);
            PipGraphBuilder.AddCopyFile(passingCopyFile);

            var schedulerResult = RunScheduler().AssertFailure();
            var logFolder       = Path.Combine(schedulerResult.Config.Logging.LogsDirectory.ToString(Context.PathTable), "FailedPips");
            var failingLogFile  = Path.Combine(logFolder, $"{failingCopyFile.FormattedSemiStableHash}.json");
            var passingLogFile  = Path.Combine(logFolder, $"{passingCopyFile.FormattedSemiStableHash}.json");

            SetExpectedFailures(1, 0); // One error logged for the failing pip
            AssertErrorCount();

            Assert.True(File.Exists(failingLogFile));
            Assert.False(File.Exists(passingLogFile));
        }