Search in sources :

Example 21 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class GoPartialConfigIntegrationTest method shouldMarkAnInvalidKnownPartialAsValidWhenLoadingAnotherPartialMakesThisOneValid_InterConfigRepoDependency.

@Test
public void shouldMarkAnInvalidKnownPartialAsValidWhenLoadingAnotherPartialMakesThisOneValid_InterConfigRepoDependency() {
    ConfigRepoConfig repoConfig3 = new ConfigRepoConfig(new GitMaterialConfig("url3"), "plugin");
    configHelper.addConfigRepo(repoConfig3);
    PartialConfig repo1 = PartialConfigMother.withPipeline("p1_repo1", new RepoConfigOrigin(repoConfig1, "1"));
    PartialConfig repo2 = PartialConfigMother.withPipeline("p2_repo2", new RepoConfigOrigin(repoConfig2, "1"));
    PartialConfig repo3 = PartialConfigMother.withPipeline("p3_repo3", new RepoConfigOrigin(repoConfig3, "1"));
    PipelineConfig p1 = repo1.getGroups().first().getPipelines().get(0);
    PipelineConfig p2 = repo2.getGroups().first().getPipelines().get(0);
    PipelineConfig p3 = repo3.getGroups().first().getPipelines().get(0);
    p2.addMaterialConfig(new DependencyMaterialConfig(p1.name(), p1.first().name()));
    p2.addMaterialConfig(new DependencyMaterialConfig(p3.name(), p3.first().name()));
    p1.addMaterialConfig(new DependencyMaterialConfig(p3.name(), p3.first().name()));
    goPartialConfig.onSuccessPartialConfig(repoConfig2, repo2);
    assertThat(goConfigDao.loadConfigHolder().config.getAllPipelineNames().contains(p2.name()), is(false));
    assertThat(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(repoConfig2)).isEmpty(), is(false));
    ServerHealthState healthStateForInvalidConfigMerge = serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(repoConfig2)).get(0);
    assertThat(healthStateForInvalidConfigMerge.getMessage(), is("Invalid Merged Configuration"));
    assertThat(healthStateForInvalidConfigMerge.getDescription(), is("3+ errors :: Pipeline "p1_repo1" does not exist. It is used from pipeline "p2_repo2".;; Pipeline with name 'p1_repo1' does not exist, it is defined as a dependency for pipeline 'p2_repo2' (url2 at 1);; Pipeline with name 'p3_repo3' does not exist, it is defined as a dependency for pipeline 'p2_repo2' (url2 at 1);;  -  Config-Repo: url2 at 1"));
    assertThat(healthStateForInvalidConfigMerge.getLogLevel(), is(HealthStateLevel.ERROR));
    assertThat(cachedGoPartials.lastValidPartials().isEmpty(), is(true));
    assertThat(cachedGoPartials.lastKnownPartials().size(), is(1));
    assertThat(cacheContainsPartial(cachedGoPartials.lastKnownPartials(), repo2), is(true));
    assertThat(cacheContainsPartial(cachedGoPartials.lastKnownPartials(), repo1), is(false));
    goPartialConfig.onSuccessPartialConfig(repoConfig3, repo3);
    assertThat(goConfigDao.loadConfigHolder().config.getAllPipelineNames().contains(p3.name()), is(true));
    assertThat(goConfigDao.loadConfigHolder().config.getAllPipelineNames().contains(p2.name()), is(false));
    assertThat(goConfigDao.loadConfigHolder().config.getAllPipelineNames().contains(p1.name()), is(false));
    assertThat(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(repoConfig3)).isEmpty(), is(true));
    assertThat(cachedGoPartials.lastValidPartials().size(), is(1));
    assertThat(cacheContainsPartial(cachedGoPartials.lastValidPartials(), repo2), is(false));
    assertThat(cacheContainsPartial(cachedGoPartials.lastValidPartials(), repo3), is(true));
    assertThat(cachedGoPartials.lastKnownPartials().size(), is(2));
    assertThat(cacheContainsPartial(cachedGoPartials.lastKnownPartials(), repo2), is(true));
    assertThat(cacheContainsPartial(cachedGoPartials.lastKnownPartials(), repo3), is(true));
    goPartialConfig.onSuccessPartialConfig(repoConfig1, repo1);
    assertThat(goConfigDao.loadConfigHolder().config.getAllPipelineNames().contains(p1.name()), is(true));
    assertThat(goConfigDao.loadConfigHolder().config.getAllPipelineNames().contains(p2.name()), is(true));
    assertThat(goConfigDao.loadConfigHolder().config.getAllPipelineNames().contains(p3.name()), is(true));
    assertThat(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(repoConfig1)).isEmpty(), is(true));
    assertThat(cachedGoPartials.lastValidPartials().size(), is(3));
    assertThat(cacheContainsPartial(cachedGoPartials.lastValidPartials(), repo2), is(true));
    assertThat(cacheContainsPartial(cachedGoPartials.lastValidPartials(), repo1), is(true));
    assertThat(cacheContainsPartial(cachedGoPartials.lastValidPartials(), repo3), is(true));
    assertThat(cachedGoPartials.lastKnownPartials().size(), is(3));
    assertThat(cacheContainsPartial(cachedGoPartials.lastKnownPartials(), repo2), is(true));
    assertThat(cacheContainsPartial(cachedGoPartials.lastKnownPartials(), repo1), is(true));
    assertThat(cacheContainsPartial(cachedGoPartials.lastKnownPartials(), repo3), is(true));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 22 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class GoRepoConfigDataSourceIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    GoConfigFileHelper configHelper = new GoConfigFileHelper(DEFAULT_XML_WITH_2_AGENTS);
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    configHelper.onSetUp();
    GoRepoConfigDataSource repoConfigDataSource = new GoRepoConfigDataSource(configWatchList, configPluginService, serverHealthService);
    repoConfigDataSource.registerListener(new GoPartialConfig(repoConfigDataSource, configWatchList, goConfigService, cachedGoPartials, serverHealthService));
    configHelper.addTemplate("t1", "param1", "stage");
    File templateConfigRepo = temporaryFolder.newFolder();
    String latestRevision = setupExternalConfigRepo(templateConfigRepo, "external_git_config_repo_referencing_template_with_params");
    ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(new GitMaterialConfig(templateConfigRepo.getAbsolutePath()), "gocd-xml");
    configHelper.addConfigRepo(configRepoConfig);
    goConfigService.forceNotifyListeners();
    repoConfigDataSource.onCheckoutComplete(configRepoConfig.getMaterialConfig(), templateConfigRepo, latestRevision);
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) File(java.io.File) Before(org.junit.Before)

