Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ca08167
add sjsw dependency
terahidro2003 Jan 25, 2025
e672fe3
add javaAgent arg to test execution methods
terahidro2003 Jan 25, 2025
bd5d71b
Prepare SJSW config in SamplingCauseSearcher
terahidro2003 Jan 25, 2025
c89ff8d
Config runOnce for sampling
terahidro2003 Jan 25, 2025
09f8519
Add sjsw snapshot version
terahidro2003 Jan 25, 2025
b5ea630
Don't instrument tests
terahidro2003 Jan 25, 2025
b451164
Add break statement
terahidro2003 Jan 25, 2025
0750cc1
Don't instrument tests when on SAMPLING rca strategy
terahidro2003 Jan 25, 2025
d1f2def
Add timeout=0 problem workaround
terahidro2003 Jan 25, 2025
9d26e66
Add minimal logging
terahidro2003 Jan 25, 2025
390099d
Wrap java-agent into mvn argument -DargLine=
terahidro2003 Jan 25, 2025
3bd2788
Fix timeout issues
terahidro2003 Jan 26, 2025
9e952f7
Introduce SJSW tree converter utility
terahidro2003 Jan 26, 2025
3b1f280
Increase SJSW snapshot version
terahidro2003 Jan 26, 2025
8ac148a
Parse profiler results and produce CallTreeNode's
terahidro2003 Jan 26, 2025
5c30824
Add fallback mechanism in case statistic is not created
terahidro2003 Jan 26, 2025
1ac1ab3
Allow different call format
terahidro2003 Jan 26, 2025
321f37f
Attempt to perform RCA on sampling results
terahidro2003 Jan 26, 2025
6eba09f
Change SJSW release version
terahidro2003 Jan 26, 2025
37050ff
Disable failed tests (for now)
terahidro2003 Jan 26, 2025
cb2fde3
Test shortening should always take place
DaGeRe Jan 26, 2025
40852c3
Prepare shortening before test execution
DaGeRe Jan 27, 2025
952d191
Use RCA log folder
DaGeRe Jan 27, 2025
451871c
Supply normalized method name to SJSW filter
terahidro2003 Jan 28, 2025
bd2e59c
Read SJSW results from RCA folder
terahidro2003 Jan 28, 2025
52f1974
Disable Kieker on SAMPLING strategy
terahidro2003 Jan 28, 2025
3c9d540
Prepare conversion of sampling to call tree nodes
DaGeRe Jan 28, 2025
4acadbe
vmnodes list is not necessary, fix names
DaGeRe Jan 28, 2025
a99ddfc
Fix typo
DaGeRe Jan 28, 2025
8c9a933
Create dual CallTreeNode tree
terahidro2003 Jan 29, 2025
f8ff7a4
Unit test for CallTreeNode creation
terahidro2003 Jan 29, 2025
4cce1c0
Fix measurements not added to last level bug
terahidro2003 Jan 29, 2025
9e9c803
Add probably proper kieker pattern to tree
terahidro2003 Jan 29, 2025
27efbd6
Add more tests
terahidro2003 Jan 29, 2025
025cd04
Update SJSW snapshot
terahidro2003 Jan 29, 2025
15b6ec3
Add method signature parsing method
terahidro2003 Jan 29, 2025
b308e8e
Add debug methods
terahidro2003 Jan 29, 2025
270419c
Fix CallTreeNode behavior
DaGeRe Jan 30, 2025
18b78f7
Also fix last test
DaGeRe Jan 30, 2025
5f8b037
Fix for missing data
DaGeRe Jan 30, 2025
cf8afbb
Disable kieker on analysis phase
terahidro2003 Feb 3, 2025
6b0eacd
Getter for the whole node data
terahidro2003 Feb 5, 2025
2379943
[REVIEW] Set stats bi-directionally for ADDED nodes
terahidro2003 Feb 5, 2025
2fba6d7
Update SJSW version
terahidro2003 Feb 5, 2025
201eef1
Add additional logging
terahidro2003 Feb 5, 2025
e8ca52d
Not only first node can be a constructor
terahidro2003 Feb 5, 2025
9bbb492
Add measurements to both trees of both commits
terahidro2003 Feb 5, 2025
cb2f284
Remove tree printing method
terahidro2003 Feb 5, 2025
0d061da
Test includes a constructor method (to check for empty measurements)
terahidro2003 Feb 5, 2025
028c13e
Remove unnecessary log output
DaGeRe Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ public void executeTest(final TestMethodCall test, final File logFolder, final l
cleanAboveSize(logFolder, "txt");
}

