use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class BuildCauseTest method shouldNotThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenManualTrigger.
@Test
public void shouldNotThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenManualTrigger() {
SvnMaterial material = MaterialsMother.svnMaterial();
MaterialConfig materialConfig = material.config();
MaterialRevisions first = new MaterialRevisions(new MaterialRevision(material, oneModifiedFile("revision1")));
BuildCause buildCause = BuildCause.createManualForced();
buildCause.setMaterialRevisions(first);
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build");
pipelineConfig.materialConfigs().clear();
pipelineConfig.materialConfigs().add(materialConfig);
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig, "plug"), "revision2"));
buildCause.assertPipelineConfigAndMaterialRevisionMatch(pipelineConfig);
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class BuildCauseTest method shouldThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenAutoTrigger.
@Test
public void shouldThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenAutoTrigger() {
SvnMaterial material = MaterialsMother.svnMaterial();
MaterialConfig materialConfig = material.config();
MaterialRevisions first = new MaterialRevisions(new MaterialRevision(material, oneModifiedFile("revision1")));
BuildCause buildCause = BuildCause.createWithModifications(first, "");
buildCause.setMaterialRevisions(first);
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build");
pipelineConfig.materialConfigs().clear();
pipelineConfig.materialConfigs().add(materialConfig);
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig, "plug"), "revision2"));
try {
buildCause.assertPipelineConfigAndMaterialRevisionMatch(pipelineConfig);
} catch (BuildCauseOutOfDateException ex) {
//good
return;
}
fail("should have thrown");
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig 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.ConfigRepoConfig 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.ConfigRepoConfig in project gocd by gocd.
the class CachedGoConfigIntegrationTest method shouldRecoverFromDeepConfigRepoReferencesBug1901When3Repos.
@Test
public void shouldRecoverFromDeepConfigRepoReferencesBug1901When3Repos() throws Exception {
// pipeline references are like this: pipe1 -> downstream -> downstream2
File secondDownstreamExternalConfigRepo = temporaryFolder.newFolder();
/*here is a pipeline 'downstream2' with material dependency on 'downstream' in other repository*/
String secondDownstreamLatestCommit = setupExternalConfigRepo(secondDownstreamExternalConfigRepo, "external_git_config_repo_referencing_second");
configHelper.addConfigRepo(new ConfigRepoConfig(new GitMaterialConfig(secondDownstreamExternalConfigRepo.getAbsolutePath()), "gocd-xml"));
File firstDownstreamExternalConfigRepo = temporaryFolder.newFolder();
/*here is a pipeline 'downstream' with material dependency on 'pipe1' in other repository*/
String firstDownstreamLatestCommit = setupExternalConfigRepo(firstDownstreamExternalConfigRepo, "external_git_config_repo_referencing_first");
configHelper.addConfigRepo(new ConfigRepoConfig(new GitMaterialConfig(firstDownstreamExternalConfigRepo.getAbsolutePath()), "gocd-xml"));
goConfigService.forceNotifyListeners();
ConfigRepoConfig firstDownstreamConfigRepo = configWatchList.getCurrentConfigRepos().get(1);
ConfigRepoConfig secondDownstreamConfigRepo = configWatchList.getCurrentConfigRepos().get(2);
assertThat(configWatchList.getCurrentConfigRepos().size(), is(3));
// And unluckily downstream2 gets parsed first
repoConfigDataSource.onCheckoutComplete(secondDownstreamConfigRepo.getMaterialConfig(), secondDownstreamExternalConfigRepo, secondDownstreamLatestCommit);
// So parsing fails and proper message is shown:
List<ServerHealthState> messageForInvalidMerge = serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(secondDownstreamConfigRepo));
assertThat(messageForInvalidMerge.isEmpty(), is(false));
assertThat(messageForInvalidMerge.get(0).getDescription(), containsString("tries to fetch artifact from pipeline "downstream""));
// and current config is still old
assertThat(goConfigService.hasPipelineNamed(new CaseInsensitiveString("downstream2")), is(false));
assertThat(cachedGoPartials.lastKnownPartials().size(), is(1));
assertThat(cachedGoPartials.lastValidPartials().size(), is(0));
//here downstream2 partial is waiting to be merged
assertThat(cachedGoPartials.lastKnownPartials().get(0).getGroups().get(0).hasPipeline(new CaseInsensitiveString("downstream2")), is(true));
// Then middle upstream config repository is parsed
repoConfigDataSource.onCheckoutComplete(firstDownstreamConfigRepo.getMaterialConfig(), firstDownstreamExternalConfigRepo, firstDownstreamLatestCommit);
// and errors are still shown
messageForInvalidMerge = serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(firstDownstreamConfigRepo));
assertThat(messageForInvalidMerge.isEmpty(), is(false));
assertThat(messageForInvalidMerge.get(0).getDescription(), containsString("Pipeline "pipe1" does not exist. It is used from pipeline "downstream""));
// and current config is still old
assertThat(goConfigService.hasPipelineNamed(new CaseInsensitiveString("downstream")), is(false));
assertThat(goConfigService.hasPipelineNamed(new CaseInsensitiveString("downstream2")), is(false));
assertThat(cachedGoPartials.lastKnownPartials().size(), is(2));
assertThat(cachedGoPartials.lastValidPartials().size(), is(0));
// Finally upstream config repository is parsed
repoConfigDataSource.onCheckoutComplete(configRepo.getMaterialConfig(), externalConfigRepo, latestCommit);
// now server should be healthy and contain all pipelines
assertThat(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(firstDownstreamConfigRepo)).isEmpty(), is(true));
assertThat(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(secondDownstreamConfigRepo)).isEmpty(), is(true));
assertThat(cachedGoConfig.currentConfig().hasPipelineNamed(new CaseInsensitiveString("pipe1")), is(true));
assertThat(cachedGoConfig.currentConfig().hasPipelineNamed(new CaseInsensitiveString("downstream")), is(true));
assertThat(cachedGoConfig.currentConfig().hasPipelineNamed(new CaseInsensitiveString("downstream2")), is(true));
}
Aggregations