Search in sources :

Example 1 with BothTreeReader

use of de.dagere.peass.measurement.rca.kieker.BothTreeReader in project peass by DaGeRe.

the class LevelCauseSearchExperimentalStarter method main.

public static void main(final String[] args) throws IOException, XmlPullParserException, InterruptedException, IllegalStateException, AnalysisConfigurationException, ViewNotFoundException, JAXBException {
    final File projectFolder = new File("../../projekte/commons-fileupload");
    final String version = "4ed6e923cb2033272fcb993978d69e325990a5aa";
    final TestCase test = new TestCase("org.apache.commons.fileupload.ServletFileUploadTest", "testFoldedHeaders");
    final MeasurementConfig measurementConfiguration = new MeasurementConfig(15 * 1000 * 60, 5, true, version, version + "~1");
    measurementConfiguration.setUseKieker(true);
    final CauseSearcherConfig causeSearcherConfig = new CauseSearcherConfig(test, false, 0.1, false, false, RCAStrategy.COMPLETE, 1);
    final CauseSearchFolders folders2 = new CauseSearchFolders(projectFolder);
    final BothTreeReader reader = new BothTreeReader(causeSearcherConfig, measurementConfiguration, folders2, new EnvironmentVariables());
    final CauseTester measurer = new CauseTester(folders2, measurementConfiguration, causeSearcherConfig, new EnvironmentVariables());
    final LevelCauseSearcher searcher = new LevelCauseSearcher(reader, causeSearcherConfig, measurer, measurementConfiguration, folders2, new EnvironmentVariables());
    reader.readTrees();
    List<CallTreeNode> predecessor = Arrays.asList(new CallTreeNode[] { reader.getRootPredecessor() });
    List<CallTreeNode> current = Arrays.asList(new CallTreeNode[] { reader.getRootVersion() });
    int level = 0;
    boolean hasChilds = true;
    while (hasChilds) {
        level++;
        LOG.info("Level: " + level + " " + predecessor.get(0).getKiekerPattern());
        boolean foundNodeLevel = false;
        final List<CallTreeNode> predecessorNew = new LinkedList<>();
        final List<CallTreeNode> currentNew = new LinkedList<>();
        final Iterator<CallTreeNode> currentIterator = current.iterator();
        for (final Iterator<CallTreeNode> preIterator = predecessor.iterator(); preIterator.hasNext() && currentIterator.hasNext(); ) {
            final CallTreeNode predecessorChild = preIterator.next();
            final CallTreeNode currentChild = currentIterator.next();
            predecessorNew.addAll(predecessorChild.getChildren());
            currentNew.addAll(currentChild.getChildren());
            final String searchedCall = "public static long org.apache.commons.fileupload.util.Streams.copy(java.io.InputStream,java.io.OutputStream,boolean,byte[])";
            if (predecessorChild.getKiekerPattern().equals(searchedCall) && currentChild.getKiekerPattern().equals(searchedCall)) {
                foundNodeLevel = true;
            }
            if (predecessorChild.getKiekerPattern().equals(searchedCall) != currentChild.getKiekerPattern().equals(searchedCall)) {
                LOG.info(predecessorChild.getKiekerPattern());
                LOG.info(currentChild.getKiekerPattern());
                throw new RuntimeException("Tree structure differs above searched node!");
            }
        }
        if (foundNodeLevel) {
            LOG.info("Found!");
            searcher.isLevelDifferent(predecessorNew, currentNew);
        }
        predecessor = predecessorNew;
        current = currentNew;
        if (predecessor.isEmpty()) {
            hasChilds = false;
        }
    }
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) CallTreeNode(de.dagere.peass.measurement.rca.data.CallTreeNode) BothTreeReader(de.dagere.peass.measurement.rca.kieker.BothTreeReader) LinkedList(java.util.LinkedList) CauseSearchFolders(de.dagere.peass.folders.CauseSearchFolders) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) LevelCauseSearcher(de.dagere.peass.measurement.rca.searcher.LevelCauseSearcher) File(java.io.File)

Example 2 with BothTreeReader

use of de.dagere.peass.measurement.rca.kieker.BothTreeReader in project peass by DaGeRe.

the class RootCauseAnalysis method call.