@Override
public void executeTest(String javaAgent, final TestMethodCall test, final File logFolder, final long timeout) {
throw new RuntimeException("Functionality regarding running tests with javaagent on Gradle is not currently supported.");
}

/**
* Runs the given test and saves the results to the result folder.
*
* @param specialResultFolder Folder for saving the results
* @param testname Name of the test that should be run
*/
@Override
protected void runTest(String javaAgent, final File moduleFolder, final File methodLogFile, TestMethodCall test, final String testname, final long timeout) {
throw new RuntimeException("Functionality regarding running tests with javaagent on Gradle is not currently supported.");
}

/**
* Runs the given test and saves the results to the result folder.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,46 @@ public void executeTest(final TestMethodCall test, final File logFolder, final l
cleanAboveSize(logFolder, "txt");
}

@Override
public void executeTest(final String javaAgent, final TestMethodCall test, final File logFolder, final long timeout) {
final File moduleFolder = new File(folders.getProjectFolder(), test.getModule());
runMethod(logFolder, test, moduleFolder, timeout, javaAgent);

cleanAboveSize(logFolder, "txt");
}

/**
* Runs the given test and saves the results to the result folder.
*
* @param specialResultFolder Folder for saving the results
* @param testname Name of the test that should be run
*/
@Override
protected void runTest(final File module, final File logFile, TestMethodCall test, final String testname, final long timeout) {
protected void runTest(final String javaAgent, final File module, final File logFile, TestMethodCall test, final String testname, final long timeout) {
try {
final Process process = buildMavenProcess(logFile, test, "-Dtest=" + testname);
final Process process = buildMavenProcess(logFile, test, "-Dtest=" + testname, javaAgent);
execute(testname, timeout, process);
} catch (final InterruptedException | IOException e) {
e.printStackTrace();
}
}

/**
* Runs the given test and saves the results to the result folder.
*
* @param specialResultFolder Folder for saving the results
* @param testname Name of the test that should be run
*/
@Override
protected void runTest(final File module, final File logFile, TestMethodCall test, final String testname, final long timeout) {
try {
final Process process = buildMavenProcess(logFile, test, "-Dtest=" + testname);
execute(testname, timeout, process);
} catch (final InterruptedException | IOException e) {
e.printStackTrace();
}
}

@Override
public boolean doesBuildfileExist() {
File pomFile = new File(folders.getProjectFolder(), "pom.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ protected String getTestGoal() {
}

protected abstract void runTest(File moduleFolder, final File logFile, TestMethodCall test, final String testname, final long timeout);

protected abstract void runTest(String javaAgent, File moduleFolder, final File logFile, TestMethodCall test, final String testname, final long timeout);

protected void runMethod(final File logFolder, final TestMethodCall test, final File moduleFolder, final long timeout) {
runMethod(logFolder, test, moduleFolder, timeout, null);
}

protected void runMethod(final File logFolder, final TestMethodCall test, final File moduleFolder, final long timeout, String javaAgent) {
try (final JUnitTestShortener shortener = new JUnitTestShortener(testTransformer, moduleFolder, test.toEntity(), test.getMethod())) {
if (testTransformer.getConfig().isDirectlyMeasureKieker()) {
File fileToInstrument = shortener.getCalleeClazzFile();
Expand All @@ -68,7 +74,14 @@ protected void runMethod(final File logFolder, final TestMethodCall test, final
clean(cleanFile);

final File methodLogFile = getMethodLogFile(logFolder, test);
runTest(moduleFolder, methodLogFile, test, test.getClazz(), timeout);

if(javaAgent != null) {
runTest(javaAgent, moduleFolder, methodLogFile, test, test.getClazz(), timeout == 0 ? 300 : timeout);
} else {
runTest(moduleFolder, methodLogFile, test, test.getClazz(), timeout == 0 ? 300 : timeout);
}

// runTest(moduleFolder, methodLogFile, test, test.getClazz(), timeout);
} catch (Exception e1) {
e1.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public int getJDKVersion() {

public abstract void executeTest(final TestMethodCall test, final File logFolder, long timeout);

public abstract void executeTest(final String javaAgent, final TestMethodCall test, final File logFolder, long timeout);

/**
* Deletes files which are bigger than sizeInMb Mb, since they pollute the disc space and will not be analyzable
*
Expand Down Expand Up @@ -125,7 +127,7 @@ protected void prepareKiekerSource() {

protected void execute(final String testname, final long timeoutInSeconds, final Process process) {
if (timeoutInSeconds == -1) {
LOG.info("Executing without timeout!");
LOG.warn("Executing without timeout!");
try {
process.waitFor();
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public List<File> findTempClazzFolder(final TestCase testcase) {

private List<File> findTempClazzFolder(final File baseFolder, final FileFilter folderFilter) {
final List<File> files = new LinkedList<>();
System.out.println("Searching in " + baseFolder + " " + baseFolder.exists());
LOG.trace("Searching in {} {}", baseFolder, baseFolder.exists());
for (final File subfolder : baseFolder.listFiles()) {
if (subfolder.isDirectory()) {
if (folderFilter.accept(subfolder)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ public boolean doesBuildfileExist() {
return true;
}

@Override
public void executeTest(String javaAgent, TestMethodCall test, File logFolder, long timeout) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'executeTest'");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public ProjectModules getModules() {
@Override
protected void clean(final File logFile) throws IOException, InterruptedException {
}

@Override
public void executeTest(String javaAgent, TestMethodCall test, File logFolder, long timeout) {
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import com.github.javaparser.ParseException;
Expand Down
6 changes: 6 additions & 0 deletions measurement/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@

<dependencies>

<dependency>
<groupId>io.github.terahidro2003</groupId>
<artifactId>sjsw</artifactId>
<version>0.1.4-SNAPSHOT</version>
</dependency>

<!-- For execution, it is assumed that the kieker aspectJ-jar is in the local .m2 directory; no need for inclusion in jar, therefore scope runtime -->
<dependency>
<groupId>net.kieker-monitoring</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ public TreeAnalyzer getAnalyzer(final BothTreeReader reader, final CauseSearcher
tester = new CauseSearcherComplete(reader, causeSearcherConfig, measurer, measurementConfiguration, alternateFolders, creator, env);
break;
case SAMPLING:
tester = new SamplingCauseSearcher(causeSearcherConfig.getTestCase(), measurementConfiguration, alternateFolders, env);
measurementConfiguration.setUseKieker(false);
tester = new SamplingCauseSearcher(causeSearcherConfig.getTestCase(), measurementConfiguration, alternateFolders, env, causeSearcherConfig, reader);
break;
default:
throw new RuntimeException("Strategy " + causeSearcherConfig.getRcaStrategy() + " not expected");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.time.Duration;

import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
Expand All @@ -13,6 +14,12 @@
import de.dagere.peass.measurement.organize.ResultOrganizer;
import de.dagere.peass.measurement.rca.searcher.ICauseSearcher;
import de.dagere.peass.testtransformation.TestTransformer;
import io.github.terahidro2003.config.Config;
import io.github.terahidro2003.samplers.SamplerExecutorPipeline;
import io.github.terahidro2003.samplers.asyncprofiler.AsyncProfilerExecutor;
import io.github.terahidro2003.samplers.asyncprofiler.MeasurementInformation;

import static io.github.terahidro2003.samplers.asyncprofiler.AsyncProfilerExecutor.log;

public class SamplingRunner extends AbstractMeasurementProcessRunner {
private static final Logger LOG = LogManager.getLogger(OnceRunner.class);
Expand All @@ -23,13 +30,17 @@ public class SamplingRunner extends AbstractMeasurementProcessRunner {
protected final ResultOrganizer currentOrganizer;
private final ICauseSearcher resultHandler;

public SamplingRunner(final PeassFolders folders, final TestExecutor testExecutor, final ResultOrganizer currentOrganizer, final ICauseSearcher resultHandler) {
private final Config configuration;

public SamplingRunner(final PeassFolders folders, final TestExecutor testExecutor, final ResultOrganizer currentOrganizer, final ICauseSearcher resultHandler,
final Config config) {
super(folders);
this.testTransformer = testExecutor.getTestTransformer();
this.testExecutor = testExecutor;
this.currentOrganizer = currentOrganizer;
this.resultHandler = resultHandler;

this.configuration = config;

try {
FileUtils.cleanDirectory(folders.getTempDir());
} catch (IOException e) {
Expand All @@ -39,20 +50,32 @@ public SamplingRunner(final PeassFolders folders, final TestExecutor testExecuto

@Override
public void runOnce(TestMethodCall testcase, String commit, int vmid, File logFolder) {
LOG.debug("Preparing testcase {} to run with SAMPLING enabled", testcase);
initCommit(commit);

final File vmidFolder = initVMFolder(commit, vmid, logFolder);

testExecutor.loadClasses();
testExecutor.prepareKoPeMeExecution(new File(logFolder, "clean.txt"));

//TODO implement sampling measurement
if (true) {
throw new RuntimeException("Not implemented yet");
}


final File vmidFolder = initVMFolder(commit, vmid, logFolder);

// What is the reason behind this arithmetic of timeout?
final long outerTimeout = 10 + (int) (this.testTransformer.getConfig().getTimeoutInSeconds() * 1.2);
LOG.info("Executing testcase {}", testcase);
String mavenJavaAgent = retrieveProfilerJavaAgentAsMavenArgument(configuration, outerTimeout, vmid, logFolder, commit);
testExecutor.executeTest(mavenJavaAgent, testcase, vmidFolder, outerTimeout);

LOG.info("Organizing result paths");
currentOrganizer.saveResultFiles(commit, vmid);

cleanup();
}

private String retrieveProfilerJavaAgentAsMavenArgument(Config config, long maxSamplingDuration, int vmid, File logFolder, String commit) {
Duration duration = Duration.ofSeconds(maxSamplingDuration * 60);
SamplerExecutorPipeline pipeline = new AsyncProfilerExecutor();
MeasurementInformation agent = pipeline.javaAgent(this.configuration, vmid, commit, duration);
String javaAgentAsMavenArgument = "-DargLine=" + agent.javaAgentPath();
LOG.info("Async-profiler java-agent configured: {}", javaAgentAsMavenArgument);
return javaAgentAsMavenArgument;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public String getCall() {
return call;
}

public void setCall(String call) { this.call = call; }

public String getKiekerPattern() {
return kiekerPattern;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public class CallTreeNode extends BasicNode {
protected final List<CallTreeNode> children = new ArrayList<>();
protected final Map<String, CallTreeStatistics> data = new HashMap<>();

public List<String> getKeys() {
return data.keySet().stream().collect(Collectors.toList());
}

public Map<String, CallTreeStatistics> getData() {
return data;
}

@JsonIgnore
protected MeasurementConfig config;

Expand Down Expand Up @@ -184,14 +192,23 @@ public String toString() {
return kiekerPattern.toString();
}

private String extractMethodName(String call) {
int lastParenthesisIndex = call.contains("(") ? call.lastIndexOf("(") : call.length() -1;
String methodName = call.substring(0, lastParenthesisIndex);

String[] parts = methodName.split(" ");
return parts.length > 1 ? parts[parts.length - 1] : call;
}

public MethodCall toEntity() {
if (call.equals(CauseSearchData.ADDED)) {
String otherKiekerPattern = getOtherKiekerPattern();
String otherCall = otherKiekerPattern.substring(otherKiekerPattern.lastIndexOf(' '), otherKiekerPattern.indexOf('('));
// String otherKiekerPattern = getOtherKiekerPattern();
String otherCall = getOtherCommitNode().getCall();
return MethodCall.createMethodCallFromString(otherCall);
} else {
final int index = call.lastIndexOf(MethodCall.METHOD_SEPARATOR);
String method = call.substring(index + 1);
System.out.println(call + " " + method);
final MethodCall entity;
if (method.contains("(")) {
entity = new MethodCall(call.substring(0, index), module, method.substring(0, method.indexOf('(')));
Expand Down Expand Up @@ -287,7 +304,7 @@ public void setOtherCommitNode(final CallTreeNode otherVersionNode) {

@JsonIgnore
public String getMethod() {
final String method = call.substring(call.lastIndexOf('#'));
final String method = call.contains("#") ? call.substring(call.lastIndexOf('#')) : call;
return method;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ private void setStatistic(final CallTreeNode rawDataNode, final MeasuredNode ser
serializeNode.setStatistic(rawDataNode.getTestcaseStatistic());
} else {
LOG.debug(rawDataNode.getCall() + " " + rawDataNode.getOtherKiekerPattern());
serializeNode.setStatistic(rawDataNode.getPartialTestcaseStatistic());
if (rawDataNode.getCall().equals(ADDED) &&
!rawDataNode.getOtherKiekerPattern().equals(ADDED)) {
serializeNode.setStatistic(rawDataNode.getOtherCommitNode().getPartialTestcaseStatistic());
} else {
serializeNode.setStatistic(rawDataNode.getPartialTestcaseStatistic());
}
}
}

Expand Down
Loading