Search in sources :

Example 1 with ConfigRepoConfig

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

Example 2 with ConfigRepoConfig

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

Example 3 with ConfigRepoConfig

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));
}
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 4 with ConfigRepoConfig

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));
}
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 5 with ConfigRepoConfig

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 &quot;downstream&quot;"));
    // 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 &quot;pipe1&quot; does not exist. It is used from pipeline &quot;downstream&quot"));
    // 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));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) StringContains.containsString(org.hamcrest.core.StringContains.containsString) File(java.io.File)

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