Search in sources :

Example 6 with JobIdentifier

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

the class RestfulServiceTest method shouldShouldTranslateLatestPipelineLabel.

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

Example 7 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier 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 8 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier 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 9 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier 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 10 with JobIdentifier

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

the class ScheduleServiceCachedIntegrationTest method shouldUpdateResultOfStageWhenJobCompletes_irrespectiveOfOtherThreadsPrimingStageCache.

@Test
public void shouldUpdateResultOfStageWhenJobCompletes_irrespectiveOfOtherThreadsPrimingStageCache() throws Exception {
    Pipeline assigned = preCondition.createPipelineWithFirstStageAssigned();
    Stage stage = assigned.findStage(preCondition.devStage);
    StageSummaryModel model = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
    JobIdentifier identifier = stage.getFirstJob().getIdentifier();
    scheduleService.updateJobStatus(identifier, JobState.Building);
    scheduleService.jobCompleting(identifier, JobResult.Passed, "uuid");
    //priming the cache
    Stage stageLoadedByOtherFlows = stageDao.stageById(stage.getId());
    scheduleService.updateJobStatus(stage.getFirstJob().getIdentifier(), JobState.Completed);
    StageSummaryModel reloadedModel = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
    Stage reloadedStage = reloadedModel.getStage();
    assertThat(reloadedStage.getFirstJob().getState(), is(JobState.Completed));
    assertThat(reloadedStage.getCompletedByTransitionId(), is(reloadedStage.getFirstJob().getTransitions().byState(JobState.Completed).getId()));
    assertThat(reloadedStage.getResult(), is(StageResult.Passed));
    assertThat(reloadedStage.getState(), is(StageState.Passed));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) StageSummaryModel(com.thoughtworks.go.server.ui.StageSummaryModel) Stage(com.thoughtworks.go.domain.Stage) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)100 Test (org.junit.Test)74 JobInstance (com.thoughtworks.go.domain.JobInstance)17 Pipeline (com.thoughtworks.go.domain.Pipeline)16 File (java.io.File)15 DateTime (org.joda.time.DateTime)12 Stage (com.thoughtworks.go.domain.Stage)9 Before (org.junit.Before)8 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5 LogFile (com.thoughtworks.go.server.domain.LogFile)5 IllegalArtifactLocationException (com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)4 Property (com.thoughtworks.go.domain.Property)3 Username (com.thoughtworks.go.server.domain.Username)3 IOException (java.io.IOException)3 Expectations (org.jmock.Expectations)3 RunIf (com.googlecode.junit.ext.RunIf)2 Tabs (com.thoughtworks.go.config.Tabs)2 Properties (com.thoughtworks.go.domain.Properties)2