Example 23 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class ConfigRepoConfigTest method hasMaterialWithFingerprint_shouldReturnFalseWhenFingerprintNotEquals.

@Test
public void hasMaterialWithFingerprint_shouldReturnFalseWhenFingerprintNotEquals() {
    MaterialConfig configRepo = git("url", "branch");
    GitMaterialConfig someRepo = git("url", "branch1");
    ConfigRepoConfig config = ConfigRepoConfig.createConfigRepoConfig(configRepo, "myplugin", "id");
    assertThat(config.hasMaterialWithFingerprint(someRepo.getFingerprint())).isFalse();
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.jupiter.api.Test)

Example 24 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class ConfigRepoConfigTest method newPluginProfile.

@Override
protected RuleAwarePluginProfile newPluginProfile(String id, String pluginId, ConfigurationProperty... configurationProperties) {
    RuleAwarePluginProfile profile = new ConfigRepoConfig().setId(id).setPluginId(pluginId);
    profile.addConfigurations(Arrays.asList(configurationProperties));
    ((ConfigRepoConfig) profile).setRepo(new GitMaterialConfig());
    return profile;
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) RuleAwarePluginProfile(com.thoughtworks.go.config.rules.RuleAwarePluginProfile)

Example 25 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class ConfigRepoConfigTest method hasSameMaterial_shouldReturnTrueWhenFingerprintEquals_AndDestinationDirectoriesAreDifferent.

@Test
public void hasSameMaterial_shouldReturnTrueWhenFingerprintEquals_AndDestinationDirectoriesAreDifferent() {
    MaterialConfig configRepo = git("url", "branch");
    GitMaterialConfig someRepo = git("url", "branch");
    someRepo.setFolder("someFolder");
    ConfigRepoConfig config = ConfigRepoConfig.createConfigRepoConfig(configRepo, "myplugin", "id");
    assertThat(config.hasSameMaterial(someRepo)).isTrue();
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.jupiter.api.Test)

Aggregations

GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)138 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)37 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)21 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)20 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)14 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)11 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 Material (com.thoughtworks.go.domain.materials.Material)8 SCMs (com.thoughtworks.go.domain.scm.SCMs)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7