use of com.thoughtworks.go.config.remote.PartialConfig 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.PartialConfig in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldEnsureMergeFlowWithLastKnownPartialsIfConfigHasChangedBetweenUpdates_OnWriteFullConfigWithLock.
@Test
public void shouldEnsureMergeFlowWithLastKnownPartialsIfConfigHasChangedBetweenUpdates_OnWriteFullConfigWithLock() throws Exception {
BasicCruiseConfig configForEdit = new BasicCruiseConfig();
MagicalGoConfigXmlLoader.setMd5(configForEdit, "new_md5");
FullConfigUpdateCommand updatingCommand = new FullConfigUpdateCommand(new BasicCruiseConfig(), "old_md5");
GoConfigHolder configHolder = new GoConfigHolder(new BasicCruiseConfig(), configForEdit);
List<PartialConfig> lastKnownPartials = mock(List.class);
CachedGoPartials cachedGoPartials = mock(CachedGoPartials.class);
GoFileConfigDataSource source = new GoFileConfigDataSource(null, null, systemEnvironment, null, null, null, null, null, cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow);
stub(cachedGoPartials.lastKnownPartials()).toReturn(lastKnownPartials);
stub(fullConfigSaveMergeFlow.execute(Matchers.any(FullConfigUpdateCommand.class), Matchers.any(List.class), Matchers.any(String.class))).toReturn(new GoConfigHolder(new BasicCruiseConfig(), new BasicCruiseConfig()));
source.writeFullConfigWithLock(updatingCommand, configHolder);
verify(fullConfigSaveMergeFlow).execute(updatingCommand, lastKnownPartials, "loser_boozer");
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTest method shouldTriggerMDUOfConfigRepoMaterialIfThePipelineIsDefinedRemotelyInAConfigRepo_ManualTriggerOfPipeline_EvenIfMDUOptionIsTurnedOFFInRequest.
@Test
public void shouldTriggerMDUOfConfigRepoMaterialIfThePipelineIsDefinedRemotelyInAConfigRepo_ManualTriggerOfPipeline_EvenIfMDUOptionIsTurnedOFFInRequest() throws Exception {
ConfigRepoConfig repoConfig = new ConfigRepoConfig(new GitMaterialConfig("url2"), "plugin");
configHelper.addConfigRepo(repoConfig);
PartialConfig partialConfig = PartialConfigMother.withPipelineMultipleMaterials("remote_pipeline", new RepoConfigOrigin(repoConfig, "4567"));
PipelineConfig remotePipeline = partialConfig.getGroups().first().getPipelines().get(0);
GitMaterial git = u.wf((GitMaterial) new MaterialConfigConverter().toMaterial(remotePipeline.materialConfigs().getGitMaterial()), "git");
u.checkinInOrder(git, u.d(1), "g1r1");
SvnMaterial svn = u.wf((SvnMaterial) new MaterialConfigConverter().toMaterial(remotePipeline.materialConfigs().getSvnMaterial()), "svn");
u.checkinInOrder(svn, u.d(1), "svn1r11");
GitMaterial configRepoMaterial = u.wf((GitMaterial) new MaterialConfigConverter().toMaterial(repoConfig.getMaterialConfig()), "git");
u.checkinInOrder(configRepoMaterial, u.d(1), "s1");
goPartialConfig.onSuccessPartialConfig(repoConfig, partialConfig);
assertTrue(goConfigService.hasPipelineNamed(remotePipeline.name()));
scheduleOptions.shouldPerformMDUBeforeScheduling(false);
service.manualSchedulePipeline(username, remotePipeline.name(), scheduleOptions, result);
assertThat(result.isSuccess(), is(true));
assertThat(result.message(), is("Request to schedule pipeline remote_pipeline accepted"));
assertThat(materialUpdateStatusNotifier.hasListenerFor(remotePipeline), is(true));
assertMDUPendingForMaterial(remotePipeline, configRepoMaterial);
assertMDUNotPendingForMaterial(remotePipeline, svn);
assertMDUNotPendingForMaterial(remotePipeline, git);
assertThat(triggerMonitor.isAlreadyTriggered(remotePipeline.name().toString()), Is.is(true));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(remotePipeline.name().toString());
assertNull(buildCause);
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class ConfigMaterialUpdaterIntegrationTest method shouldNotParseAgainWhenNoChangesInMaterial.
@Test
public void shouldNotParseAgainWhenNoChangesInMaterial() throws Exception {
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
String revision = goRepoConfigDataSource.getRevisionAtLastAttempt(materialConfig);
assertNotNull(revision);
PartialConfig partial = goRepoConfigDataSource.latestPartialConfigForMaterial(materialConfig);
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
PartialConfig partial2 = goRepoConfigDataSource.latestPartialConfigForMaterial(materialConfig);
assertSame(partial, partial2);
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class ConfigMaterialUpdaterIntegrationTest method shouldParseEmptyRepository.
@Test
public void shouldParseEmptyRepository() throws Exception {
materialUpdateService.updateMaterial(material);
waitForMaterialNotInProgress();
String revision = goRepoConfigDataSource.getRevisionAtLastAttempt(materialConfig);
assertNotNull(revision);
PartialConfig partial = goRepoConfigDataSource.latestPartialConfigForMaterial(materialConfig);
assertThat(partial.getGroups().size(), is(0));
assertThat(partial.getEnvironments().size(), is(0));
}
Aggregations