Search in sources :

Example 31 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData in project peass by DaGeRe.

the class ContinuousDependencyReaderIT method testAnotherVersion.

@Order(2)
@Test
public void testAnotherVersion() throws Exception {
    final String prevTag = builder.getTags().get(builder.getTags().size() - 1);
    GitUtils.goToTag(prevTag, TestConstants.CURRENT_FOLDER);
    String newVersion = builder.addVersion(new File("../dependency/src/test/resources/dependencyIT/basic_state"), "test 2");
    VersionIteratorGit iterator = new VersionIteratorGit(TestConstants.CURRENT_FOLDER);
    ExecutionConfig executionConfig = new ExecutionConfig();
    executionConfig.setVersion(newVersion);
    executionConfig.setVersionOld(iterator.getPrevious().getTag());
    final ContinuousDependencyReader spiedReader = new ContinuousDependencyReader(DependencyTestConstants.DEFAULT_CONFIG_WITH_VIEWS, executionConfig, new KiekerConfig(true), new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, new EnvironmentVariables());
    StaticTestSelection dependencies = spiedReader.getDependencies(iterator, "");
    final String lastTag = builder.getTags().get(builder.getTags().size() - 1);
    checkVersion(dependencies, lastTag, 2);
    ExecutionData executions = Constants.OBJECTMAPPER.readValue(resultsFolders.getTraceTestSelectionFile(), ExecutionData.class);
    Assert.assertEquals(3, executions.getVersions().size());
}
Also used : VersionIteratorGit(de.dagere.peass.vcs.VersionIteratorGit) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) File(java.io.File) KiekerConfig(de.dagere.peass.config.KiekerConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Example 32 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData in project peass by DaGeRe.

the class CreateMeasurementExecutionScript method call.

@Override
public Void call() throws Exception {
    if (dependencyFile != null) {
        dependencies = Constants.OBJECTMAPPER.readValue(dependencyFile, StaticTestSelection.class);
    }
    if (executionfile != null) {
        executionData = Constants.OBJECTMAPPER.readValue(executionfile, ExecutionData.class);
        dependencies = new StaticTestSelection(executionData);
    }
    if (executionData == null && dependencies == null) {
        throw new RuntimeException("Dependencyfile and executionfile not readable - one needs to be defined!");
    }
    PrintStream destination = System.out;
    RunCommandWriter writer;
    if (useSlurm) {
        destination.println("timestamp=$(date +%s)");
        writer = new RunCommandWriterSlurm(System.out, experimentId, dependencies);
    } else {
        writer = new RunCommandWriter(destination, experimentId, dependencies);
    }
    generateExecuteCommands(dependencies, executionData, experimentId, writer);
    return null;
}
Also used : PrintStream(java.io.PrintStream) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Example 33 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData in project peass by DaGeRe.

the class DivideAllVersions method main.

public static void main(final String[] args) throws JAXBException, JsonParseException, JsonMappingException, IOException {
    String repoName = System.getenv(Constants.PEASS_REPOS);
    File repos = new File(repoName);
    if (!repos.exists()) {
        LOG.error("Repofolder " + repos.getAbsolutePath() + " not found!");
    }
    final File resultFolder = new File("results");
    if (!resultFolder.exists()) {
        resultFolder.mkdirs();
    }
    File dependencyFolder = new File(repos, "dependencies-final");
    for (String project : Constants.defaultUrls.keySet()) {
        File dependencyFile = new File(dependencyFolder, ResultsFolders.STATIC_SELECTION_PREFIX + project + ".json");
        File executionFile = new File(dependencyFolder, ResultsFolders.TRACE_SELECTION_PREFIX + project + ".json");
        if (dependencyFile.exists() && executionFile.exists()) {
            LOG.debug("Loading: " + project);
            final File executeCommandsFile = new File(resultFolder, "execute-" + project + ".sh");
            final StaticTestSelection dependencies = Constants.OBJECTMAPPER.readValue(dependencyFile, StaticTestSelection.class);
            final ExecutionData changedTests = Constants.OBJECTMAPPER.readValue(executionFile, ExecutionData.class);
            CreateMeasurementExecutionScript.generateExecuteCommands(dependencies, changedTests, "validation", new PrintStream(new FileOutputStream(executeCommandsFile)));
        } else {
            LOG.error("File not existing: " + project + " " + Constants.defaultUrls.get(project) + " " + dependencyFile.getAbsolutePath());
        }
    }
}
Also used : PrintStream(java.io.PrintStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Example 34 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData in project peass by DaGeRe.

the class DependencyViewGeneratorTest method testTwoVersions.

@Test
public void testTwoVersions() throws Exception {
    try (MockedStatic<GitUtils> gitUtilsMock = Mockito.mockStatic(GitUtils.class)) {
        FakeGitUtil.prepareGitUtils(gitUtilsMock);
        DependencyDetectorTestUtil.init(TraceGettingIT.BASIC);
        ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
        TestSelectionConfig dependencyConfig = new TestSelectionConfig(1, false, true, false);
        FakeFileIterator iteratorspied = mockIterator();
        DependencyReader reader = new DependencyReader(dependencyConfig, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iteratorspied, new VersionKeeper(new File("/dev/null")), new ExecutionConfig(), new KiekerConfig(true), new EnvironmentVariables());
        reader.readInitialVersion();
        try {
            reader.readDependencies();
        } catch (Throwable t) {
            System.out.println();
            for (StackTraceElement te : t.getStackTrace()) {
                System.out.println(te);
            }
            System.out.println();
            throw t;
        }
        File expectedDiff = new File(resultsFolders.getVersionDiffFolder("000002"), "TestMe#test.txt");
        System.out.println(expectedDiff.getAbsolutePath());
        Assert.assertTrue(expectedDiff.exists());
        // TODO Test, that instrumentation sources are not added to the view
        final ExecutionData tests = Constants.OBJECTMAPPER.readValue(resultsFolders.getTraceTestSelectionFile(), ExecutionData.class);
        // 
        Assert.assertEquals(2, tests.getVersions().size());
        Assert.assertEquals(1, tests.getVersions().get("000002").getTests().size());
    }
}
Also used : TestSelectionConfig(de.dagere.peass.config.TestSelectionConfig) VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) GitUtils(de.dagere.peass.vcs.GitUtils) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File) KiekerConfig(de.dagere.peass.config.KiekerConfig) Test(org.junit.jupiter.api.Test)

