Search in sources :

Example 56 with ConfigRepoConfig

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

the class MagicalGoConfigXmlLoaderTest method shouldLoadConfigWithConfigRepoAndPluginName.

@Test
public void shouldLoadConfigWithConfigRepoAndPluginName() throws Exception {
    CruiseConfig cruiseConfig = xmlLoader.loadConfigHolder(configWithConfigRepos("  <config-repos>\n" + "    <config-repo pluginId=\"myplugin\" id=\"repo-id\">\n" + "      <git url=\"https://github.com/tomzo/gocd-indep-config-part.git\" />\n" + "    </config-repo >\n" + "  </config-repos>\n")).config;
    assertThat(cruiseConfig.getConfigRepos().size(), is(1));
    ConfigRepoConfig configRepo = cruiseConfig.getConfigRepos().get(0);
    assertThat(configRepo.getConfigProviderPluginName(), is("myplugin"));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) Test(org.junit.Test)

Example 57 with ConfigRepoConfig

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

the class MagicalGoConfigXmlLoaderTest method shouldLoadConfigWithConfigRepo.

@Test
public void shouldLoadConfigWithConfigRepo() throws Exception {
    CruiseConfig cruiseConfig = xmlLoader.loadConfigHolder(ONE_CONFIG_REPO).config;
    assertThat(cruiseConfig.getConfigRepos().size(), is(1));
    ConfigRepoConfig configRepo = cruiseConfig.getConfigRepos().get(0);
    assertThat(configRepo.getMaterialConfig(), Is.<MaterialConfig>is(new GitMaterialConfig("https://github.com/tomzo/gocd-indep-config-part.git")));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.Test)

Example 58 with ConfigRepoConfig

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

the class MagicalGoConfigXmlLoaderTest method shouldLoadConfigWithConfigRepoAndConfiguration.

@Test
public void shouldLoadConfigWithConfigRepoAndConfiguration() throws Exception {
    CruiseConfig cruiseConfig = xmlLoader.loadConfigHolder(configWithConfigRepos("  <config-repos>\n" + "    <config-repo id=\"id1\">\n" + "      <git url=\"https://github.com/tomzo/gocd-indep-config-part.git\" />\n" + "      <configuration>\n" + "        <property>\n" + "          <key>pattern</key>\n" + "          <value>*.gocd.xml</value>\n" + "        </property>\n" + "      </configuration>\n" + "    </config-repo >\n" + "  </config-repos>\n")).config;
    assertThat(cruiseConfig.getConfigRepos().size(), is(1));
    ConfigRepoConfig configRepo = cruiseConfig.getConfigRepos().get(0);
    assertThat(configRepo.getConfiguration().size(), is(1));
    assertThat(configRepo.getConfiguration().getProperty("pattern").getValue(), is("*.gocd.xml"));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) Test(org.junit.Test)

Example 59 with ConfigRepoConfig

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

the class BuildCauseProducerServiceConfigRepoIntegrationTest method setup.

@Before
public void setup() throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    hgRepo = new HgTestRepo("testHgRepo", temporaryFolder);
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    materialConfig = hgRepo.materialConfig();
    configHelper.addConfigRepo(new ConfigRepoConfig(materialConfig, "gocd-xml"));
    logger = mock(MDUPerformanceLogger.class);
    TestingEmailSender emailSender = new TestingEmailSender();
    SystemDiskSpaceChecker mockDiskSpaceChecker = Mockito.mock(SystemDiskSpaceChecker.class);
    StageService stageService = mock(StageService.class);
    ConfigDbStateRepository configDbStateRepository = mock(ConfigDbStateRepository.class);
    goDiskSpaceMonitor = new GoDiskSpaceMonitor(goConfigService, systemEnvironment, serverHealthService, emailSender, mockDiskSpaceChecker, mock(ArtifactsService.class), stageService, configDbStateRepository);
    goDiskSpaceMonitor.initialize();
    worker = new MaterialUpdateListener(configTopic, materialDatabaseUpdater, logger, goDiskSpaceMonitor);
    xmlWriter = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins());
    configTestRepo = new ConfigTestRepo(hgRepo, xmlWriter);
    this.material = (HgMaterial) materialConfigConverter.toMaterial(materialConfig);
    pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
    pipelineConfig.materialConfigs().clear();
    pipelineConfig.materialConfigs().add(materialConfig);
    PIPELINE_NAME = CaseInsensitiveString.str(pipelineConfig.name());
    configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
    materialUpdateService.updateMaterial(material);
    // time for messages to pass through all services
    waitForMaterialNotInProgress();
    pipelineConfig = goConfigService.pipelineConfigNamed(pipelineConfig.name());
    pipelineScheduleQueue.clear();
    // check test setup
    Materials materials = materialConfigConverter.toMaterials(pipelineConfig.materialConfigs());
    MaterialRevisions peggedRevisions = new MaterialRevisions();
    firstRevisions = materialChecker.findLatestRevisions(peggedRevisions, materials);
    assertThat(firstRevisions.isMissingModifications(), is(false));
}
Also used : MDUPerformanceLogger(com.thoughtworks.go.server.perf.MDUPerformanceLogger) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) GoDiskSpaceMonitor(com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) ConfigTestRepo(com.thoughtworks.go.helper.ConfigTestRepo) Before(org.junit.Before)

