Search in sources :

Example 21 with ConfigReposConfig

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

the class GoConfigRepoConfigDataSourceTest method shouldSetOKHealthState_AtConfigRepoScope_WhenPluginHasParsed.

@Test
public void shouldSetOKHealthState_AtConfigRepoScope_WhenPluginHasParsed() {
    ScmMaterialConfig material = git("http://my.git");
    ConfigRepoConfig configRepoConfig = ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
    configWatchList.onConfigChange(cruiseConfig);
    // set error state to simulate previously failed parse
    HealthStateScope scope = HealthStateScope.forPartialConfigRepo(configRepoConfig);
    serverHealthService.update(ServerHealthState.error("Parse failed", "Bad config format", HealthStateType.general(scope)));
    // verify error health
    assertFalse(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(configRepoConfig)).isEmpty());
    // now this should fix health
    repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
    assertTrue(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(configRepoConfig)).isEmpty());
}
Also used : HealthStateScope(com.thoughtworks.go.serverhealth.HealthStateScope) ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 22 with ConfigReposConfig

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

the class GoConfigRepoConfigDataSourceTest method shouldAssignConfigOriginInPipelines.

@Test
public void shouldAssignConfigOriginInPipelines() throws Exception {
    ScmMaterialConfig material = git("http://my.git");
    ConfigRepoConfig configRepo = ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepo));
    configWatchList.onConfigChange(cruiseConfig);
    when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(PartialConfigMother.withPipeline("pipe1"));
    repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
    PartialConfig partialConfig = repoConfigDataSource.latestPartialConfigForMaterial(material);
    RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(configRepo, "7a8f");
    assertNotNull(partialConfig.getOrigin());
    assertThat(partialConfig.getOrigin(), is(repoConfigOrigin));
    PipelineConfig pipe = partialConfig.getGroups().get(0).get(0);
    assertThat(pipe.getOrigin(), is(repoConfigOrigin));
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) File(java.io.File) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 23 with ConfigReposConfig

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

the class GoConfigRepoConfigDataSourceTest method shouldThrowWhenGettingLatestPartialConfig_WhenInitializingPluginHasFailed.

@Test
public void shouldThrowWhenGettingLatestPartialConfig_WhenInitializingPluginHasFailed() throws Exception {
    when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenThrow(new RuntimeException("Failed to initialize plugin"));
    ScmMaterialConfig material = git("http://my.git");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id")));
    configWatchList.onConfigChange(cruiseConfig);
    repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
    assertTrue(repoConfigDataSource.latestParseHasFailedForMaterial(material));
    try {
        repoConfigDataSource.latestPartialConfigForMaterial(material);
    } catch (RuntimeException ex) {
        assertThat(ex.getMessage(), is("Failed to initialize plugin"));
    }
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 24 with ConfigReposConfig

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

the class GoConfigRepoConfigDataSourceTest method shouldAssignConfigOrigin.

@Test
public void shouldAssignConfigOrigin() throws Exception {
    ScmMaterialConfig material = git("http://my.git");
    ConfigRepoConfig configRepo = ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepo));
    configWatchList.onConfigChange(cruiseConfig);
    repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
    PartialConfig partialConfig = repoConfigDataSource.latestPartialConfigForMaterial(material);
    assertNotNull(partialConfig.getOrigin());
    RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(configRepo, "7a8f");
    assertThat(partialConfig.getOrigin(), is(repoConfigOrigin));
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 25 with ConfigReposConfig

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

the class GoConfigRepoConfigDataSourceTest method shouldThrowWhenGettingLatestPartialConfig_WhenPluginHasFailed.

@Test
public void shouldThrowWhenGettingLatestPartialConfig_WhenPluginHasFailed() throws Exception {
    // use broken plugin now
    when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenReturn(new BrokenConfigPlugin());
    ScmMaterialConfig material = git("http://my.git");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id")));
    configWatchList.onConfigChange(cruiseConfig);
    repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
    assertTrue(repoConfigDataSource.latestParseHasFailedForMaterial(material));
    try {
        repoConfigDataSource.latestPartialConfigForMaterial(material);
    } catch (BrokenConfigPluginException ex) {
        return;
    }
    fail("should have thrown BrokenConfigPluginException");
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigReposConfig (com.thoughtworks.go.config.remote.ConfigReposConfig)30 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)18 Test (org.junit.jupiter.api.Test)17 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)14 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)7 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)6 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)5 File (java.io.File)4 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)3 ConfigRepoService (com.thoughtworks.go.server.service.ConfigRepoService)2 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ApiController (com.thoughtworks.go.api.ApiController)1 ApiVersion (com.thoughtworks.go.api.ApiVersion)1 CrudController (com.thoughtworks.go.api.CrudController)1 OutputWriter (com.thoughtworks.go.api.base.OutputWriter)1 JsonReader (com.thoughtworks.go.api.representers.JsonReader)1 ApiAuthenticationHelper (com.thoughtworks.go.api.spring.ApiAuthenticationHelper)1 GsonTransformer (com.thoughtworks.go.api.util.GsonTransformer)1 HaltApiResponses.haltBecauseEntityAlreadyExists (com.thoughtworks.go.api.util.HaltApiResponses.haltBecauseEntityAlreadyExists)1