Search in sources :

Example 86 with RepoConfigOrigin

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

the class CachedGoConfigIntegrationTest method setupExternalConfigRepoWithDependencyMaterialOnPipelineInMainXml.

private void setupExternalConfigRepoWithDependencyMaterialOnPipelineInMainXml(String upstream, String remoteDownstreamPipelineName) {
    PipelineConfig upstreamPipelineConfig = GoConfigMother.createPipelineConfigWithMaterialConfig(upstream, new GitMaterialConfig("FOO"));
    goConfigService.addPipeline(upstreamPipelineConfig, "default");
    PartialConfig partialConfig = PartialConfigMother.pipelineWithDependencyMaterial(remoteDownstreamPipelineName, upstreamPipelineConfig, new RepoConfigOrigin(configRepo, "r1"));
    goPartialConfig.onSuccessPartialConfig(configRepo, partialConfig);
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin)

Example 87 with RepoConfigOrigin

use of com.thoughtworks.go.config.remote.RepoConfigOrigin 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)

Example 88 with RepoConfigOrigin

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

the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldSchedulePipelineWhenPartIsInvalid_AndManuallyTriggered.

@Test
public void shouldSchedulePipelineWhenPartIsInvalid_AndManuallyTriggered() throws Exception {
    List<Modification> lastPush = configTestRepo.addCodeToRepositoryAndPush(fileName, "added broken config file", "bad bad config");
    materialUpdateService.updateMaterial(material);
    waitForMaterialNotInProgress();
    assertThat(goRepoConfigDataSource.latestParseHasFailedForMaterial(material.config()), is(true));
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
    Map<String, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(5);
    assertThat(afterLoad.keySet(), hasItem(PIPELINE_NAME));
    BuildCause cause = afterLoad.get(PIPELINE_NAME);
    assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
    PipelineConfig pipelineConfigAfterSchedule = goConfigService.pipelineConfigNamed(pipelineConfig.name());
    RepoConfigOrigin configOriginAfterSchedule = (RepoConfigOrigin) pipelineConfigAfterSchedule.getOrigin();
    String lastValidPushedRevision = this.firstRevisions.latestRevision();
    assertThat("revisionOfPipelineConfigOriginShouldMatchLastValidPushedCommit", configOriginAfterSchedule.getRevision(), is(lastValidPushedRevision));
    assertThat("buildCauseRevisionShouldMatchLastPushedCommit", cause.getMaterialRevisions().latestRevision(), is(lastPush.get(0).getRevision()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) HashMap(java.util.HashMap) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 89 with RepoConfigOrigin

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

the class PipelineConfigServiceTest method setUp.

@Before
public void setUp() throws Exception {
    PipelineConfigs configs = createGroup("group", "pipeline", "in_env");
    downstream(configs);
    cruiseConfig = new BasicCruiseConfig(configs);
    cruiseConfig.addEnvironment(environment("foo", "in_env"));
    PipelineConfig remotePipeline = PipelineConfigMother.pipelineConfig("remote");
    remotePipeline.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(new GitMaterialConfig("url"), "plugin"), "1234"));
    cruiseConfig.addPipeline("group", remotePipeline);
    goConfigService = mock(GoConfigService.class);
    securityService = mock(SecurityService.class);
    pluggableTaskService = mock(PluggableTaskService.class);
    when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
    when(goConfigService.getConfigForEditing()).thenReturn(cruiseConfig);
    pipelineConfigService = new PipelineConfigService(goConfigService, securityService, pluggableTaskService, null);
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) PluggableTaskService(com.thoughtworks.go.server.service.tasks.PluggableTaskService) Before(org.junit.Before)

Aggregations

RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)89 Test (org.junit.Test)63 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)32 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)28 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)20 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)14 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)13 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)11 StringContains.containsString (org.hamcrest.core.StringContains.containsString)11 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)10 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)10 File (java.io.File)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)8 ExpectedException (org.junit.rules.ExpectedException)8 Cloner (com.rits.cloning.Cloner)7 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)7 Modification (com.thoughtworks.go.domain.materials.Modification)7 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)6