Example 60 with ConfigRepoConfig

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

the class ConfigSaveDeadlockDetectionIntegrationTest method shouldNotDeadlockWhenAllPossibleWaysOfUpdatingTheConfigAreBeingUsedAtTheSameTime.

@Test
public void shouldNotDeadlockWhenAllPossibleWaysOfUpdatingTheConfigAreBeingUsedAtTheSameTime() throws Exception {
    int EXISTING_ENV_COUNT = goConfigService.cruiseConfig().getEnvironments().size();
    final ArrayList<Thread> group1 = new ArrayList<>();
    final ArrayList<Thread> group2 = new ArrayList<>();
    final ArrayList<Thread> group3 = new ArrayList<>();
    final ArrayList<Thread> group4 = new ArrayList<>();
    final ArrayList<Thread> group5 = new ArrayList<>();
    int count = 100;
    final int pipelineCreatedThroughApiCount = count;
    final int pipelineCreatedThroughUICount = count;
    final int configRepoAdditionThreadCount = count;
    final int configRepoDeletionThreadCount = count;
    final int fullConfigSaveThreadCount = count;
    for (int i = 0; i < pipelineCreatedThroughUICount; i++) {
        Thread thread = configSaveThread(i);
        group1.add(thread);
    }
    for (int i = 0; i < pipelineCreatedThroughApiCount; i++) {
        Thread thread = pipelineSaveThread(i);
        group2.add(thread);
    }
    ConfigReposConfig configRepos = new ConfigReposConfig();
    for (int i = 0; i < configRepoAdditionThreadCount; i++) {
        ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(new GitMaterialConfig("url" + i), "plugin");
        configRepos.add(configRepoConfig);
        Thread thread = configRepoSaveThread(configRepoConfig, i);
        group3.add(thread);
    }
    for (int i = 0; i < configRepoDeletionThreadCount; i++) {
        ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(new GitMaterialConfig("to-be-deleted-url" + i), "plugin");
        cachedGoPartials.addOrUpdate(configRepoConfig.getMaterialConfig().getFingerprint(), PartialConfigMother.withPipeline("to-be-deleted" + i, new RepoConfigOrigin(configRepoConfig, "plugin")));
        configRepos.add(configRepoConfig);
        Thread thread = configRepoDeleteThread(configRepoConfig, i);
        group4.add(thread);
    }
    for (int i = 0; i < fullConfigSaveThreadCount; i++) {
        Thread thread = fullConfigSaveThread(i);
        group5.add(thread);
    }
    configHelper.setConfigRepos(configRepos);
    for (int i = 0; i < count; i++) {
        Thread timerThread = null;
        try {
            timerThread = createThread(new Runnable() {

                @Override
                public void run() {
                    try {
                        writeConfigToFile(new File(goConfigDao.fileLocation()));
                    } catch (Exception e) {
                        e.printStackTrace();
                        fail("Failed with error: " + e.getMessage());
                    }
                    cachedGoConfig.forceReload();
                }
            }, "timer-thread");
        } catch (InterruptedException e) {
            fail(e.getMessage());
        }
        try {
            group1.get(i).start();
            group2.get(i).start();
            group3.get(i).start();
            group4.get(i).start();
            group5.get(i).start();
            timerThread.start();
            group1.get(i).join();
            group2.get(i).join();
            group3.get(i).join();
            group4.get(i).join();
            group5.get(i).join();
            timerThread.join();
        } catch (InterruptedException e) {
            fail(e.getMessage());
        }
    }
    assertThat(goConfigService.getAllPipelineConfigs().size(), is(pipelineCreatedThroughApiCount + pipelineCreatedThroughUICount + configRepoAdditionThreadCount));
    assertThat(goConfigService.getConfigForEditing().getAllPipelineConfigs().size(), is(pipelineCreatedThroughApiCount + pipelineCreatedThroughUICount));
    assertThat(goConfigService.getConfigForEditing().getEnvironments().size(), is(fullConfigSaveThreadCount + EXISTING_ENV_COUNT));
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ArrayList(java.util.ArrayList) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) File(java.io.File) TimeoutException(java.util.concurrent.TimeoutException) InvalidCipherTextException(org.bouncycastle.crypto.InvalidCipherTextException) IOException(java.io.IOException) 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