private void initConfig(JSAPResult arguments) { this.config = RepairnatorConfig.getInstance(); this.config.setDebug(true); this.config.setRunId(LauncherUtils.getArgRunId(arguments)); this.config.setGithubToken(LauncherUtils.getArgGithubOAuth(arguments)); if (LauncherUtils.gerArgBearsMode(arguments)) { this.config.setLauncherMode(LauncherMode.BEARS); } else if (LauncherUtils.gerArgCheckstyleMode(arguments)) { this.config.setLauncherMode(LauncherMode.CHECKSTYLE); } else { this.config.setLauncherMode(LauncherMode.REPAIR); this.config.setInputPath(LauncherUtils.getArgInput(arguments).getPath()); this.config.setOutputPath(LauncherUtils.getArgOutput(arguments).getPath()); this.config.setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments)); this.config.setMongodbName(LauncherUtils.getArgMongoDBName(arguments)); this.config.setNotifyEndProcess(LauncherUtils.getArgNotifyEndProcess(arguments)); this.config.setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); this.config.setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); this.config.setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); this.config.setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); this.config.setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); this.config.setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); this.config.setDockerImageName(LauncherUtils.getArgDockerImageName(arguments)); this.config.setSkipDelete(LauncherUtils.getArgSkipDelete(arguments)); this.config.setCreateOutputDir(LauncherUtils.getArgCreateOutputDir(arguments)); this.config.setLogDirectory(LauncherUtils.getArgLogDirectory(arguments)); this.config.setNbThreads(LauncherUtils.getArgNbThreads(arguments));
this.inputBuildId = inputBuildId; this.logDirectory = logDirectory; this.repairnatorConfig = RepairnatorConfig.getInstance(); this.treatedBuildTracking = treatedBuildTracking; this.containerName = "repairnator-pipeline_"+ Utils.formatFilenameDate(new Date())+"_"+this.inputBuildId.getBuggyBuildId()+"_"+this.repairnatorConfig.getRunId(); String output = (this.repairnatorConfig.isCreateOutputDir()) ? "/var/log/"+this.repairnatorConfig.getRunId() : "/var/log"; if (this.repairnatorConfig.getLauncherMode() == LauncherMode.BEARS) { this.envValues.add("NEXT_BUILD_ID="+this.inputBuildId.getPatchedBuildId()); if (this.repairnatorConfig.isDebug()) { this.envValues.add("LOG_LEVEL=DEBUG"); } else { this.envValues.add("GITHUB_OAUTH="+RepairnatorConfig.getInstance().getGithubToken()); this.envValues.add("RUN_ID="+this.repairnatorConfig.getRunId()); this.envValues.add("REPAIR_MODE="+this.repairnatorConfig.getLauncherMode().name().toLowerCase()); this.envValues.add("PUSH_URL="+this.repairnatorConfig.getPushRemoteRepo()); this.envValues.add("MONGODB_HOST="+this.repairnatorConfig.getMongodbHost()); this.envValues.add("MONGODB_NAME="+this.repairnatorConfig.getMongodbName()); this.envValues.add("SMTP_SERVER="+this.repairnatorConfig.getSmtpServer()); this.envValues.add("SMTP_PORT="+this.repairnatorConfig.getSmtpPort()); this.envValues.add("SMTP_USERNAME="+this.repairnatorConfig.getSmtpUsername()); this.envValues.add("SMTP_PASSWORD="+this.repairnatorConfig.getSmtpPassword()); this.envValues.add("GITHUB_USERNAME="+this.repairnatorConfig.getGithubUserName()); this.envValues.add("GITHUB_USEREMAIL="+this.repairnatorConfig.getGithubUserEmail()); this.envValues.add("NOTIFY_TO="+ StringUtils.join(this.repairnatorConfig.getNotifyTo(),',')); this.envValues.add("OUTPUT="+output); if (this.repairnatorConfig.isCreatePR()) {
public InspectProcessDuration(InspectBuilds inspectBuilds, InspectJobs inspectJobs, BuildRunner buildRunner) { this.duration = RepairnatorConfig.getInstance().getDuration(); this.inspectBuilds = inspectBuilds; this.inspectJobs = inspectJobs; this.buildRunner = buildRunner; }
public InspectJobs(RTScanner scanner) { this.rtScanner = scanner; this.sleepTime = RepairnatorConfig.getInstance().getJobSleepTime(); }
public static List<NotifierEngine> initEmailSummaryEngines(Logger logger) { List<NotifierEngine> summaryEngines = new ArrayList<>(); RepairnatorConfig config = RepairnatorConfig.getInstance(); if(config.getSmtpServer() != null && config.getSummaryFrequency() != null && config.getNotifySummary() != null) { logger.info("The summary email engine will be used."); summaryEngines.add(new EmailNotifierEngine(config.getNotifySummary(), config.getSmtpServer(), config.getSmtpPort(), config.isSmtpTLS(), config.getSmtpUsername(), config.getSmtpPassword())); } else { logger.info("The summary email engine will not be used."); } return summaryEngines; }
private void initConfig(JSAPResult arguments) { this.config = RepairnatorConfig.getInstance(); this.config.setDebug(true); this.config.setLauncherMode(LauncherMode.CHECKSTYLE); } else { this.config.setLauncherMode(LauncherMode.REPAIR); this.config.setRunId(LauncherUtils.getArgRunId(arguments)); this.config.setOutputPath(LauncherUtils.getArgOutput(arguments).getPath()); this.config.setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments)); this.config.setMongodbName(LauncherUtils.getArgMongoDBName(arguments)); this.config.setNotifyEndProcess(LauncherUtils.getArgNotifyEndProcess(arguments)); this.config.setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); this.config.setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); this.config.setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); this.config.setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); this.config.setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); this.config.setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); this.config.setDockerImageName(LauncherUtils.getArgDockerImageName(arguments)); this.config.setSkipDelete(LauncherUtils.getArgSkipDelete(arguments)); this.config.setCreateOutputDir(LauncherUtils.getArgCreateOutputDir(arguments)); this.config.setLogDirectory(LauncherUtils.getArgLogDirectory(arguments)); this.config.setNbThreads(LauncherUtils.getArgNbThreads(arguments)); this.config.setGithubToken(LauncherUtils.getArgGithubOAuth(arguments)); this.config.setGithubUserEmail(LauncherUtils.getArgGithubUserEmail(arguments)); this.config.setGithubUserName(LauncherUtils.getArgGithubUserName(arguments)); if (LauncherUtils.getArgPushUrl(arguments) != null) { this.config.setPush(true);
private void initConfig(JSAPResult arguments) { if (LauncherUtils.getArgDebug(arguments)) { this.getConfig().setDebug(true); this.getConfig().setClean(true); this.getConfig().setRunId(LauncherUtils.getArgRunId(arguments)); this.getConfig().setGithubToken(LauncherUtils.getArgGithubOAuth(arguments)); if (LauncherUtils.gerArgBearsMode(arguments)) { this.getConfig().setLauncherMode(LauncherMode.BEARS); } else if (LauncherUtils.gerArgCheckstyleMode(arguments)) { this.getConfig().setLauncherMode(LauncherMode.CHECKSTYLE); } else { this.getConfig().setLauncherMode(LauncherMode.REPAIR); this.getConfig().setOutputPath(LauncherUtils.getArgOutput(arguments).getPath()); this.getConfig().setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments)); this.getConfig().setMongodbName(LauncherUtils.getArgMongoDBName(arguments)); this.getConfig().setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); this.getConfig().setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); this.getConfig().setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); this.getConfig().setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); this.getConfig().setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); this.getConfig().setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); this.getConfig().setPush(true); this.getConfig().setPushRemoteRepo(LauncherUtils.getArgPushUrl(arguments)); this.getConfig().setCreatePR(LauncherUtils.getArgCreatePR(arguments));
private void initConfig(JSAPResult arguments) { this.config = RepairnatorConfig.getInstance(); this.config.setDebug(true); this.config.setRunId(LauncherUtils.getArgRunId(arguments)); this.config.setGithubToken(LauncherUtils.getArgGithubOAuth(arguments)); this.config.setLauncherMode(LauncherMode.BEARS); } else { this.config.setLauncherMode(LauncherMode.REPAIR); this.config.setInputPath(LauncherUtils.getArgInput(arguments).getPath()); if (LauncherUtils.getArgOutput(arguments) != null) { this.config.setOutputPath(LauncherUtils.getArgOutput(arguments).getAbsolutePath()); this.config.setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments)); this.config.setMongodbName(LauncherUtils.getArgMongoDBName(arguments)); this.config.setNotifyEndProcess(LauncherUtils.getArgNotifyEndProcess(arguments)); this.config.setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); this.config.setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); this.config.setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); this.config.setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); this.config.setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); this.config.setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); Date lookFromDate = arguments.getDate("lookFromDate"); Date lookToDate = arguments.getDate("lookToDate"); this.config.setLookFromDate(lookFromDate); this.config.setLookToDate(lookToDate);
private void initConfig(JSAPResult arguments) { this.config = RepairnatorConfig.getInstance(); if (LauncherUtils.getArgDebug(arguments)) { this.config.setDebug(true); } this.config.setRunId(LauncherUtils.getArgRunId(arguments)); if (LauncherUtils.gerArgBearsMode(arguments)) { this.config.setLauncherMode(LauncherMode.BEARS); } else { this.config.setLauncherMode(LauncherMode.REPAIR); } this.config.setInputPath(LauncherUtils.getArgInput(arguments).getPath()); this.config.setOutputPath(LauncherUtils.getArgOutput(arguments).getAbsolutePath()); this.config.setNotifyEndProcess(LauncherUtils.getArgNotifyEndProcess(arguments)); this.config.setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); this.config.setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); this.config.setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); this.config.setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); this.config.setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); this.config.setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); this.config.setDockerImageName(LauncherUtils.getArgDockerImageName(arguments)); this.config.setSkipDelete(LauncherUtils.getArgSkipDelete(arguments)); this.config.setNbThreads(LauncherUtils.getArgNbThreads(arguments)); this.config.setGlobalTimeout(LauncherUtils.getArgGlobalTimeout(arguments)); this.config.setHumanPatch(arguments.getBoolean("humanPatch")); this.config.setRepository(arguments.getString("repository")); }
private void getBuildToBeInspected() { JTravis jTravis = this.getConfig().getJTravis(); Optional<Build> optionalBuild = jTravis.build().fromId(this.getConfig().getBuildId()); if (!optionalBuild.isPresent()) { LOGGER.error("Error while retrieving the buggy build. The process will exit now."); System.exit(-1); String runId = this.getConfig().getRunId(); if (this.getConfig().getLauncherMode() == LauncherMode.BEARS) { Optional<Build> optionalBuildPatch = jTravis.build().fromId(this.getConfig().getNextBuildId()); if (!optionalBuildPatch.isPresent()) { LOGGER.error("Error while getting patched build: null value was obtained. The process will exit now."); this.getConfig().setPush(false); this.getConfig().setFork(false); this.getConfig().setCreatePR(false); this.engines.clear(); LOGGER.info("The build "+this.getConfig().getBuildId()+" is from a project to be ignored ("+project+"), thus the pipeline deactivated serialization for that build.");
public static List<NotifierEngine> initNotifierEngines(Logger logger) { List<NotifierEngine> notifierEngines = new ArrayList<>(); RepairnatorConfig config = RepairnatorConfig.getInstance(); if (config.getSmtpServer() != null && config.getNotifyTo() != null) { logger.info("The email notifier engine will be used."); notifierEngines.add(new EmailNotifierEngine(config.getNotifyTo(), config.getSmtpServer(), config.getSmtpPort(), config.isSmtpTLS(), config.getSmtpUsername(), config.getSmtpPassword())); } else { logger.info("The email notifier engine won't be used."); } return notifierEngines; }
public ProjectScanner(Date lookFromDate, Date lookToDate, String runId) { this.lookFromDate = lookFromDate; this.lookToDate = lookToDate; this.slugs = new HashSet<String>(); this.repositories = new HashSet<Repository>(); this.runId = runId; this.jTravis = RepairnatorConfig.getInstance().getJTravis(); this.logger.info("Look from " + Utils.formatCompleteDate(this.lookFromDate) + " to " + Utils.formatCompleteDate(this.lookToDate)); }
private void setConfigurationFromProperties(Properties properties, RepairnatorConfig config) throws RepairnatorConfigException { try { config.setPush(Boolean.parseBoolean(properties.getProperty("push"))); config.setWorkspacePath(properties.getProperty("workspacePath")); config.setZ3solverPath(properties.getProperty("z3path")); config.setOutputPath(properties.getProperty("jsonOutputPath")); config.setPushRemoteRepo(properties.getProperty("pushRemoteRepo")); } catch (Exception e) { logger.error("Error while setting config values from properties."); throw new RepairnatorConfigException("Error while setting config values from properties.", e); } }
private void runPool() throws IOException { String runId = this.config.getRunId(); List<String> branchNames = this.readListOfBranches(); LOGGER.info("Find "+branchNames.size()+" branches to run."); this.docker = DockerHelper.initDockerClient(); String imageId = DockerHelper.findDockerImage(this.config.getDockerImageName(), this.docker); LOGGER.info("Found the following docker image id: "+imageId); ExecutorService executorService = Executors.newFixedThreadPool(this.config.getNbThreads()); for (String branchName : branchNames) { RunnablePipelineContainer runnablePipelineContainer = new RunnablePipelineContainer(imageId, branchName); submittedRunnablePipelineContainers.add(runnablePipelineContainer); executorService.submit(runnablePipelineContainer); } executorService.shutdown(); try { if (executorService.awaitTermination(this.config.getGlobalTimeout(), TimeUnit.DAYS)) { LOGGER.info("Job finished within time."); } else { LOGGER.warn("Timeout launched: the job is running for one day. Force stopped "+ submittedRunnablePipelineContainers.size()+" docker container(s)."); executorService.shutdownNow(); } } catch (InterruptedException e) { LOGGER.error("Error while await termination. Force stopped "+ submittedRunnablePipelineContainers.size()+" docker container(s).", e); executorService.shutdownNow(); } this.docker.close(); if (this.endProcessNotifier != null) { this.endProcessNotifier.notifyEnd(); } }
if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS) { for (Job job : build.getJobs()) { RepairnatorConfig.getInstance().getJTravis().refresh(job); if (job.getState() == StateType.PASSED) { Optional<Log> optionalLog = job.getLog();
private void initNotifiers() { if (this.config.isNotifyEndProcess()) { List<NotifierEngine> notifierEngines = LauncherUtils.initNotifierEngines(LOGGER); this.endProcessNotifier = new EndProcessNotifier(notifierEngines, LauncherType.DOCKERPOOL.name().toLowerCase()+" (runid: "+this.config.getRunId()+")"); } }
private Map<ScannedBuildStatus, List<BuildToBeInspected>> runScanner() throws IOException { Launcher.LOGGER.info("Start to scan projects in Travis..."); ProjectScanner scanner = new ProjectScanner(this.config.getLookFromDate(), this.config.getLookToDate(), this.config.getRunId()); Map<ScannedBuildStatus, List<BuildToBeInspected>> buildsToBeInspected = scanner.getListOfBuildsToBeInspectedFromProjects(this.config.getInputPath()); ProcessSerializer scannerSerializer; if (this.config.getLauncherMode() == LauncherMode.REPAIR) { scannerSerializer = new ScannerSerializer(this.engines, scanner); } else { scannerSerializer = new ScannerSerializer4Bears(this.engines, scanner); ScannerDetailedDataSerializer scannerDetailedDataSerializer = new ScannerDetailedDataSerializer(this.engines, buildsToBeInspected); scannerDetailedDataSerializer.serialize(); } scannerSerializer.serialize(); Launcher.LOGGER.info("---------------------------------------------------------------"); Launcher.LOGGER.info("Scanner results."); Launcher.LOGGER.info("---------------------------------------------------------------"); if (buildsToBeInspected.isEmpty()) { Launcher.LOGGER.info("No build interesting to be inspected has been found ("+scanner.getTotalScannedBuilds()+" scanned builds.)"); } else { Launcher.LOGGER.info(buildsToBeInspected.size()+" builds interesting to be inspected have been found ("+scanner.getTotalScannedBuilds()+" scanned builds.)"); } return buildsToBeInspected; }
public BuildRunner(RTScanner rtScanner) { LOGGER.info("Init build runner"); super.setDockerOutputDir(RepairnatorConfig.getInstance().getLogDirectory()); super.setRunId(RepairnatorConfig.getInstance().getRunId()); super.setEngines(rtScanner.getEngines()); }
private void serializeData() { if (serializers != null) { if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS) { this.getLogger().info("Serialize all data for the pair of builds " + this.getInspector().getBuggyBuild().getId() + ", " + this.getInspector().getPatchedBuild().getId()); } else { this.getLogger().info("Serialize all data for build: " + this.getInspector().getBuggyBuild().getId()); } for (AbstractDataSerializer serializer : this.serializers) { serializer.serializeData(this.inspector); } } }
public void initRunner() { this.setDockerImageName(RepairnatorConfig.getInstance().getDockerImageName()); this.initExecutorService(RepairnatorConfig.getInstance().getNbThreads()); }