use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldFindAllPipelineInstancesForGivenPipelineName.
@Test
public void shouldFindAllPipelineInstancesForGivenPipelineName() {
Pipeline pipeline = pipelineOne.createdPipelineWithAllStagesPassed();
configHelper.setViewPermissionForGroup("group1", "foo");
PipelineInstanceModels pipelineInstances = pipelineHistoryService.findAllPipelineInstances(pipeline.getName(), new Username(new CaseInsensitiveString("foo")), new HttpOperationResult());
assertThat(pipelineInstances.size(), is(1));
assertThat(pipelineInstances.first().getName(), is(pipeline.getName()));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class ScheduleStageTest method shouldFailWhenStageAlreadyActive.
@Test
public void shouldFailWhenStageAlreadyActive() {
Pipeline pipeline = fixture.createPipelineWithFirstStageScheduled();
Stage oldStage = pipeline.getStages().byName(fixture.devStage);
HttpOperationResult result = new HttpOperationResult();
Stage newStage = scheduleService.rerunJobs(oldStage, a("foo", "foo3"), result);
assertThat(result.canContinue(), is(false));
assertThat(result.message(), containsString("Pipeline[name='" + pipeline.getName() + "', counter='" + pipeline.getCounter() + "', label='" + pipeline.getLabel() + "'] is still in progress"));
assertThat(result.message(), containsString("Cannot schedule"));
assertThat(newStage, is(nullValue()));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class ScheduleStageTest method shouldConsiderCopyOfRerunJobACopyAndNotRerun.
@Test
public void shouldConsiderCopyOfRerunJobACopyAndNotRerun() {
Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
Stage stage = scheduleService.rerunStage(pipeline.getName(), pipeline.getCounter(), fixture.devStage);
assertThat(stage.hasRerunJobs(), is(false));
dbHelper.passStage(stage);
Stage oldStage = stageDao.stageById(pipeline.getStages().byName(fixture.devStage).getId());
assertThat(oldStage.hasRerunJobs(), is(false));
HttpOperationResult result = new HttpOperationResult();
Stage newStage = scheduleService.rerunJobs(oldStage, a("foo", "foo3"), result);
Stage loadedLatestStage = dbHelper.getStageDao().findStageWithIdentifier(newStage.getIdentifier());
assertThat(loadedLatestStage.hasRerunJobs(), is(true));
dbHelper.passStage(loadedLatestStage);
JobInstances jobsBeforeLatestRerunJobs = loadedLatestStage.getJobInstances();
newStage = scheduleService.rerunJobs(loadedLatestStage, a("foo2"), result);
loadedLatestStage = dbHelper.getStageDao().findStageWithIdentifier(newStage.getIdentifier());
assertThat(loadedLatestStage.getJobInstances().getByName("foo").getResult(), is(JobResult.Passed));
assertThat(loadedLatestStage.getJobInstances().getByName("foo").getState(), is(JobState.Completed));
assertThat(loadedLatestStage.getJobInstances().getByName("foo").getOriginalJobId(), is(jobsBeforeLatestRerunJobs.getByName("foo").getId()));
assertThat(loadedLatestStage.getJobInstances().getByName("foo").isRerun(), is(false));
assertThat(loadedLatestStage.getJobInstances().getByName("foo").isCopy(), is(true));
assertThat(loadedLatestStage.getJobInstances().getByName("foo2").getResult(), is(JobResult.Unknown));
assertThat(loadedLatestStage.getJobInstances().getByName("foo2").getState(), is(JobState.Scheduled));
assertThat(loadedLatestStage.getJobInstances().getByName("foo2").getOriginalJobId(), is(nullValue()));
assertThat(loadedLatestStage.getJobInstances().getByName("foo2").isRerun(), is(true));
assertThat(loadedLatestStage.getJobInstances().getByName("foo2").isCopy(), is(false));
assertThat(loadedLatestStage.getJobInstances().getByName("foo3").getResult(), is(JobResult.Passed));
assertThat(loadedLatestStage.getJobInstances().getByName("foo3").getState(), is(JobState.Completed));
assertThat(loadedLatestStage.getJobInstances().getByName("foo3").getOriginalJobId(), is(jobsBeforeLatestRerunJobs.getByName("foo3").getId()));
assertThat(loadedLatestStage.getJobInstances().getByName("foo3").isRerun(), is(false));
assertThat(loadedLatestStage.getJobInstances().getByName("foo3").isCopy(), is(true));
assertThat(loadedLatestStage, is(newStage));
assertThat(loadedLatestStage.hasRerunJobs(), is(true));
assertThat(loadedLatestStage.getCounter(), is(oldStage.getCounter() + 3));
assertThat(loadedLatestStage.getIdentifier().getPipelineCounter(), is(oldStage.getIdentifier().getPipelineCounter()));
assertThat(result.canContinue(), is(true));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class StageServiceIntegrationTest method findStageHistoryForChart_shouldNotRetrieveCancelledStagesAndStagesWithRerunJobs.
@Test
public void findStageHistoryForChart_shouldNotRetrieveCancelledStagesAndStagesWithRerunJobs() throws Exception {
PipelineConfig pipelineConfig = configFileHelper.addPipeline("pipeline-1", "stage-1");
configFileHelper.turnOffSecurity();
Pipeline pipeline = dbHelper.schedulePipelineWithAllStages(pipelineConfig, ModificationsMother.modifySomeFiles(pipelineConfig));
dbHelper.pass(pipeline);
StageSummaryModels stages = stageService.findStageHistoryForChart(pipelineConfig.name().toString(), pipelineConfig.first().name().toString(), 1, 10, new Username(new CaseInsensitiveString("loser")));
assertThat(stages.size(), is(1));
scheduleService.rerunJobs(pipeline.getFirstStage(), Arrays.asList(CaseInsensitiveString.str(pipelineConfig.first().getJobs().first().name())), new HttpOperationResult());
stages = stageService.findStageHistoryForChart(pipelineConfig.name().toString(), pipelineConfig.first().name().toString(), 1, 10, new Username(new CaseInsensitiveString("loser")));
// should not retrieve stages with rerun jobs
assertThat(stages.size(), is(1));
pipeline = dbHelper.schedulePipelineWithAllStages(pipelineConfig, ModificationsMother.modifySomeFiles(pipelineConfig));
dbHelper.cancelStage(pipeline.getFirstStage());
stages = stageService.findStageHistoryForChart(pipelineConfig.name().toString(), pipelineConfig.first().name().toString(), 1, 10, new Username(new CaseInsensitiveString("loser")));
// should not retrieve cancelled stages
assertThat(stages.size(), is(1));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldLoadPipelineInstanceWithMultipleRevisions.
@Test
public void shouldLoadPipelineInstanceWithMultipleRevisions() {
Pipeline pipeline = pipelineOne.createPipelineWithFirstStageScheduled(ModificationsMother.multipleModifications(pipelineOne.pipelineConfig()));
configHelper.setViewPermissionForGroup("group1", "foo");
PipelineInstanceModel pipelineInstance = pipelineHistoryService.load(pipeline.getId(), new Username(new CaseInsensitiveString("foo")), new HttpOperationResult());
assertThat(pipelineInstance, is(not(nullValue())));
assertThat(pipelineInstance.hasNewRevisions(), is(false));
}
Aggregations