Search in sources :

Example 36 with PartialConfig

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

the class PipelineConfigServiceIntegrationTest method shouldFallbackToValidPartialsForConfigChanges.

@Test
public void shouldFallbackToValidPartialsForConfigChanges() throws Exception {
    assertThat(goConfigService.getCurrentConfig().getAllPipelineNames().contains(new CaseInsensitiveString(remoteDownstreamPipelineName)), is(true));
    String remoteInvalidPipeline = "remote_invalid_pipeline";
    PartialConfig invalidPartial = PartialConfigMother.invalidPartial(remoteInvalidPipeline, new RepoConfigOrigin(repoConfig1, "repo1_r2"));
    goPartialConfig.onSuccessPartialConfig(repoConfig1, invalidPartial);
    assertThat(goConfigService.getCurrentConfig().getAllPipelineNames().contains(new CaseInsensitiveString(remoteInvalidPipeline)), is(false));
    assertThat(goConfigService.getCurrentConfig().getAllPipelineNames().contains(new CaseInsensitiveString(remoteDownstreamPipelineName)), is(true));
    String xml = new MagicalGoConfigXmlWriter(configCache, registry).toXmlPartial(pipelineConfig);
    String md5 = CachedDigestUtils.md5Hex(xml);
    pipelineConfig.getFirstStageConfig().getJobs().first().addTask(new ExecTask("executable", new Arguments(new Argument("foo")), "working"));
    pipelineConfigService.updatePipelineConfig(user, pipelineConfig, md5, result);
    assertThat(result.isSuccessful(), is(true));
    CruiseConfig currentConfig = goConfigService.getCurrentConfig();
    assertThat(currentConfig.getAllPipelineNames().contains(new CaseInsensitiveString(remoteDownstreamPipelineName)), is(true));
    assertThat(currentConfig.getAllPipelineNames().contains(new CaseInsensitiveString(remoteInvalidPipeline)), is(false));
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 37 with PartialConfig

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

the class GoFileConfigDataSource method areKnownPartialsSameAsValidPartials.

protected boolean areKnownPartialsSameAsValidPartials(List<PartialConfig> lastKnownPartials, List<PartialConfig> lastValidPartials) {
    if (lastKnownPartials.size() != lastValidPartials.size()) {
        return false;
    }
    final ArrayList<ConfigOrigin> validConfigOrigins = ListUtil.map(lastValidPartials, new ListUtil.Transformer<PartialConfig, ConfigOrigin>() {

        @Override
        public ConfigOrigin transform(PartialConfig partialConfig) {
            return partialConfig.getOrigin();
        }
    });
    PartialConfig invalidKnownPartial = ListUtil.find(lastKnownPartials, new ListUtil.Condition() {

        @Override
        public <T> boolean isMet(T item) {
            return !validConfigOrigins.contains(((PartialConfig) item).getOrigin());
        }
    });
    return invalidKnownPartial == null;
}
Also used : ConfigOrigin(com.thoughtworks.go.config.remote.ConfigOrigin) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig)

Example 38 with PartialConfig

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

the class ConfigRepoPartialPreprocessorTest method shouldMergePartialsSetOnConfig.

@Test
public void shouldMergePartialsSetOnConfig() {
    final PartialConfig partialConfig = PartialConfigMother.withPipeline("partial");
    partialConfig.setOrigin(new RepoConfigOrigin(configRepoConfig, "sha-1"));
    ConfigRepoPartialPreprocessor preprocessor = new ConfigRepoPartialPreprocessor();
    PipelineConfig pipelineInMain = PipelineConfigMother.createPipelineConfig("main_pipeline", "stage", "job");
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(pipelineInMain));
    cruiseConfig.setConfigRepos(reposConfig);
    cruiseConfig.setPartials(asList(partialConfig));
    preprocessor.process(cruiseConfig);
    assertThat(cruiseConfig.getAllPipelineNames().contains(pipelineInMain.name()), is(true));
    assertThat(cruiseConfig.getAllPipelineNames().contains(partialConfig.getGroups().first().get(0).name()), is(true));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) Test(org.junit.Test)

Example 39 with PartialConfig

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

the class PartialConfigMother method pipelineWithDependencyMaterial.

public static PartialConfig pipelineWithDependencyMaterial(String name, PipelineConfig upstream, RepoConfigOrigin repoConfig) {
    PartialConfig partialConfig = withPipeline(name, repoConfig);
    PipelineConfig pipeline = partialConfig.getGroups().first().get(0);
    pipeline.materialConfigs().add(new DependencyMaterialConfig(upstream.name(), upstream.first().name()));
    return partialConfig;
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 40 with PartialConfig

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

the class PartialConfigMother method invalidPartial.

public static PartialConfig invalidPartial(String name, RepoConfigOrigin repoOrigin) {
    PipelineConfig pipe = PipelineConfigMother.pipelineConfig(name);
    pipe.getFirstStageConfig().setName(new CaseInsensitiveString(""));
    BasicPipelineConfigs pipes = new BasicPipelineConfigs("grp", new Authorization(), pipe);
    PartialConfig partialConfig = new PartialConfig(new PipelineGroups(pipes));
    partialConfig.setOrigins(repoOrigin);
    return partialConfig;
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) 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