use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModifications.
@Test
public void shouldCreateBuildCauseWithModifications() throws Exception {
repositoryForMaterial(new SvnTestRepo(tempDir));
prepareAPipelineWithHistory();
checkInFiles("foo");
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
materialDatabaseUpdater.updateMaterial(svnMaterial);
buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
assertThat(result.canContinue(), is(true));
BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(mingleConfig.name());
MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
assertThat(materialRevisions.getRevisions().size(), is(1));
Materials materials = materialRevisions.getMaterials();
assertThat(materials.size(), is(1));
assertThat(materials.get(0), is(svnMaterial));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal.
@Test
public void shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal() throws Exception {
SvnTestRepoWithExternal repo = new SvnTestRepoWithExternal(tempDir);
repositoryForMaterial(repo);
prepareAPipelineWithHistory();
checkInFiles("foo");
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
materialDatabaseUpdater.updateMaterial(svnMaterial);
buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
assertThat(result.canContinue(), is(true));
BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(mingleConfig.name());
MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
assertThat(materialRevisions.getRevisions().size(), is(2));
Materials materials = materialRevisions.getMaterials();
assertThat(materials.size(), is(2));
assertThat(materials.get(0), is(svnMaterial));
SvnMaterial external = (SvnMaterial) materials.get(1);
assertThat(external.getUrl(), is(repo.externalRepositoryUrl()));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTimerTest method pipelineWithTimerShouldRerunWhenItHasAlreadyRunWithLatestMaterials_GivenTimerIsNOTSetToTriggerOnlyForNewMaterials.
@Test
public void pipelineWithTimerShouldRerunWhenItHasAlreadyRunWithLatestMaterials_GivenTimerIsNOTSetToTriggerOnlyForNewMaterials() throws Exception {
int i = 1;
String pipelineName = "p1";
GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder");
ScheduleTestUtil.AddedPipeline up1 = u.saveConfigWith("up1", u.m(git1));
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWithTimer(pipelineName, u.timer("* * * * * ? 2000", false), u.m(git1), u.m(up1));
u.checkinFile(git1, "g11", newFile(tempDir.resolve("blah_g11")), ModifiedAction.added);
String up1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up1, u.d(i++), "g11");
pipelineTimeline.update();
// Run once with latest, when pipeline schedules due to timer.
buildCauseProducerService.timerSchedulePipeline(p1.config, new ServerHealthStateOperationResult());
assertThat(piplineScheduleQueue.toBeScheduled().size(), is(1));
assertThat(piplineScheduleQueue.toBeScheduled().get(new CaseInsensitiveString(pipelineName)).getMaterialRevisions(), isSameMaterialRevisionsAs(u.mrs(u.mr(git1, true, "g11"), u.mr(up1, true, up1_1))));
BuildCause buildCause = piplineScheduleQueue.toBeScheduled().get(new CaseInsensitiveString(pipelineName));
String up1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up1, u.d(i++), "g11");
piplineScheduleQueue.finishSchedule(new CaseInsensitiveString(pipelineName), buildCause, buildCause);
try (LogFixture logFixture = logFixtureFor(TimedBuild.class, Level.INFO)) {
// Timer time comes around again. Will rerun since the new flag (runOnlyOnNewMaterials) is not ON.
buildCauseProducerService.timerSchedulePipeline(p1.config, new ServerHealthStateOperationResult());
assertThat(piplineScheduleQueue.toBeScheduled().size(), is(1));
assertThat(piplineScheduleQueue.toBeScheduled().get(new CaseInsensitiveString(pipelineName)).getMaterialRevisions(), is(u.mrs(u.mr(git1, false, "g11"), u.mr(up1, false, up1_2))));
assertThat(logFixture.contains(Level.INFO, "Skipping scheduling of timer-triggered pipeline 'p1' as it has previously run with the latest material(s)."), is(false));
}
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered.
@Test
public void shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered(@TempDir Path tempDir) throws Exception {
GitTestRepo otherGitRepo = new GitTestRepo(tempDir);
pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
pipelineConfig.materialConfigs().clear();
materialConfig = hgRepo.createMaterialConfig("dest1");
materialConfig.setAutoUpdate(true);
pipelineConfig.materialConfigs().add(materialConfig);
// new material is added
GitMaterial gitMaterial = otherGitRepo.createMaterial("dest2");
gitMaterial.setAutoUpdate(true);
MaterialConfig otherMaterialConfig = gitMaterial.config();
otherMaterialConfig.setAutoUpdate(true);
pipelineConfig.materialConfigs().add(otherMaterialConfig);
List<Modification> mod = configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
final HashMap<String, String> revisions = new HashMap<>();
final HashMap<String, String> environmentVariables = new HashMap<>();
buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
cachedGoConfig.throwExceptionIfExists();
Map<CaseInsensitiveString, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(20);
assertThat(afterLoad.keySet(), hasItem(new CaseInsensitiveString(PIPELINE_NAME)));
BuildCause cause = afterLoad.get(new CaseInsensitiveString(PIPELINE_NAME));
assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
PipelineConfig pipelineConfigAfterSchedule = goConfigService.pipelineConfigNamed(pipelineConfig.name());
RepoConfigOrigin configOriginAfterSchedule = (RepoConfigOrigin) pipelineConfigAfterSchedule.getOrigin();
String lastPushedRevision = mod.get(0).getRevision();
assertThat("revisionOfPipelineConfigOriginShouldMatchLastPushedCommit", configOriginAfterSchedule.getRevision(), is(lastPushedRevision));
assertThat(pipelineConfig.materialConfigs(), hasItem(otherMaterialConfig));
assertThat("buildCauseRevisionShouldMatchLastPushedCommit", cause.getMaterialRevisions().latestRevision(), is(lastPushedRevision));
// update of commited material happened during manual trigger
MaterialRevisions modificationsInDb = materialRepository.findLatestModification(gitMaterial);
assertThat(modificationsInDb.latestRevision(), is(otherGitRepo.latestModification().get(0).getRevision()));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldSchedulePipeline.
@Test
public void shouldSchedulePipeline() throws Exception {
configTestRepo.addCodeToRepositoryAndPush("a.java", "added code file", "some java code");
materialUpdateService.updateMaterial(material);
waitForMaterialNotInProgress();
buildCauseProducerService.autoSchedulePipeline(PIPELINE_NAME, new ServerHealthStateOperationResult(), 123);
assertThat(scheduleHelper.waitForAnyScheduled(5).keySet(), hasItem(new CaseInsensitiveString(PIPELINE_NAME)));
}
Aggregations