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()));
}
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()));
}
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"));
}
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()));
}
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"));
}
Aggregations