Search in sources :

Example 31 with PartialConfig

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");
}
Also used : FullConfigUpdateCommand(com.thoughtworks.go.config.update.FullConfigUpdateCommand) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) ConfigFileHasChangedException(com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) ExpectedException(org.junit.rules.ExpectedException) ConfigMergeException(com.thoughtworks.go.config.exceptions.ConfigMergeException) IOException(java.io.IOException) Test(org.junit.Test)

Example 32 with PartialConfig

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");
}
Also used : FullConfigUpdateCommand(com.thoughtworks.go.config.update.FullConfigUpdateCommand) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) Arrays.asList(java.util.Arrays.asList) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 33 with PartialConfig

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);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) GoPartialConfig(com.thoughtworks.go.config.GoPartialConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 34 with PartialConfig

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);
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig)

Example 35 with PartialConfig

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));
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig)

Aggregations

PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)70 Test (org.junit.Test)39 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)29 File (java.io.File)15 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)12 StringContains.containsString (org.hamcrest.core.StringContains.containsString)12 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)10 IOException (java.io.IOException)8 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)8 ExpectedException (org.junit.rules.ExpectedException)8 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)7 PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)7 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)7 Cloner (com.rits.cloning.Cloner)6 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)6 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)5 ConfigFileHasChangedException (com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException)4 ConfigMergeException (com.thoughtworks.go.config.exceptions.ConfigMergeException)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3