Search in sources :

Example 6 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class CachedGoConfigIntegrationTest method shouldNotNotifyListenersWhenMergeFails.

@Test
public void shouldNotNotifyListenersWhenMergeFails() throws IOException {
    checkinPartial("config_repo_with_invalid_partial");
    ConfigRepoConfig configRepo = configWatchList.getCurrentConfigRepos().get(0);
    ConfigChangeListenerStub listener = new ConfigChangeListenerStub();
    cachedGoConfig.registerListener(listener);
    // at registration
    assertThat(listener.invocationCount, is(1));
    repoConfigDataSource.onCheckoutComplete(configRepo.getMaterialConfig(), externalConfigRepo, latestCommit);
    assertThat("currentConfigShouldBeMainXmlOnly", cachedGoConfig.currentConfig().hasPipelineNamed(new CaseInsensitiveString("pipeline_with_no_stage")), is(false));
    assertThat(listener.invocationCount, is(1));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig)

Example 7 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class GoFileConfigDataSourceTest method shouldNotRetryConfigUpdateIfLastKnownAndValidPartialsAreSame_OnWriteFullConfigWithLock.

@Test(expected = RuntimeException.class)
public void shouldNotRetryConfigUpdateIfLastKnownAndValidPartialsAreSame_OnWriteFullConfigWithLock() throws Exception {
    PartialConfig partialConfig1 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin"), "git_r1"));
    List<PartialConfig> known = asList(partialConfig1);
    List<PartialConfig> valid = asList(partialConfig1);
    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 GoConfigInvalidException(configForEdit, "error"));
    source.writeFullConfigWithLock(updatingCommand, configHolder);
}
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) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) Test(org.junit.Test)

Example 8 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig 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));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 9 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig 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 10 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class GoPartialConfigIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    goCache.clear();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    repoConfig1 = new ConfigRepoConfig(new GitMaterialConfig("url1"), "plugin");
    repoConfig2 = new ConfigRepoConfig(new GitMaterialConfig("url2"), "plugin");
    configHelper.addConfigRepo(repoConfig1);
    configHelper.addConfigRepo(repoConfig2);
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Before(org.junit.Before)

Aggregations

ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)54 Test (org.junit.Test)34 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)32 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)27 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)10 ConfigReposConfig (com.thoughtworks.go.config.remote.ConfigReposConfig)8 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)8 Before (org.junit.Before)8 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)6 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)6 File (java.io.File)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 AbstractMaterialConfig (com.thoughtworks.go.config.materials.AbstractMaterialConfig)4 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)4 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)4 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)4 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)4 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)3