Example 35 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData in project peass by DaGeRe.

the class TestChangedTraceTestSerialisation method testVersionContent.

@Test
public void testVersionContent() throws IOException {
    final ExecutionData tests = new ExecutionData();
    tests.addEmptyVersion("v1", "v0");
    tests.addCall("v1", new TestCase("Test1#test"));
    tests.addEmptyVersion("v2", "v1");
    tests.addCall("v2", new TestCase("Test1#test"));
    final ObjectMapper mapper = Constants.OBJECTMAPPER;
    final String json = mapper.writeValueAsString(tests);
    Assert.assertNotNull(json);
    System.out.println(json);
    final ExecutionData deserialize = mapper.readValue(json, ExecutionData.class);
    Assert.assertNotNull(deserialize);
    Map<TestCase, Set<String>> regularV1 = tests.getVersions().get("v1").getTestcases();
    Map<TestCase, Set<String>> deserializedV1 = deserialize.getVersions().get("v1").getTestcases();
    Assert.assertEquals(regularV1, deserializedV1);
}
Also used : Set(java.util.Set) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) Test(org.junit.jupiter.api.Test)

Aggregations

ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)42 File (java.io.File)25 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)12 Test (org.junit.jupiter.api.Test)10 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)8 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)8 ResultsFolders (de.dagere.peass.folders.ResultsFolders)7 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)6 PeassFolders (de.dagere.peass.folders.PeassFolders)5 PrintStream (java.io.PrintStream)5 RepoFolders (de.dagere.peass.analysis.all.RepoFolders)4 ProjectChanges (de.dagere.peass.analysis.changes.ProjectChanges)4 PropertyReader (de.dagere.peass.analysis.properties.PropertyReader)4 KiekerConfig (de.dagere.peass.config.KiekerConfig)4 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)4 ChangeReader (de.dagere.peass.analysis.changes.ChangeReader)3 VersionKeeper (de.dagere.peass.dependency.reader.VersionKeeper)3 LinkedList (java.util.LinkedList)3 Change (de.dagere.peass.analysis.changes.Change)2 VersionChangeProperties (de.dagere.peass.analysis.properties.VersionChangeProperties)2