Search in sources :

Example 96 with Pipeline

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

the class SchedulingCheckerServiceIntegrationTest method shouldNotScheduleStageInLockedPipelineIfAnyStageIsActiveInAnyPipeline.

@Test
public void shouldNotScheduleStageInLockedPipelineIfAnyStageIsActiveInAnyPipeline() throws Exception {
    Pipeline completed = pipelineFixture.createdPipelineWithAllStagesPassed();
    Pipeline pipeline = pipelineFixture.createPipelineWithFirstStagePassedAndSecondStageRunning();
    configFileHelper.lockPipeline(pipeline.getName());
    //to ensure locking happens(fixture uses the dao to directly save it to the db, hence lock is not taken)
    pipelineService.save(pipeline);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    schedulingChecker.canScheduleStage(completed.getIdentifier(), pipelineFixture.stageName(1), APPROVED_USER, result);
    assertThat(result.getServerHealthState().isSuccess(), is(false));
    assertThat(result.getServerHealthState().getDescription(), containsString("is locked"));
    assertThat(result.getServerHealthState().getDescription(), containsString(pipeline.getName()));
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 97 with Pipeline

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

the class StageIntegrationTest method createPipelineWithFirstStageBuilding.

private Pipeline createPipelineWithFirstStageBuilding() throws StageAlreadyBuildingException {
    Pipeline scheduledPipeline = schedulePipeline();
    dbHelper.saveBuildingStage(scheduledPipeline.getFirstStage());
    return pipelineDao.mostRecentPipeline(CaseInsensitiveString.str(mingle.name()));
}
Also used : Pipeline(com.thoughtworks.go.domain.Pipeline)

Example 98 with Pipeline

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

the class StageNotificationServiceIntegrationTest method shouldSendEmailWhenStageFixed.

@Test
public void shouldSendEmailWhenStageFixed() throws SQLException {
    String jezMail = prepareOneMatchedUser(StageEvent.Fixed);
    Pipeline pipeline = pipelineFixture.createdPipelineWithAllStagesCompleted(JobResult.Failed);
    Stage ftStage = mockStageServiceWithStage(pipeline);
    stageNotificationListener.onMessage(new StageResultMessage(ftStage.getIdentifier(), StageEvent.Fixed, Username.BLANK));
    String subject = "Stage [" + ftStage.getIdentifier().stageLocator() + "]" + " is fixed";
    assertThat(inMemoryEmailNotificationTopic.getSubject(jezMail), is(subject));
    assertThat(inMemoryEmailNotificationTopic.getBody(jezMail), containsString("Sent by Go on behalf of jez"));
}
Also used : StageResultMessage(com.thoughtworks.go.server.messaging.StageResultMessage) Stage(com.thoughtworks.go.domain.Stage) StringContains.containsString(org.hamcrest.core.StringContains.containsString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 99 with Pipeline

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

the class MaterialDatabaseDependencyUpdaterIntegrationTest method shouldInsertAllRunsAfterLastKnownOfUpstreamStage.

@Test
public void shouldInsertAllRunsAfterLastKnownOfUpstreamStage() throws Exception {
    PipelineConfig mingleConfig = PipelineConfigMother.createPipelineConfig("acceptance", "stage-name", "job");
    goConfigService.addPipeline(mingleConfig, "pipeline-group");
    Pipeline passed1 = dbHelper.schedulePipeline(mingleConfig, new TimeProvider());
    dbHelper.passStage(passed1.getStages().get(0));
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("acceptance"), new CaseInsensitiveString("stage-name"));
    String revision1 = String.format("acceptance/%s/stage-name/1", passed1.getCounter());
    updater.updateMaterial(dependencyMaterial);
    assertThat(materialRepository.findModificationWithRevision(dependencyMaterial, revision1), is(not(nullValue())));
    Pipeline cancelledPipeline = dbHelper.schedulePipeline(mingleConfig, new TimeProvider());
    dbHelper.cancelStage(cancelledPipeline.getStages().get(0));
    Pipeline passed2 = dbHelper.schedulePipeline(mingleConfig, new TimeProvider());
    dbHelper.passStage(passed2.getStages().get(0));
    updater.updateMaterial(dependencyMaterial);
    assertThat(materialRepository.findModificationWithRevision(dependencyMaterial, String.format("acceptance/%s/stage-name/1", cancelledPipeline.getCounter())), is(nullValue()));
    Modification modification1 = materialRepository.findModificationWithRevision(dependencyMaterial, revision1);
    assertThat(modification1, is(not(nullValue())));
    assertThat(modification1.getRevision(), is(revision1));
    assertThat(modification1.getPipelineLabel(), is(passed1.getCounter().toString()));
    assertThat(modification1.getPipelineId(), is(passed1.getId()));
    String revision2 = String.format("acceptance/%s/stage-name/1", passed2.getCounter());
    Modification modification2 = materialRepository.findModificationWithRevision(dependencyMaterial, revision2);
    assertThat(modification2, is(not(nullValue())));
    assertThat(modification2.getRevision(), is(revision2));
    assertThat(modification2.getPipelineLabel(), is(passed2.getCounter().toString()));
    assertThat(modification2.getPipelineId(), is(passed2.getId()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 100 with Pipeline

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

the class PropertyDaoTest method shouldLoadPropertiesHistoryLimitToSpecifiedCount.

@Test
public void shouldLoadPropertiesHistoryLimitToSpecifiedCount() throws Exception {
    Pipeline oldPipeline = createPipelineWithJobProperty(PIPELINE1, property("key1", "value1"));
    Pipeline newPipeline = createPipelineWithJobProperty(PIPELINE1, property("key2", "value2"));
    List<Properties> history = propertyDao.loadHistory(PIPELINE1, STAGE1, PLAN1, newPipeline.getId(), 1);
    assertThat(history.size(), is(1));
    assertThat(history.get(0).toString(), history.get(0).getValue("key2"), is("value2"));
    history = propertyDao.loadHistory(PIPELINE1, STAGE1, PLAN1, newPipeline.getId(), Integer.MAX_VALUE);
    assertThat(history.size(), is(2));
    assertThat(history.get(0).toString(), history.get(0).getValue("key1"), is("value1"));
    assertThat(history.get(1).toString(), history.get(1).getValue("key2"), is("value2"));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Pipeline (com.thoughtworks.go.domain.Pipeline)208 Test (org.junit.Test)155 Stage (com.thoughtworks.go.domain.Stage)62 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)34 Username (com.thoughtworks.go.server.domain.Username)34 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)30 JobInstance (com.thoughtworks.go.domain.JobInstance)27 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)27 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)22 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)21 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)16 Modification (com.thoughtworks.go.domain.materials.Modification)14 Date (java.util.Date)14 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)13 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)12 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)12 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)11 TimeProvider (com.thoughtworks.go.util.TimeProvider)9 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)8 TransactionStatus (org.springframework.transaction.TransactionStatus)8