Search in sources :

Example 11 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class LauncherUtils method initMongoDBSerializerEngine.

public static SerializerEngine initMongoDBSerializerEngine(Logger logger) {
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    if (config.getMongodbHost() != null) {
        logger.info("Initialize mongoDB serializer engine.");
        MongoConnection mongoConnection = new MongoConnection(config.getMongodbHost(), config.getMongodbName());
        if (mongoConnection.isConnected()) {
            return new MongoDBSerializerEngine(mongoConnection);
        } else {
            logger.error("Error while connecting to mongoDB.");
        }
    } else {
        logger.info("MongoDB won't be used for serialization.");
    }
    return null;
}
Also used : RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) MongoConnection(fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection) MongoDBSerializerEngine(fr.inria.spirals.repairnator.serializer.engines.json.MongoDBSerializerEngine)

Example 12 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class TestCheckoutBuild method testCheckoutBuggyBuild.

@Test
public void testCheckoutBuggyBuild() throws IOException, GitAPIException, RepairnatorConfigException {
    // surli/failingProject build
    int buildId = 207924136;
    RepairnatorConfig repairnatorConfig = RepairnatorConfig.getInstance();
    repairnatorConfig.setClean(false);
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_checkout");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    BuildToBeInspected toBeInspected = new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, "");
    ProjectInspector inspector = mock(ProjectInspector.class);
    when(inspector.getWorkspace()).thenReturn(tmpDir.getAbsolutePath());
    when(inspector.getRepoLocalPath()).thenReturn(tmpDir.getAbsolutePath() + "/repo");
    when(inspector.getBuildToBeInspected()).thenReturn(toBeInspected);
    when(inspector.getBuggyBuild()).thenReturn(build);
    when(inspector.getGitHelper()).thenReturn(new GitHelper());
    JobStatus jobStatus = new JobStatus(tmpDir.getAbsolutePath() + "/repo");
    when(inspector.getJobStatus()).thenReturn(jobStatus);
    CloneRepository cloneStep = new CloneRepository(inspector);
    CheckoutBuggyBuild checkoutBuggyBuild = new CheckoutBuggyBuild(inspector);
    cloneStep.setNextStep(checkoutBuggyBuild);
    cloneStep.execute();
    assertThat(checkoutBuggyBuild.getPipelineState(), is(PipelineState.BUILDCHECKEDOUT));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.BUILDCHECKEDOUT));
    assertThat(checkoutBuggyBuild.isShouldStop(), is(false));
    Git gitDir = Git.open(new File(tmpDir, "repo"));
    Iterable<RevCommit> logs = gitDir.log().call();
    Iterator<RevCommit> iterator = logs.iterator();
    boolean foundRightCommitAfterRepairCommits = false;
    boolean stopSearch = false;
    while (iterator.hasNext() && !stopSearch) {
        RevCommit revCommit = iterator.next();
        if (revCommit.getName().equals(build.getCommit().getSha())) {
            foundRightCommitAfterRepairCommits = true;
            stopSearch = true;
        } else if (!revCommit.getShortMessage().contains("repairnator")) {
            stopSearch = true;
        }
    }
    assertThat(foundRightCommitAfterRepairCommits, is(true));
}
Also used : Path(java.nio.file.Path) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) GitHelper(fr.inria.spirals.repairnator.process.git.GitHelper) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) CloneRepository(fr.inria.spirals.repairnator.process.step.CloneRepository) Git(org.eclipse.jgit.api.Git) Build(fr.inria.jtravis.entities.Build) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 13 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class TestProjectInspector method testSpoonException.