@Override
public Void call() throws Exception {
    if (testName == null) {
        throw new RuntimeException("Test needs to be defined!");
    }
    initVersionProcessor();
    if (version == null) {
        version = executionData.getVersions().keySet().iterator().next();
        LOG.info("Version was not defined, using " + version);
    }
    final TestCase test = new TestCase(testName);
    final VersionStaticSelection versionInfo = staticTestSelection.getVersions().get(version);
    boolean found = versionInfo.getTests().getTests().contains(test);
    if (!found) {
        LOG.error("Test " + test + " is not contained in regression test selection result, therefore it is unlikely to have a performance change!");
    }
    final String predecessor = versionInfo.getPredecessor();
    LOG.debug("Timeout in minutes: {}", executionMixin.getTimeout());
    final MeasurementConfig measurementConfiguration = getConfiguration(predecessor);
    final CauseSearcherConfig causeSearcherConfig = new CauseSearcherConfig(test, causeSearchConfigMixin);
    if (kiekerConfigMixin.isUseAggregation() && measurementConfiguration.getKiekerConfig().getRecord() == AllowedKiekerRecord.OPERATIONEXECUTION) {
        throw new RuntimeException("Aggregation and OperationExecutionRecord can not be combined!");
    }
    final CauseSearchFolders alternateFolders = new CauseSearchFolders(folders.getProjectFolder());
    final BothTreeReader reader = new BothTreeReader(causeSearcherConfig, measurementConfiguration, alternateFolders, new EnvironmentVariables());
    final CauseSearcher tester = getCauseSeacher(measurementConfiguration, causeSearcherConfig, alternateFolders, reader);
    tester.search();
    return null;
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) CauseSearchFolders(de.dagere.peass.folders.CauseSearchFolders) LevelCauseSearcher(de.dagere.peass.measurement.rca.searcher.LevelCauseSearcher) CauseSearcher(de.dagere.peass.measurement.rca.searcher.CauseSearcher) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) VersionStaticSelection(de.dagere.peass.dependency.persistence.VersionStaticSelection) BothTreeReader(de.dagere.peass.measurement.rca.kieker.BothTreeReader) CauseSearcherConfig(de.dagere.peass.measurement.rca.CauseSearcherConfig)

Example 3 with BothTreeReader

use of de.dagere.peass.measurement.rca.kieker.BothTreeReader in project peass by DaGeRe.

the class LevelManagerTest method testLongTree.

@Test
public void testLongTree() {
    final CauseSearchData data = new CauseSearchData();
    final MeasuredNode rootMeasured = new MeasuredNode("Test#test", "public void Test.test()", null);
    data.setNodes(rootMeasured);
    final CallTreeNode root = new CallTreeNode("Test#test", "public void Test.test()", "public void Test.test()", (MeasurementConfig) null);
    CallTreeNode current = root;
    MeasuredNode measuredCurrent = rootMeasured;
    for (int i = 0; i < 20; i++) {
        final String call = "C" + i + ".method" + i;
        final String kiekerPattern = "public void " + call + "()";
        current = current.appendChild(call, kiekerPattern, null);
        final MeasuredNode childMeasured = new MeasuredNode(call, kiekerPattern, null);
        measuredCurrent.getChilds().add(childMeasured);
        measuredCurrent = childMeasured;
    }
    current.appendChild("FinalClass.finalMethod", "public void FinalClass.finalMethod()", null);
    final BothTreeReader mock = Mockito.mock(BothTreeReader.class);
    Mockito.when(mock.getRootPredecessor()).thenReturn(root);
    Mockito.when(mock.getRootVersion()).thenReturn(root);
    final LinkedList<CallTreeNode> currentVersionNodeList = new LinkedList<>();
    final LinkedList<CallTreeNode> currentVersionPredecessorNodeList = new LinkedList<>();
    new LevelManager(currentVersionPredecessorNodeList, currentVersionNodeList, mock).goToLastMeasuredLevel(rootMeasured);
    System.out.println(currentVersionPredecessorNodeList);
    Assert.assertEquals(1, currentVersionPredecessorNodeList.size());
    Assert.assertEquals(1, currentVersionNodeList.size());
    Assert.assertEquals("FinalClass.finalMethod", currentVersionNodeList.get(0).getCall());
}
Also used : MeasuredNode(de.dagere.peass.measurement.rca.serialization.MeasuredNode) CallTreeNode(de.dagere.peass.measurement.rca.data.CallTreeNode) CauseSearchData(de.dagere.peass.measurement.rca.data.CauseSearchData) LevelManager(de.dagere.peass.measurement.rca.LevelManager) BothTreeReader(de.dagere.peass.measurement.rca.kieker.BothTreeReader) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 4 with BothTreeReader

use of de.dagere.peass.measurement.rca.kieker.BothTreeReader in project peass by DaGeRe.

the class TestSourceChangeTreeAnalyzer method testNodeSelection.

