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));
}
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;
}
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));
}
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;
}
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;
}
Aggregations