@Test
public void testSpoonException() throws IOException, GitAPIException {
    // surli/failingProject only-one-failing
    int buildId = 355743087;
    Path tmpDirPath = Files.createTempDirectory("test_spoonexception");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    Build failingBuild = BuildHelper.getBuildFromId(buildId, null);
    BuildToBeInspected buildToBeInspected = new BuildToBeInspected(failingBuild, null, ScannedBuildStatus.ONLY_FAIL, "test");
    List<AbstractDataSerializer> serializers = new ArrayList<>();
    List<AbstractNotifier> notifiers = new ArrayList<>();
    List<SerializerEngine> serializerEngines = new ArrayList<>();
    SerializerEngine serializerEngine = mock(SerializerEngine.class);
    serializerEngines.add(serializerEngine);
    serializers.add(new InspectorSerializer(serializerEngines));
    serializers.add(new NopolSerializer(serializerEngines));
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setLauncherMode(LauncherMode.REPAIR);
    ProjectInspector inspector = new ProjectInspector(buildToBeInspected, tmpDir.getAbsolutePath(), serializers, notifiers);
    inspector.run();
    JobStatus jobStatus = inspector.getJobStatus();
    assertThat(jobStatus.getPipelineState(), is(PipelineState.NOPOL_NOTPATCHED));
    assertThat(jobStatus.getNopolInformations().get(0).getStatus(), is(NopolStatus.EXCEPTION));
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR));
}
Also used : Path(java.nio.file.Path) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) ArrayList(java.util.ArrayList) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) InspectorSerializer(fr.inria.spirals.repairnator.serializer.InspectorSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Build(fr.inria.jtravis.entities.Build) NopolSerializer(fr.inria.spirals.repairnator.serializer.NopolSerializer) File(java.io.File) Test(org.junit.Test)

Example 14 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class TestProjectInspector method testFailingProjectNotBuildable.

@Test
public void testFailingProjectNotBuildable() throws IOException, GitAPIException {
    // surli/failingProject only-one-failing
    int buildId = 228303218;
    Path tmpDirPath = Files.createTempDirectory("test_complete2");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    Build failingBuild = BuildHelper.getBuildFromId(buildId, null);
    BuildToBeInspected buildToBeInspected = new BuildToBeInspected(failingBuild, null, ScannedBuildStatus.ONLY_FAIL, "test");
    List<AbstractDataSerializer> serializers = new ArrayList<>();
    List<AbstractNotifier> notifiers = new ArrayList<>();
    List<SerializerEngine> serializerEngines = new ArrayList<>();
    SerializerEngine serializerEngine = mock(SerializerEngine.class);
    serializerEngines.add(serializerEngine);
    serializers.add(new InspectorSerializer(serializerEngines));
    serializers.add(new NopolSerializer(serializerEngines));
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setLauncherMode(LauncherMode.REPAIR);
    ProjectInspector inspector = new ProjectInspector(buildToBeInspected, tmpDir.getAbsolutePath(), serializers, notifiers);
    inspector.run();
    JobStatus jobStatus = inspector.getJobStatus();
    assertThat(jobStatus.getPipelineState(), is(PipelineState.NOTBUILDABLE));
    assertThat(jobStatus.getPushState(), is(PushState.NONE));
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR));
}
Also used : Path(java.nio.file.Path) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) ArrayList(java.util.ArrayList) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) InspectorSerializer(fr.inria.spirals.repairnator.serializer.InspectorSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Build(fr.inria.jtravis.entities.Build) NopolSerializer(fr.inria.spirals.repairnator.serializer.NopolSerializer) File(java.io.File) Test(org.junit.Test)

Example 15 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class TestProjectInspector method setUp.

@Before
public void setUp() {
    String solverPath;
    if (isMac()) {
        solverPath = SOLVER_PATH_DIR + SOLVER_NAME_MAC;
    } else {
        solverPath = SOLVER_PATH_DIR + SOLVER_NAME_LINUX;
    }
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setZ3solverPath(solverPath);
    config.setPush(true);
    config.setPushRemoteRepo("");
    Utils.setLoggersLevel(Level.ERROR);
}
Also used : RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Before(org.junit.Before)

Aggregations

RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)19 File (java.io.File)12 Build (fr.inria.jtravis.entities.Build)11 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)11 Path (java.nio.file.Path)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 SerializerEngine (fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)8 Git (org.eclipse.jgit.api.Git)8 RevCommit (org.eclipse.jgit.revwalk.RevCommit)8 AbstractNotifier (fr.inria.spirals.repairnator.notifier.AbstractNotifier)7 AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)7 SerializedData (fr.inria.spirals.repairnator.serializer.engines.SerializedData)7 NotifierEngine (fr.inria.spirals.repairnator.notifier.engines.NotifierEngine)6 InspectorSerializer (fr.inria.spirals.repairnator.serializer.InspectorSerializer)5 NopolSerializer (fr.inria.spirals.repairnator.serializer.NopolSerializer)5 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)4 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)4 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)4 CloneRepository (fr.inria.spirals.repairnator.process.step.CloneRepository)4