use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class CcTrayBreakersCalculatorTest method shouldCaptureAuthorNamesOfUnchangedRevisionsIfThereAreNoChangedRevisions.
@Test
public void shouldCaptureAuthorNamesOfUnchangedRevisionsIfThereAreNoChangedRevisions() throws Exception {
Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
Modification user2Commit = ModificationsMother.checkinWithComment("124", "comment 2", "user2", "user2@domain2.com", new Date(), "bar.c");
MaterialRevision firstUnchangedRevision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit, user2Commit);
Modification user3Commit = ModificationsMother.checkinWithComment("125", "comment 1", "user3", "user3@domain2.com", new Date(), "bar.c");
MaterialRevision secondUnchangedRevision = new MaterialRevision(MaterialsMother.gitMaterial("bar.com"), user3Commit);
MaterialRevisions revisions = new MaterialRevisions(firstUnchangedRevision, secondUnchangedRevision);
when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(revisions);
CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
Set<String> actualBreakers = status.calculateFor(failedStage());
assertThat(actualBreakers, is(s("user1", "user2", "user3")));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class CcTrayBreakersCalculatorTest method shouldNotHaveAnyBreakersIfStageHasNotFailed.
@Test
public void shouldNotHaveAnyBreakersIfStageHasNotFailed() throws Exception {
Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
MaterialRevision revision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit);
revision.markAsChanged();
MaterialRevisions revisions = new MaterialRevisions(revision);
when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(revisions);
CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
Set<String> actualBreakers = status.calculateFor(StageMother.createPassedStage("pipeline1", 1, "stage1", 1, "job1", new Date()));
assertThat(actualBreakers, is(Collections.<String>emptySet()));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered.
@Test
public void shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered() throws Exception {
GitTestRepo otherGitRepo = new GitTestRepo(temporaryFolder);
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<String, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(20);
assertThat(afterLoad.keySet(), hasItem(PIPELINE_NAME));
BuildCause cause = afterLoad.get(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.domain.MaterialRevisions in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTest method shouldUnderstandChangedMaterial_forManual_triggerWithOptions_DoneWithANewRevision.
@Test
public void shouldUnderstandChangedMaterial_forManual_triggerWithOptions_DoneWithANewRevision() throws Exception {
SvnMaterial svn = SvnMaterial.createSvnMaterialWithMock(repository);
MaterialRevisions revsAfterFoo = checkinFile(svn, "foo.c", svnRepository);
String revisionForFingerPrint = revsAfterFoo.findRevisionForFingerPrint(svn.getFingerprint()).getRevision().getRevision();
scheduleHelper.manuallySchedulePipelineWithRealMaterials(MINGLE_PIPELINE_NAME, new Username(new CaseInsensitiveString("loser")), m(new MaterialConfigConverter().toMaterial(mingleConfig.materialConfigs().get(0)).getPipelineUniqueFingerprint(), revisionForFingerPrint));
assertThat(pipelineScheduleQueue.toBeScheduled().keySet(), hasItem(MINGLE_PIPELINE_NAME));
BuildCause bisectAfterBisectBuildCause = pipelineScheduleQueue.toBeScheduled().get(MINGLE_PIPELINE_NAME);
for (MaterialRevision materialRevision : bisectAfterBisectBuildCause.getMaterialRevisions()) {
assertThat("material revision " + materialRevision + " should have been considered changed.", materialRevision.isChanged(), is(true));
}
assertThat(bisectAfterBisectBuildCause.getMaterialRevisions().getRevisions().size(), is(1));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTest method setup.
@Before
public void setup() throws Exception {
diskSpaceSimulator = new DiskSpaceSimulator();
new HgTestRepo("testHgRepo", temporaryFolder);
svnRepository = new SvnTestRepo(temporaryFolder);
dbHelper.onSetUp();
configHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
repository = new SvnCommand(null, svnRepository.projectRepositoryUrl());
PipelineConfig goParentPipelineConfig = configHelper.addPipeline(GO_PIPELINE_UPSTREAM, STAGE_NAME, new MaterialConfigs(new GitMaterialConfig("foo-bar")), "unit");
goPipelineConfig = configHelper.addPipeline(GO_PIPELINE_NAME, STAGE_NAME, repository, "unit");
svnMaterialRevs = new MaterialRevisions();
svnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
svnMaterialRevs.addRevision(svnMaterial, svnMaterial.latestModification(null, new ServerSubprocessExecutionContext(goConfigService, new SystemEnvironment())));
final MaterialRevisions materialRevisions = new MaterialRevisions();
SvnMaterial anotherSvnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
materialRevisions.addRevision(anotherSvnMaterial, anotherSvnMaterial.latestModification(null, subprocessExecutionContext));
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
materialRepository.save(svnMaterialRevs);
}
});
BuildCause buildCause = BuildCause.createWithModifications(svnMaterialRevs, "");
mingleConfig = configHelper.addPipeline(MINGLE_PIPELINE_NAME, STAGE_NAME, repository, new Filter(new IgnoredFiles("**/*.doc")), "unit", "functional");
latestPipeline = PipelineMother.schedule(this.mingleConfig, buildCause);
latestPipeline = pipelineDao.saveWithStages(latestPipeline);
dbHelper.passStage(latestPipeline.getStages().first());
pipelineScheduleQueue.clear();
result = new HttpOperationResult();
scheduleOptions = new ScheduleOptions();
u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
materialForManualTriggerPipeline = u.wf(new SvnMaterial("svn", "username", "password", false), "folder1");
u.checkinInOrder(materialForManualTriggerPipeline, u.d(1), "s1");
manualTriggerPipeline = configHelper.addPipeline(UUID.randomUUID().toString(), STAGE_NAME, materialForManualTriggerPipeline.config(), "build");
username = Username.ANONYMOUS;
}
Aggregations