Search in sources :

Example 56 with HttpOperationResult

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()));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Example 57 with HttpOperationResult

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()));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Test(org.junit.jupiter.api.Test)

Example 58 with HttpOperationResult

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));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Test(org.junit.jupiter.api.Test)

Example 59 with HttpOperationResult

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));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) StageSummaryModels(com.thoughtworks.go.server.ui.StageSummaryModels) Test(org.junit.jupiter.api.Test)

Example 60 with HttpOperationResult

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));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Aggregations

HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)146 Test (org.junit.jupiter.api.Test)64 Test (org.junit.Test)53 Username (com.thoughtworks.go.server.domain.Username)34 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 TriStateSelection (com.thoughtworks.go.presentation.TriStateSelection)12 Pagination (com.thoughtworks.go.server.util.Pagination)7 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)6 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)6 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)6 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)6 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 NullStage (com.thoughtworks.go.domain.NullStage)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 PipelineStatusModel (com.thoughtworks.go.presentation.PipelineStatusModel)4 Stage (com.thoughtworks.go.domain.Stage)3