public void DBEventCountVerification() { Configuration.Logging.LogExecution = true; var fileOne = FileArtifact.CreateOutputFile(Combine(TestDirPath, "foo.txt")); var fileTwo = FileArtifact.CreateOutputFile(Combine(TestDirPath, "bar.txt")); var dirOne = Path.Combine(ReadonlyRoot, "baz"); Directory.CreateDirectory(dirOne); File.WriteAllText(Path.Combine(dirOne, "abc.txt"), "text"); File.WriteAllText(Path.Combine(dirOne, "xyz.txt"), "text12"); var pipA = CreateAndSchedulePipBuilder(new[] { Operation.WriteFile(fileOne), }).Process; var pipB = CreateAndSchedulePipBuilder(new[] { Operation.WriteFile(fileTwo), }).Process; var pipC = CreateAndSchedulePipBuilder(new[] { Operation.ReadFile(fileOne), Operation.WriteFile(CreateOutputFileArtifact()) }).Process; var pipD = CreateAndSchedulePipBuilder(new[] { Operation.EnumerateDir(new DirectoryArtifact(AbsolutePath.Create(Context.PathTable, dirOne), 0, false)), Operation.WriteFile(CreateOutputFileArtifact()) }).Process; var buildA = RunScheduler().AssertSuccess(); var analyzerRes = RunAnalyzer(buildA).AssertSuccess(); var dataStore = new XldbDataStore(storeDirectory: OutputDirPath.ToString(Context.PathTable)); // As per Mike's offline comment, non-zero vs zero event count tests for now until we can rent out some mac machines // and figure out the true reason why the windows and mac event log counts differ by so much // For these tests, there should be a non-zero number of events logged XAssert.AreNotEqual(0, dataStore.GetFileArtifactContentDecidedEvents().Count()); XAssert.AreNotEqual(0, dataStore.GetPipExecutionPerformanceEvents().Count()); XAssert.AreNotEqual(0, dataStore.GetDirectoryMembershipHashedEvents().Count()); XAssert.AreNotEqual(0, dataStore.GetProcessExecutionMonitoringReportedEvents().Count()); XAssert.AreNotEqual(0, dataStore.GetProcessFingerprintComputationEvents().Count()); XAssert.AreNotEqual(0, dataStore.GetBuildSessionConfigurationEvents().Count()); XAssert.AreNotEqual(0, dataStore.GetPipExecutionStepPerformanceReportedEvents().Count()); XAssert.AreNotEqual(0, dataStore.GetPipCacheMissEvents().Count()); XAssert.AreNotEqual(0, dataStore.GetStatusReportedEvents().Count()); XAssert.AreNotEqual(0, dataStore.GetBxlInvocationEvents().Count()); // For these tests, there should be no events logged XAssert.AreEqual(0, dataStore.GetPipExecutionDirectoryOutputsEvents().Count()); XAssert.AreEqual(0, dataStore.GetWorkerListEvents().Count()); XAssert.AreEqual(0, dataStore.GetDependencyViolationReportedEvents().Count()); }
public XLGToDBAnalyzerTests(ITestOutputHelper output) : base(output) { AnalysisMode = AnalysisMode.XlgToDb; OutputDirPath = Combine(AbsolutePath.Create(Context.PathTable, TemporaryDirectory), "XlgToDb"); TestDirPath = Combine(AbsolutePath.Create(Context.PathTable, TemporaryDirectory), "XlgToDbTest"); ModeSpecificDefaultArgs = new Option[] { new Option { Name = "outputDir", Value = OutputDirPath.ToString(Context.PathTable) } }; }
public XLGToDBAnalyzerTests(ITestOutputHelper output) : base(output) { AnalysisMode = AnalysisMode.XlgToDb; var uniqueDirPath = Guid.NewGuid().ToString(); OutputDirPath = Combine(AbsolutePath.Create(Context.PathTable, ObjectRoot), "XlgToDb-", uniqueDirPath); TestDirPath = Combine(AbsolutePath.Create(Context.PathTable, SourceRoot), "XlgToDbTest"); ModeSpecificDefaultArgs = new Option[] { new Option { Name = "outputDir", Value = OutputDirPath.ToString(Context.PathTable) } }; }
public void DBCreatedAndPopulated() { Configuration.Logging.LogExecution = true; var file = FileArtifact.CreateOutputFile(Combine(TestDirPath, "blah.txt")); var pipA = CreateAndSchedulePipBuilder(new[] { Operation.WriteFile(file), }).Process; var pipB = CreateAndSchedulePipBuilder(new[] { Operation.ReadFile(file), Operation.WriteFile(CreateOutputFileArtifact()) }).Process; var buildA = RunScheduler().AssertSuccess(); var analyzerRes = RunAnalyzer(buildA).AssertSuccess(); XAssert.AreNotEqual(Directory.GetFiles(OutputDirPath.ToString(Context.PathTable), "*.sst").Length, 0); }
protected override void Execute(CodeActivityContext context) { Result.Set(context, "Not Masked"); string inputFilePath = InputFilePath.Get(context); string outputDirPath = OutputDirPath.Get(context); string maskingKeyWord = MaskingKeyWord.Get(context); string occurrenceValue = Occurrence.Get(context); bool maskOnlyKeyword = MaskOnlyKeyword.Get(context); if (!string.IsNullOrEmpty(inputFilePath) && !string.IsNullOrEmpty(outputDirPath) && !string.IsNullOrEmpty(maskingKeyWord) && maskingKeyWord.IndexOf(" ") < 0 && !string.IsNullOrEmpty(occurrenceValue) && File.Exists(inputFilePath) && Directory.Exists(outputDirPath)) { string redactedPDFNameEscaped = Regex.Replace(Path.GetFileName(inputFilePath), "%", "%%"); string redactedPDFPath = $@"{outputDirPath}\{redactedPDFNameEscaped}"; string jpgFilesDir = ConvertPDFToJPGs(inputFilePath); if (maskOnlyKeyword) { if (!string.IsNullOrEmpty(occurrenceValue) && occurrenceValue.Equals("ALL", StringComparison.OrdinalIgnoreCase)) { int occurrence = 0; var redactedJPGFiles = RedactOnlyKeyword(jpgFilesDir, maskingKeyWord, occurrence, maskOnlyKeyword); if (maskingSuccessfull) { ConvertJPGsToPDF(redactedJPGFiles, redactedPDFPath); Result.Set(context, "Success"); } } else if (!string.IsNullOrEmpty(occurrenceValue)) { if (IsDigitsOnly(occurrenceValue)) { int occurrence = Convert.ToInt32(occurrenceValue); var redactedJPGFiles = RedactOnlyKeyword(jpgFilesDir, maskingKeyWord, occurrence, maskOnlyKeyword); if (maskingSuccessfull) { ConvertJPGsToPDF(redactedJPGFiles, redactedPDFPath); Result.Set(context, "Success"); } } else { throw new Exception("Occurrence should contain only digits."); } } } else if (!string.IsNullOrEmpty(occurrenceValue)) { if (IsDigitsOnly(occurrenceValue)) { int occurrence = Convert.ToInt32(occurrenceValue); var redactedJPGFiles = RedactTextTillEnd(jpgFilesDir, maskingKeyWord, occurrence, maskOnlyKeyword); if (maskingSuccessfull) { ConvertJPGsToPDF(redactedJPGFiles, redactedPDFPath); Result.Set(context, "Success"); } } else { throw new Exception("Occurrence should contain only digits."); } } Directory.Delete(jpgFilesDir, recursive: true); } else { if (!string.IsNullOrEmpty(inputFilePath) && File.Exists(inputFilePath)) { throw new Exception("Input File Path is not correct."); } else if (!string.IsNullOrEmpty(outputDirPath) && Directory.Exists(outputDirPath)) { throw new Exception("Directory Path is not correct."); } else if (!string.IsNullOrEmpty(maskingKeyWord) && maskingKeyWord.IndexOf(" ") < 0) { throw new Exception("Masking Keyword is not correct."); } else if (!string.IsNullOrEmpty(occurrenceValue)) { throw new Exception("Occurrence Value should not be null."); } } }