use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldReturnFalseWhenValidPartialsListIsNotTheSameAsKnownPartialList.
@Test
public void shouldReturnFalseWhenValidPartialsListIsNotTheSameAsKnownPartialList() {
PartialConfig partialConfig1 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin"), "git_r1"));
PartialConfig partialConfig2 = PartialConfigMother.withPipeline("p2", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.svnMaterialConfig(), "plugin"), "svn_r1"));
PartialConfig partialConfig3 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin"), "git_r2"));
PartialConfig partialConfig4 = PartialConfigMother.withPipeline("p2", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.svnMaterialConfig(), "plugin"), "svn_r2"));
List<PartialConfig> known = asList(partialConfig1, partialConfig2);
List<PartialConfig> valid = asList(partialConfig3, partialConfig4);
assertThat(dataSource.areKnownPartialsSameAsValidPartials(known, valid), is(false));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldReturnFalseWhenValidPartialsListIsEmptyWhenKnownListIsNot.
@Test
public void shouldReturnFalseWhenValidPartialsListIsEmptyWhenKnownListIsNot() {
ConfigRepoConfig repo1 = new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin");
ConfigRepoConfig repo2 = new ConfigRepoConfig(MaterialConfigsMother.svnMaterialConfig(), "plugin");
PartialConfig partialConfig1 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(repo1, "git_r1"));
PartialConfig partialConfig2 = PartialConfigMother.withPipeline("p2", new RepoConfigOrigin(repo2, "svn_r1"));
List<PartialConfig> known = asList(partialConfig1, partialConfig2);
List<PartialConfig> valid = new ArrayList<>();
assertThat(dataSource.areKnownPartialsSameAsValidPartials(known, valid), is(false));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldReturnTrueWhenValidPartialsListIsSameAsKnownPartialList.
@Test
public void shouldReturnTrueWhenValidPartialsListIsSameAsKnownPartialList() {
ConfigRepoConfig repo1 = new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin");
ConfigRepoConfig repo2 = new ConfigRepoConfig(MaterialConfigsMother.svnMaterialConfig(), "plugin");
PartialConfig partialConfig1 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(repo1, "git_r1"));
PartialConfig partialConfig2 = PartialConfigMother.withPipeline("p2", new RepoConfigOrigin(repo2, "svn_r1"));
List<PartialConfig> known = asList(partialConfig1, partialConfig2);
List<PartialConfig> valid = asList(partialConfig1, partialConfig2);
assertThat(dataSource.areKnownPartialsSameAsValidPartials(known, valid), is(true));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldFallbackOnLastValidPartialsIfUpdateWithLastKnownPartialsFails_OnWriteFullConfigWithLock.
@Test
public void shouldFallbackOnLastValidPartialsIfUpdateWithLastKnownPartialsFails_OnWriteFullConfigWithLock() throws Exception {
PartialConfig partialConfig1 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin"), "git_r1"));
PartialConfig partialConfig2 = PartialConfigMother.withPipeline("p2", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.svnMaterialConfig(), "plugin"), "svn_r1"));
List<PartialConfig> known = asList(partialConfig1);
List<PartialConfig> valid = asList(partialConfig2);
BasicCruiseConfig configForEdit = new BasicCruiseConfig();
MagicalGoConfigXmlLoader.setMd5(configForEdit, "md5");
FullConfigUpdateCommand updatingCommand = new FullConfigUpdateCommand(new BasicCruiseConfig(), "md5");
GoConfigHolder configHolder = new GoConfigHolder(new BasicCruiseConfig(), configForEdit);
CachedGoPartials cachedGoPartials = mock(CachedGoPartials.class);
GoFileConfigDataSource source = new GoFileConfigDataSource(null, null, systemEnvironment, null, null, null, null, null, cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow);
stub(cachedGoPartials.lastKnownPartials()).toReturn(known);
stub(cachedGoPartials.lastValidPartials()).toReturn(valid);
when(fullConfigSaveNormalFlow.execute(updatingCommand, known, "loser_boozer")).thenThrow(new Exception());
when(fullConfigSaveNormalFlow.execute(updatingCommand, valid, "loser_boozer")).thenReturn(new GoConfigHolder(new BasicCruiseConfig(), new BasicCruiseConfig()));
source.writeFullConfigWithLock(updatingCommand, configHolder);
verify(fullConfigSaveNormalFlow).execute(updatingCommand, known, "loser_boozer");
verify(fullConfigSaveNormalFlow).execute(updatingCommand, valid, "loser_boozer");
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin 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()));
}
Aggregations