Search in sources :

Example 16 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class ScheduleServiceStageTriggerTest method cancelCurrentStageShouldNotTriggerSameStageInMostRecentPipelineWhenItIsScheduledAlready.

@Test
public void cancelCurrentStageShouldNotTriggerSameStageInMostRecentPipelineWhenItIsScheduledAlready() throws Exception {
    Pipeline oldest = preCondition.createPipelineWithFirstStagePassedAndSecondStageRunning();
    preCondition.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    preCondition.createdPipelineWithAllStagesPassed();
    long cancelledStageId = oldest.getStages().byName(preCondition.ftStage).getId();
    scheduleService.cancelAndTriggerRelevantStages(cancelledStageId, null, null);
    Pipeline mostRecent = pipelineService.mostRecentFullPipelineByName(preCondition.pipelineName);
    Stage cancelledStage = stageService.stageById(cancelledStageId);
    assertThat(cancelledStage.stageState(), is(StageState.Cancelled));
    assertThat(mostRecent.getStages().byName(preCondition.ftStage).stageState(), is(StageState.Passed));
}
Also used : Stage(com.thoughtworks.go.domain.Stage) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 17 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class ScheduleServiceStageTriggerTest method shouldNotRerunCurrentStageInNewerPipeline.

@Test
public void shouldNotRerunCurrentStageInNewerPipeline() throws Exception {
    Pipeline olderPipeline = preCondition.createdPipelineWithAllStagesPassed();
    Pipeline newerPipeline = preCondition.createdPipelineWithAllStagesPassed();
    Stage oldFtStage = newerPipeline.getStages().byName(preCondition.ftStage);
    schedulerFixture.rerunAndPassStage(olderPipeline, preCondition.ftStage());
    Stage passedFtStage = pipelineService.fullPipelineById(olderPipeline.getId()).getStages().byName(preCondition.ftStage);
    scheduleService.automaticallyTriggerRelevantStagesFollowingCompletionOf(passedFtStage);
    Stage ftStage = pipelineService.mostRecentFullPipelineByName(preCondition.pipelineName).getStages().byName(preCondition.ftStage);
    assertThat("Should not rerun ft in newer pipeline", ftStage.getId(), is(oldFtStage.getId()));
}
Also used : Stage(com.thoughtworks.go.domain.Stage) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 18 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class ScheduleServiceStageTriggerTest method shouldNotTriggerNextStageFromConfigIfItIsScheduled.

@Test
public void shouldNotTriggerNextStageFromConfigIfItIsScheduled() throws Exception {
    // having a pipeline with two stages both are completed
    Pipeline pipeline = preCondition.createdPipelineWithAllStagesPassed();
    Stage oldDevStage = pipeline.getStages().byName(preCondition.devStage);
    // now we reorder the two stages via config from dev -> ft to ft -> dev
    reOrderTwoStages();
    // and then rerun the ftstage
    schedulerFixture.rerunAndPassStage(pipeline, preCondition.ftStage());
    // after ftStage passes, it should NOT trigger dev stage again otherwise this will
    // ends up in a deadlock
    Stage ftStage = stageDao.mostRecentWithBuilds(preCondition.pipelineName, preCondition.ftStage());
    scheduleService.automaticallyTriggerRelevantStagesFollowingCompletionOf(ftStage);
    // verifying that devStage is NOT rerun
    Stage devStage = stageDao.mostRecentWithBuilds(preCondition.pipelineName, preCondition.devStage());
    assertThat("Should not schedule dev stage again", devStage.getId(), is(oldDevStage.getId()));
}
Also used : Stage(com.thoughtworks.go.domain.Stage) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 19 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class RestfulServiceTest method shouldTranslateLatestToRealStageCounter.

@Test
public void shouldTranslateLatestToRealStageCounter() throws Exception {
    Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
    JobIdentifier jobIdentifier = restfulService.findJob(pipeline.getName(), pipeline.getLabel(), fixture.devStage, JobIdentifier.LATEST, PipelineWithTwoStages.JOB_FOR_DEV_STAGE);
    assertThat(Integer.valueOf(jobIdentifier.getStageCounter()), is(pipeline.getStages().byName(fixture.devStage).getCounter()));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 20 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class RestfulServiceTest method shouldTranslateLatestToRealPipelineLabel.

@Test
public void shouldTranslateLatestToRealPipelineLabel() throws Exception {
    fixture.createdPipelineWithAllStagesPassed();
    Pipeline latestPipleine = fixture.createdPipelineWithAllStagesPassed();
    JobIdentifier jobIdentifier = restfulService.findJob(latestPipleine.getName(), JobIdentifier.LATEST, fixture.devStage, JobIdentifier.LATEST, PipelineWithTwoStages.JOB_FOR_DEV_STAGE);
    assertThat(jobIdentifier.getPipelineLabel(), is(latestPipleine.getLabel()));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Pipeline (com.thoughtworks.go.domain.Pipeline)177 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)55 Stage (com.thoughtworks.go.domain.Stage)40 JobInstance (com.thoughtworks.go.domain.JobInstance)26 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 Username (com.thoughtworks.go.server.domain.Username)17 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)16 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)14 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)12 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)12 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)11 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)10 ModelAndView (org.springframework.web.servlet.ModelAndView)10 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)9 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)9 Modification (com.thoughtworks.go.domain.materials.Modification)9 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)7 PipelineState (com.thoughtworks.go.domain.PipelineState)6 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)6