Search in sources :

Example 11 with Pipeline

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

the class RestfulServiceTest method shouldReturnLatestJobWhenMultiplePipelinesWithSameLabel.

@Test
public void shouldReturnLatestJobWhenMultiplePipelinesWithSameLabel() throws Exception {
    configHelper.setPipelineLabelTemplate(fixture.pipelineName, "label-${COUNT}");
    Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
    Pipeline newPipeline = createPipelineWithSameLabelButNoCounter(pipeline);
    Stage stage = newPipeline.getStages().byName(fixture.devStage);
    JobInstance job = stage.getJobInstances().first();
    JobIdentifier result = restfulService.findJob(newPipeline.getName(), newPipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter()), job.getName(), null);
    JobIdentifier expect = new JobIdentifier(pipeline, stage, job);
    assertThat(result, is(expect));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stage(com.thoughtworks.go.domain.Stage) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 12 with Pipeline

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

the class RestfulServiceTest method shouldReturnJobWithJobIdWhenSpecifyPipelineCounter.

@Test
public void shouldReturnJobWithJobIdWhenSpecifyPipelineCounter() throws Exception {
    configHelper.setPipelineLabelTemplate(fixture.pipelineName, "label-${COUNT}");
    Pipeline oldPipeline = fixture.createdPipelineWithAllStagesPassed();
    fixture.createdPipelineWithAllStagesPassed();
    Stage stage = oldPipeline.getStages().byName(fixture.devStage);
    JobInstance job = stage.getJobInstances().first();
    JobIdentifier result = restfulService.findJob(oldPipeline.getName(), String.valueOf(oldPipeline.getCounter()), stage.getName(), String.valueOf(stage.getCounter()), job.getName(), null);
    JobIdentifier expect = new JobIdentifier(oldPipeline, stage, job);
    assertThat(result, is(expect));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stage(com.thoughtworks.go.domain.Stage) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 13 with Pipeline

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

the class RestfulServiceTest method canSupportQueryingUsingStageNameWithDifferentCase.

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

Example 14 with Pipeline

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

the class ScheduleServiceCachedIntegrationTest method shouldUseLatestStageStateInsteadOfCachedWhenScheduling.

@Test
public // #2296
void shouldUseLatestStageStateInsteadOfCachedWhenScheduling() throws Exception {
    assertThat(currentActivityService.isStageActive(preCondition.pipelineName, preCondition.devStage), is(false));
    Pipeline pipeline0 = pipelineService.mostRecentFullPipelineByName(preCondition.pipelineName);
    Pipeline pipeline1 = tryToScheduleAPipeline();
    assertThat("we should be able to schedule a pipeline when its first stage is inactive", pipeline0.getId(), is(not(pipeline1.getId())));
    Pipeline pipeline2 = tryToScheduleAPipeline();
    assertThat("we should NOT schedule the pipeline again when its first stage is active", pipeline2.getId(), is(pipeline1.getId()));
}
Also used : Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 15 with Pipeline

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

the class ScheduleServiceStageTriggerTest method cancelCurrentStageShouldTriggerSameStageInMostRecentPipeline.

@Test
public void cancelCurrentStageShouldTriggerSameStageInMostRecentPipeline() throws Exception {
    Pipeline oldest = preCondition.createPipelineWithFirstStagePassedAndSecondStageRunning();
    preCondition.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    preCondition.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    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.Building));
}
Also used : Stage(com.thoughtworks.go.domain.Stage) 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