use of de.dagere.peass.dependency.analysis.CalledMethodLoader in project peass by DaGeRe.
the class TestTraceMethodReader method testTraceLengthSimpleFor.
@Test
public void testTraceLengthSimpleFor() throws ParseException, IOException {
System.out.println("Searching: " + SLF4J_API_JAR + " " + new File(SLF4J_API_JAR).exists());
System.out.println("Searching: " + SLF4J_IMPL_JAR + " " + new File(SLF4J_IMPL_JAR).exists());
String jarPath = getJarPath();
String agentPath = getAgentPath();
final ProcessBuilder builder = new ProcessBuilder("java", "-javaagent:" + agentPath, "-Dorg.aspectj.weaver.loadtime.configuration=file:src" + File.separator + "test" + File.separator + "resources" + File.separator + "aop.xml", "-cp", jarPath, "de.peass.example.CallerSimpleFor");
System.out.println("Command: " + builder.command());
final Process process = builder.start();
StreamGobbler.showFullProcess(process);
final File[] kiekerFolders = tmpFolder.listFiles((FileFilter) new WildcardFileFilter("kieker-*"));
final File traceFolder = kiekerFolders[0];
//
final TraceMethodReader reader = new TraceMethodReader(new CalledMethodLoader(traceFolder, ModuleClassMapping.SINGLE_MODULE_MAPPING, new KiekerConfig()).getShortTrace(""), new File("src" + File.separator + "test" + File.separator + "java"));
final TraceWithMethods trace = reader.getTraceWithMethods();
System.out.println(trace.getWholeTrace());
/*
* Trace: 20 Methodenaufrufe -> 10 sonstige -> 10 mal Schleife callMe2 -> müsste auf 1 Eintrag (callMe2, *10 Aufrufe) zusammenfasst werden -> Ziel: 11 Aufrufe
*/
Assert.assertEquals(11, trace.getLength());
}
use of de.dagere.peass.dependency.analysis.CalledMethodLoader in project peass by DaGeRe.
the class TraceGettingIT method executeReading.
public static void executeReading(final TestCase testcase, final File clazzDir, final Map<String, List<File>> traceFileMap, final String githash, final File kiekerResultFolder) throws ParseException, IOException {
final ArrayList<TraceElement> shortTrace = new CalledMethodLoader(kiekerResultFolder, ModuleClassMapping.SINGLE_MODULE_MAPPING, new KiekerConfig()).getShortTrace("");
LOG.debug("Short Trace: {}", shortTrace.size());
final TraceMethodReader traceMethodReader = new TraceMethodReader(shortTrace, new File(TestConstants.CURRENT_FOLDER, "src/main/java"), new File(TestConstants.CURRENT_FOLDER, "src/java"), new File(TestConstants.CURRENT_FOLDER, "src/test/java"), new File(TestConstants.CURRENT_FOLDER, "src/test"));
final TraceWithMethods trace = traceMethodReader.getTraceWithMethods();
List<File> traceFile = traceFileMap.get(testcase.getMethod());
if (traceFile == null) {
traceFile = new LinkedList<>();
traceFileMap.put(testcase.getMethod(), traceFile);
}
if (!clazzDir.exists()) {
clazzDir.mkdirs();
}
final File currentTraceFile = new File(clazzDir, testcase.getMethod() + "_hash_" + githash);
traceFile.add(currentTraceFile);
try (final FileWriter fw = new FileWriter(currentTraceFile)) {
fw.write(trace.getWholeTrace());
}
final File methodTrace = new File(clazzDir, testcase.getMethod() + "_hash_" + githash + "_method");
try (final FileWriter fw = new FileWriter(methodTrace)) {
LOG.debug("Methoden: " + trace.getTraceMethods().length());
fw.write(trace.getTraceMethods());
}
}
use of de.dagere.peass.dependency.analysis.CalledMethodLoader in project peass by DaGeRe.
the class OneTraceGenerator method generateTraceFiles.
private boolean generateTraceFiles(final String versionCurrent, final File[] kiekerResultFolders) throws FileNotFoundException, IOException, XmlPullParserException, com.github.javaparser.ParseException {
boolean success = false;
TraceWithMethods trace = null;
TraceMethodReader traceMethodReader = null;
int overallSizeInMb = 0;
for (File kiekerResultFolder : kiekerResultFolders) {
final long size = FileUtils.sizeOfDirectory(kiekerResultFolder);
final long sizeInMB = size / (1024 * 1024);
overallSizeInMb += sizeInMB;
LOG.debug("Filesize: {} ({})", sizeInMB, size);
if (sizeInMB < kiekerConfig.getTraceSizeInMb()) {
CalledMethodLoader calledMethodLoader = new CalledMethodLoader(kiekerResultFolder, moduleClassMapping, kiekerConfig);
final List<TraceElement> shortTrace = calledMethodLoader.getShortTrace("");
if (shortTrace != null) {
LOG.debug("Short Trace: {} Folder: {} Project: {}", shortTrace.size(), kiekerResultFolder.getAbsolutePath(), folders.getProjectFolder());
if (shortTrace.size() > 0) {
traceMethodReader = new TraceMethodReader(shortTrace, classpathFolders.toArray(new File[0]));
if (trace == null) {
trace = traceMethodReader.getTraceWithMethods();
} else {
TraceWithMethods additionalTrace = traceMethodReader.getTraceWithMethods();
trace.append(additionalTrace);
}
success = true;
} else {
LOG.error("Trace empty!");
}
}
} else {
LOG.error("File size exceeds {} MB", kiekerConfig.getTraceSizeInMb());
}
}
if (success) {
writeTrace(versionCurrent, overallSizeInMb, traceMethodReader, trace);
}
return success;
}
use of de.dagere.peass.dependency.analysis.CalledMethodLoader in project peass by DaGeRe.
the class DependencyManager method getCalledMethods.
private Map<ChangedEntity, Set<String>> getCalledMethods(final ModuleClassMapping mapping, final File[] kiekerResultFolders) {
final Map<ChangedEntity, Set<String>> allCalledClasses = new LinkedHashMap<ChangedEntity, Set<String>>();
for (File kiekerResultFolder : kiekerResultFolders) {
final long size = FileUtils.sizeOfDirectory(kiekerResultFolder);
final long sizeInMB = size / (1024 * 1024);
LOG.debug("Size: {} Folder: {}", sizeInMB, kiekerResultFolder);
if (sizeInMB > fakeConfig.getKiekerConfig().getTraceSizeInMb()) {
LOG.error("Trace too big!");
} else {
LOG.debug("Reading Kieker folder: {}", kiekerResultFolder.getAbsolutePath());
CalledMethodLoader calledMethodLoader = new CalledMethodLoader(kiekerResultFolder, mapping, fakeConfig.getKiekerConfig());
final Map<ChangedEntity, Set<String>> calledMethods = calledMethodLoader.getCalledMethods();
for (Map.Entry<ChangedEntity, Set<String>> calledMethod : calledMethods.entrySet()) {
if (!allCalledClasses.containsKey(calledMethod.getKey())) {
allCalledClasses.put(calledMethod.getKey(), calledMethod.getValue());
} else {
Set<String> alreadyKnownCalledClasses = allCalledClasses.get(calledMethod.getKey());
alreadyKnownCalledClasses.addAll(calledMethod.getValue());
}
}
}
}
return allCalledClasses;
}
use of de.dagere.peass.dependency.analysis.CalledMethodLoader in project peass by DaGeRe.
the class TraceGeneratorStarter method writeTestcase.
private void writeTestcase(final String newestVersion, final PeassFolders folders, final KiekerResultManager resultsManager, final TestCase testcase) throws FileNotFoundException, IOException, XmlPullParserException, ViewNotFoundException {
final File moduleResultFolder = KiekerFolderUtil.getModuleResultFolder(folders, testcase);
final File kiekerResultFolder = KiekerFolderUtil.getClazzMethodFolder(testcase, moduleResultFolder)[0];
final long size = FileUtils.sizeOfDirectory(kiekerResultFolder);
final long sizeInMB = size / (1024 * 1024);
if (sizeInMB < 100) {
LOG.debug("Writing " + testcase);
final List<TraceElement> shortTrace = new CalledMethodLoader(kiekerResultFolder, mapping, new KiekerConfig()).getShortTrace("");
writeTrace(newestVersion, testcase, shortTrace);
} else {
LOG.info("Not writing " + testcase + " since size is " + sizeInMB + " mb");
}
}
Aggregations