@Test
public void testNodeSelection() throws InterruptedException, IOException, XmlPullParserException, ViewNotFoundException, AnalysisConfigurationException {
    final MeasurementConfig config = new MeasurementConfig(15, "fd2c8ddf3fa52973ee54c4db87b47bb587886200", "fd2c8ddf3fa52973ee54c4db87b47bb587886200~1");
    BothTreeReader treeReader = new BothTreeReader(new CauseSearcherConfig(new TestCase("de.peass.MainTest#testMe"), new CauseSearcherConfigMixin()), config, new CauseSearchFolders(new File("src/test/resources/sourceChangeRCATest/project_3")), new EnvironmentVariables());
    treeReader.readTrees();
    SourceChangeTreeAnalyzer analyzer = new SourceChangeTreeAnalyzer(treeReader.getRootVersion(), treeReader.getRootPredecessor(), new File("src/test/resources/sourceChangeRCATest/properties_project_3"), config);
    List<String> instrumentedCalls = analyzer.getMeasurementNodesPredecessor().stream().map(node -> node.getCall()).collect(Collectors.toList());
    Assert.assertThat(instrumentedCalls, IsIterableContaining.hasItem("de.peass.MainTest#testMe"));
    Assert.assertThat(instrumentedCalls, IsIterableContaining.hasItem("de.peass.C0_0#method0"));
    Assert.assertThat(instrumentedCalls, IsIterableContaining.hasItem("de.peass.C1_0#method0"));
    Assert.assertThat(instrumentedCalls, Matchers.not(IsIterableContaining.hasItem("de.peass.AddRandomNumbers#addSomething")));
    Assert.assertThat(instrumentedCalls, Matchers.not(IsIterableContaining.hasItem("de.peass.C1_0#method1")));
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) CauseSearchFolders(de.dagere.peass.folders.CauseSearchFolders) CauseSearchFolders(de.dagere.peass.folders.CauseSearchFolders) SourceChangeTreeAnalyzer(de.dagere.peass.measurement.rca.analyzer.SourceChangeTreeAnalyzer) ViewNotFoundException(de.dagere.peass.dependencyprocessors.ViewNotFoundException) CauseSearcherConfigMixin(de.dagere.peass.measurement.rca.CauseSearcherConfigMixin) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) Matchers(org.hamcrest.Matchers) CauseSearcherConfig(de.dagere.peass.measurement.rca.CauseSearcherConfig) IOException(java.io.IOException) AnalysisConfigurationException(kieker.analysis.exception.AnalysisConfigurationException) Collectors(java.util.stream.Collectors) File(java.io.File) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) Test(org.junit.jupiter.api.Test) List(java.util.List) IsIterableContaining(org.hamcrest.core.IsIterableContaining) MeasurementConfig(de.dagere.peass.config.MeasurementConfig) BothTreeReader(de.dagere.peass.measurement.rca.kieker.BothTreeReader) Assert(org.junit.Assert) CauseSearcherConfigMixin(de.dagere.peass.measurement.rca.CauseSearcherConfigMixin) SourceChangeTreeAnalyzer(de.dagere.peass.measurement.rca.analyzer.SourceChangeTreeAnalyzer) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) BothTreeReader(de.dagere.peass.measurement.rca.kieker.BothTreeReader) File(java.io.File) CauseSearcherConfig(de.dagere.peass.measurement.rca.CauseSearcherConfig) Test(org.junit.jupiter.api.Test)

Example 5 with BothTreeReader

use of de.dagere.peass.measurement.rca.kieker.BothTreeReader in project peass by DaGeRe.

the class CauseSearcherCompleteTest method getChanges.

private Set<ChangedEntity> getChanges(final CallTreeNode rootPredecessor, final CallTreeNode rootVersion) throws InterruptedException, IOException, XmlPullParserException, AnalysisConfigurationException, ViewNotFoundException, JAXBException {
    final File folder = new File("target/test/");
    folder.mkdir();
    final BothTreeReader treeReader = Mockito.mock(BothTreeReader.class);
    Mockito.when(treeReader.getRootPredecessor()).thenReturn(rootPredecessor);
    Mockito.when(treeReader.getRootVersion()).thenReturn(rootVersion);
    final CauseSearcherComplete searcher = new CauseSearcherComplete(treeReader, TestConstants.SIMPLE_CAUSE_CONFIG, measurer, TestConstants.SIMPLE_MEASUREMENT_CONFIG, new CauseSearchFolders(folder), new EnvironmentVariables());
    final Set<ChangedEntity> changes = searcher.search();
    return changes;
}
Also used : CauseSearchFolders(de.dagere.peass.folders.CauseSearchFolders) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) CauseSearcherComplete(de.dagere.peass.measurement.rca.searcher.CauseSearcherComplete) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) BothTreeReader(de.dagere.peass.measurement.rca.kieker.BothTreeReader) File(java.io.File)

Aggregations

BothTreeReader (de.dagere.peass.measurement.rca.kieker.BothTreeReader)13 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)7 CauseSearchFolders (de.dagere.peass.folders.CauseSearchFolders)7 CallTreeNode (de.dagere.peass.measurement.rca.data.CallTreeNode)6 LinkedList (java.util.LinkedList)6 LevelManager (de.dagere.peass.measurement.rca.LevelManager)5 CauseSearchData (de.dagere.peass.measurement.rca.data.CauseSearchData)5 File (java.io.File)5 Test (org.junit.Test)5 MeasurementConfig (de.dagere.peass.config.MeasurementConfig)4 CauseSearcherConfig (de.dagere.peass.measurement.rca.CauseSearcherConfig)4 CauseSearcher (de.dagere.peass.measurement.rca.searcher.CauseSearcher)4 LevelCauseSearcher (de.dagere.peass.measurement.rca.searcher.LevelCauseSearcher)4 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)3 CauseSearcherComplete (de.dagere.peass.measurement.rca.searcher.CauseSearcherComplete)3 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)2 CauseTester (de.dagere.peass.measurement.rca.CauseTester)2 SourceChangeTreeAnalyzer (de.dagere.peass.measurement.rca.analyzer.SourceChangeTreeAnalyzer)2 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)1 ViewNotFoundException (de.dagere.peass.dependencyprocessors.ViewNotFoundException)1