Search in sources :

Example 1 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class BuildWorkTest method createBuildWorkWithJobPlan.

private void createBuildWorkWithJobPlan(JobPlan jobPlan) throws Exception {
    CruiseConfig cruiseConfig = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(FileUtil.readToEnd(IOUtils.toInputStream(ConfigFileFixture.withJob(CMD_NOT_EXIST)))).config;
    JobConfig jobConfig = cruiseConfig.jobConfigByName(PIPELINE_NAME, STAGE_NAME, JOB_PLAN_NAME, true);
    final Stage stage = StageMother.custom(STAGE_NAME, new JobInstance(JOB_PLAN_NAME));
    BuildCause buildCause = BuildCause.createWithEmptyModifications();
    final Pipeline pipeline = new Pipeline(PIPELINE_NAME, buildCause, stage);
    List<Builder> builder = builderFactory.buildersForTasks(pipeline, jobConfig.getTasks(), resolver);
    BuildAssignment buildAssignment = BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, pipeline.defaultWorkingFolder());
    buildWork = new BuildWork(buildAssignment);
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) Builder(com.thoughtworks.go.domain.builder.Builder) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) JobConfig(com.thoughtworks.go.config.JobConfig) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 2 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class LongWorkCreator method getWork.

public Work getWork() {
    try {
        CruiseConfig config = GoConfigMother.pipelineHavingJob(PIPELINE_NAME, STAGE_NAME, JOB_PLAN_NAME, ARTIFACT_FILE.getAbsolutePath(), ARTIFACT_FOLDER.getAbsolutePath());
        BuildCause buildCause = BuildCause.createWithEmptyModifications();
        builder = new ArrayList<>();
        builder.add(new SleepBuilder());
        JobPlan instance = toBuildInstance(config);
        BuildAssignment buildAssignment = BuildAssignment.create(instance, buildCause, builder, new File(CruiseConfig.WORKING_BASE_DIR + PIPELINE_NAME));
        return new BuildWork(buildAssignment);
    } catch (Exception e) {
        throw bomb(e);
    }
}
Also used : JobPlan(com.thoughtworks.go.domain.JobPlan) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) File(java.io.File) BuildWork(com.thoughtworks.go.remote.work.BuildWork) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) IOException(java.io.IOException) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 3 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class ServerConfigTest method shouldParseServerConfigWithMailhost.

@Test
public void shouldParseServerConfigWithMailhost() throws Exception {
    String xml = "<mailhost hostname=\"smtp.company.com\" port=\"25\" " + "username=\"smtpuser\" password=\"password\" tls=\"true\" " + "from=\"cruise@me.com\" admin=\"jez@me.com\"/>";
    ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    CruiseConfig config = new MagicalGoConfigXmlLoader(new ConfigCache(), registry).loadConfigHolder(withServerConfig(xml)).config;
    MailHost mailHost = config.server().mailHost();
    assertThat(mailHost, is(new MailHost("smtp.company.com", 25, "smtpuser", "password", true, true, "cruise@me.com", "jez@me.com")));
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) MailHost(com.thoughtworks.go.config.MailHost) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 4 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class PipelineSqlMapDaoCachingTest method loadActivePipelines_shouldCacheResult.

@Test
public void loadActivePipelines_shouldCacheResult() {
    final String pipelineName = "pipeline";
    CruiseConfig mockCruiseConfig = mock(BasicCruiseConfig.class);
    GoConfigDao mockconfigFileDao = mock(GoConfigDao.class);
    when(mockconfigFileDao.load()).thenReturn(mockCruiseConfig);
    when(mockCruiseConfig.getAllPipelineNames()).thenReturn(Arrays.asList(new CaseInsensitiveString(pipelineName)));
    // need to mock configfileDao for this test
    pipelineDao = new PipelineSqlMapDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null, transactionSynchronizationManager, null, mockconfigFileDao, null, mock(SessionFactory.class));
    pipelineDao.setSqlMapClientTemplate(mockTemplate);
    PipelineInstanceModel pipeline = new PipelineInstanceModel(pipelineName, -2, "label", BuildCause.createManualForced(), new StageInstanceModels());
    PipelineInstanceModels pims = PipelineInstanceModels.createPipelineInstanceModels(pipeline);
    when(mockTemplate.queryForList("allActivePipelines")).thenReturn(pims);
    when(mockTemplate.queryForObject(eq("getPipelineHistoryById"), any())).thenReturn(pipeline);
    PipelineInstanceModels loaded;
    loaded = pipelineDao.loadActivePipelines();
    loaded = pipelineDao.loadActivePipelines();
    assertNotSame(pipeline, loaded);
    assertTrue(ToStringBuilder.reflectionToString(loaded) + " not equal to\n" + ToStringBuilder.reflectionToString(pipeline), EqualsBuilder.reflectionEquals(loaded, pims));
    verify(mockTemplate, times(1)).queryForList("allActivePipelines");
    verify(mockTemplate, times(1)).queryForObject(eq("getPipelineHistoryById"), any());
    verify(mockconfigFileDao, times(2)).load();
    verify(mockCruiseConfig, times(2)).getAllPipelineNames();
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigDao(com.thoughtworks.go.config.GoConfigDao) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 5 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class GoDashboardConfigChangeHandlerTest method shouldReplaceAllEntriesInCacheWithNewEntriesWhenTheWholeConfigHasChanged.

@Test
public void shouldReplaceAllEntriesInCacheWithNewEntriesWhenTheWholeConfigHasChanged() throws Exception {
    CruiseConfig config = GoConfigMother.configWithPipelines("pipeline1", "pipeline2");
    handler.call(config);
    verify(cacheUpdateService).updateCacheForAllPipelinesIn(config);
}
Also used : CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Aggregations

CruiseConfig (com.thoughtworks.go.config.CruiseConfig)95 Test (org.junit.Test)77 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)54 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)35 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)33 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)32 ServerConfig (com.thoughtworks.go.config.ServerConfig)11 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)7 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)5 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)5 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)4 File (java.io.File)4 ConfigCache (com.thoughtworks.go.config.ConfigCache)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)3 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)3 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3