@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (getClass() != obj.getClass()) { return false; } StageGroup g = (StageGroup) obj; if (g.getStages().size() == stages.size()) { for (Stage s : g.getStages()) { if (!hasStage(s.getName()) || !getStage(s.getName()).equals(s)) { return false; } } if ((getPropertiesModifiedDate() == null) != (g.getPropertiesModifiedDate() == null)) { return false; } else if (getPropertiesModifiedDate() == null && g.getPropertiesModifiedDate() == null) { return true; } return getPropertiesModifiedDate().equals(g.getPropertiesModifiedDate()); } return false; }
@Test public void shouldReturnLastSuccesfulLabel() throws Exception { StageIdentifier successfulStage = new StageIdentifier(pipeline.getName(), 1, "LABEL:1", stage.getName(), "1"); StageJsonPresentationModel presenter = new StageJsonPresentationModel(pipeline, stage, successfulStage, new Agents()); Map json = presenter.toJson(); new JsonTester(json) .shouldContain( "{ 'last_successful_label' : 'LABEL:1', 'last_successful_stage_locator' : '" + String.format("%s/%s/%s/%s", pipeline.getName(), "1", stage.getName(), "1") + "' }"); }
public Set<String> getStageNames() { HashSet<String> names = new HashSet<String>(); for (Stage stage : stages) { names.add(stage.getName()); } return names; }
public boolean isDependentOn(Stage stage, String stageName) { // depends on all stages except itself if (!stage.getName().equals(stageName)) { return true; } return false; }
public Stage getStage(String name) { for (Stage stage : stages) { if (stage.getName().equals(name)) { return stage; } } return null; }
private void assertPipelineScheduled(PipelineConfig config) { Stage evolveStage = stageDao.mostRecentWithBuilds( CaseInsensitiveString.str(config.name()), config.findBy(new CaseInsensitiveString("dev"))); assertThat(evolveStage.getName(), is("dev")); assertThat(evolveStage.getJobInstances().size(), is(1)); assertThat(evolveStage.getJobInstances().first().getState(), is(JobState.Scheduled)); }
public Stage removeStage(String stageName) { for (Stage stage : stages) { if (stage.getName().equals(stageName)) { stages.remove(stage); return stage; } } return null; }
private void assertPipelinesScheduled() { Pipeline minglePipeline = pipelineDao.mostRecentPipeline(CaseInsensitiveString.str(mingleConfig.name())); Stage mingleStage = minglePipeline.getFirstStage(); assertThat(mingleStage.getName(), is(STAGE_NAME)); assertThat(mingleStage.getJobInstances().size(), is(2)); JobInstance mingleJob = mingleStage.getJobInstances().first(); assertThat(mingleJob.getState(), is(JobState.Scheduled)); assertPipelineScheduled(evolveConfig); assertPipelineScheduled(goConfig); }
public Boolean isDependencySatisfied(Stage stage, ActiveInterviewService activeInterviewService) { // every other stages need to be completed except itself for (Module module : moduleRegistry.getModules()) { for (Stage oneStage : module.getStages()) { if (!stage.equals(oneStage)) { IStageExecution stageExecution = activeInterviewService.getStageExecution(oneStage.getName()); if (!stageExecution.isCompleted()) { // At least one stage is not complete, return null since log.debug( "Dependendant module {} not complete due to stage {}", module.getName(), oneStage.getName()); return null; } } } } return true; }
private int executeStage(Configuration configuration, Cluster cluster, int stageId) { Stage stage = masterConfig .getScenario() .getStage( stageId, state, getCurrentExtras(masterConfig, configuration, cluster), state.getReport()); InitHelper.init(stage); StageResult result; try { if (stage instanceof MasterStage) { result = executeMasterStage((MasterStage) stage); } else if (stage instanceof DistStage) { result = executeDistStage(stageId, (DistStage) stage); } else { log.error("Stage '" + stage.getName() + "' is neither master nor distributed"); return -1; } } finally { InitHelper.destroy(stage); } if (result == StageResult.SUCCESS) { return stageId + 1; } else if (result == StageResult.FAIL || result == StageResult.EXIT) { returnCode = masterConfig.getConfigurations().indexOf(configuration) + 1; if (result == StageResult.EXIT) { exitFlag = true; } return -1; } else if (result == StageResult.BREAK || result == StageResult.CONTINUE) { Stack<String> repeatNames = (Stack<String>) state.get(RepeatStage.REPEAT_NAMES); String nextLabel; if (repeatNames == null || repeatNames.isEmpty()) { log.warn("BREAK or CONTINUE used out of any repeat."); return -1; } else if (result == StageResult.BREAK) { nextLabel = Utils.concat(".", "repeat", repeatNames.peek(), "end"); } else if (result == StageResult.CONTINUE) { nextLabel = Utils.concat(".", "repeat", repeatNames.peek(), "begin"); } else throw new IllegalStateException(); int nextStageId = masterConfig.getScenario().getLabel(nextLabel); if (nextStageId < 0) { log.error("No label '" + nextLabel + "' defined"); } return nextStageId; } else { throw new IllegalStateException("Result does not match to any type."); } }
/** May return null if and only if a referenced stage library was not found in the database. */ public Set<DatabaseFile> getDatabaseFiles() { Map<Object, DatabaseFile> files = new HashMap<Object, DatabaseFile>(); for (Stage s : stages) { if (s.getDatabaseFile() == null) { logger.error("Stage group '" + s.getName() + "' is missing it's library file"); return null; } else if (!files.containsKey(s.getDatabaseFile().getId())) { files.put(s.getDatabaseFile().getId(), s.getDatabaseFile()); } } return new HashSet<DatabaseFile>(files.values()); }