Search in sources :

Example 31 with ConfigRepoConfig

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

the class PipelineScheduleQueueIntegrationTest method shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision.

@Test
public void shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision() {
    PipelineConfig pipelineConfig = fixture.pipelineConfig();
    BuildCause cause = modifySomeFilesAndTriggerAs(pipelineConfig, "cruise-developer");
    MaterialConfig materialConfig = pipelineConfig.materialConfigs().first();
    cause.getMaterialRevisions().findRevisionFor(materialConfig);
    pipelineConfig.setOrigins(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig, "123"), "plug"));
    saveRev(cause);
    queue.schedule(fixture.pipelineName, cause);
    Pipeline pipeline = queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
    assertThat(pipeline, is(nullValue()));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) 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 32 with ConfigRepoConfig

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

the class ConfigRepoServiceIntegrationTest method shouldUpdateSpecifiedConfigRepository.

@Test
public void shouldUpdateSpecifiedConfigRepository() throws Exception {
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    configHelper.enableSecurity();
    goConfigDao.updateConfig(new UpdateConfigCommand() {

        @Override
        public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
            cruiseConfig.getConfigRepos().add(configRepo);
            return cruiseConfig;
        }
    });
    String newRepoId = "repo-2";
    ConfigRepoConfig toUpdateWith = new ConfigRepoConfig(new GitMaterialConfig("http://bar.git", "master"), "yaml-plugin", newRepoId);
    assertThat(configRepoService.getConfigRepos().size(), is(1));
    assertThat(configRepoService.getConfigRepo(repoId), is(configRepo));
    configRepoService.updateConfigRepo(repoId, toUpdateWith, entityHashingService.md5ForEntity(configRepo), user, result);
    assertThat(result.toString(), result.isSuccessful(), Is.is(true));
    assertThat(configRepoService.getConfigRepos().size(), is(1));
    assertThat(configRepoService.getConfigRepo(newRepoId), is(toUpdateWith));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) UpdateConfigCommand(com.thoughtworks.go.config.UpdateConfigCommand) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) IOException(java.io.IOException) Test(org.junit.Test)

Example 33 with ConfigRepoConfig

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

the class ConfigRepoServiceIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    user = new Username(new CaseInsensitiveString("current"));
    UpdateConfigCommand command = goConfigService.modifyAdminPrivilegesCommand(asList(user.getUsername().toString()), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.add));
    goConfigService.updateConfig(command);
    this.repoId = "repo-1";
    this.pluginId = "json-config-repo-plugin";
    MaterialConfig repoMaterial = new GitMaterialConfig("https://foo.git", "master");
    this.configRepo = new ConfigRepoConfig(repoMaterial, pluginId, repoId);
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    configHelper.onSetUp();
    goConfigService.forceNotifyListeners();
}
Also used : UpdateConfigCommand(com.thoughtworks.go.config.UpdateConfigCommand) Username(com.thoughtworks.go.server.domain.Username) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) TriStateSelection(com.thoughtworks.go.presentation.TriStateSelection) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Before(org.junit.Before)

Example 34 with ConfigRepoConfig

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

the class ConfigSaveDeadlockDetectionIntegrationTest method configRepoDeleteThread.

private Thread configRepoDeleteThread(final ConfigRepoConfig configRepoToBeDeleted, final int counter) throws InterruptedException {
    return createThread(new Runnable() {

        @Override
        public void run() {
            goConfigService.updateConfig(new UpdateConfigCommand() {

                @Override
                public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
                    ConfigRepoConfig repoConfig = cruiseConfig.getConfigRepos().stream().filter(new Predicate<ConfigRepoConfig>() {

                        @Override
                        public boolean test(ConfigRepoConfig item) {
                            return configRepoToBeDeleted.getMaterialConfig().equals(item.getMaterialConfig());
                        }
                    }).findFirst().orElse(null);
                    cruiseConfig.getConfigRepos().remove(repoConfig);
                    return cruiseConfig;
                }
            });
        }
    }, "config-repo-delete-thread" + counter);
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig)

Example 35 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)

Aggregations

ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)66 Test (org.junit.Test)40 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)37 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)34 Before (org.junit.Before)13 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)11 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)10 ConfigReposConfig (com.thoughtworks.go.config.remote.ConfigReposConfig)9 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)6 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)6 File (java.io.File)6 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)5 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)5 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)5 IOException (java.io.IOException)5 AbstractMaterialConfig (com.thoughtworks.go.config.materials.AbstractMaterialConfig)4 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)4 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)4