Search in sources :

Example 41 with CruiseConfig

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

the class AutoTriggerDependencyResolutionTest method shouldTrigger_withLatestOfUnsharedMaterial_keepingAllTheSharedMaterialRevisionsPegged.

@Test
public void shouldTrigger_withLatestOfUnsharedMaterial_keepingAllTheSharedMaterialRevisionsPegged() throws Exception {
    /**
     * git -------> P1--------+
     *              |         |
     *              |         |
     *              v         v
     *              P2 -----> P3 <---- svn
     */
    GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
    String[] git_revs = { "g1", "g2" };
    u.checkinInOrder(git, git_revs);
    SvnMaterial svn = u.wf(new SvnMaterial("svn", "username", "password", false), "folder2");
    String[] svn_revs = { "s1", "s2" };
    u.checkinInOrder(svn, svn_revs);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(git));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(p1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(p1), u.m(p2), u.m(svn));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPass(p1, "g1");
    String p2_1 = u.runAndPass(p2, p1_1);
    String p1_2 = u.runAndPass(p1, "g2");
    u.scheduleWith(p2, p1_2);
    String p3_1 = u.runAndPass(p3, p1_1, p2_1, "s1");
    MaterialRevisions given = u.mrs(u.mr(p2, true, p2_1), u.mr(u.mw(p1), false, p1_2), u.mr(svn, true, "s2"));
    MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_1), u.mr(u.mw(p1), false, p1_1), u.mr(svn, true, "s2"));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p3, cruiseConfig, given);
    assertThat(finalRevisions, is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 42 with CruiseConfig

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

the class AutoTriggerDependencyResolutionTest method shouldPrefer_combinationThatBringsLatestPossibleRevisionsOfMostMaterials_whileComputingCompatibleRevisions.

@Test
public void shouldPrefer_combinationThatBringsLatestPossibleRevisionsOfMostMaterials_whileComputingCompatibleRevisions() throws Exception {
    /**
     *      +------ git ------+
     *      |        |        |
     *      |        |        |
     *      v        v        v
     *      P1      P2       P3
     *      |        |        |
     *      |        |        |
     *      +-----> P4 <------+
     */
    GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
    String[] git_revs = { "g1", "g2", "g3", "g4" };
    int i = 1;
    u.checkinInOrder(git, u.d(i++), git_revs);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(git));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(git));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(git));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p2), u.m(p1), u.m(p3));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1");
    String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2", "g3");
    String p1_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g4");
    String p1_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2");
    String p1_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g4");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g1");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g2");
    String p2_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g3");
    String p2_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g4");
    // latest
    String p2_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g2");
    // Does this honour schedule order?
    String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g1");
    String p3_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g2");
    String p3_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g3");
    String p3_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g3");
    String p3_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g4");
    MaterialRevisions given = u.mrs(u.mr(p2, true, p2_5), u.mr(p1, true, p1_5), u.mr(p3, false, p3_5));
    MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_5), u.mr(p1, false, p1_4), u.mr(p3, false, p3_2));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
    assertThat(finalRevisions, is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 43 with CruiseConfig

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

the class ServerHealthService method onTimer.

// called from spring timer
public synchronized void onTimer(CruiseConfigProvider provider) {
    CruiseConfig currentConfig = provider.getCurrentConfig();
    purgeStaleHealthMessages(currentConfig);
    LOG.debug("Recomputing material to pipeline mappings.");
    HashMap<ServerHealthState, Set<String>> erroredPipelines = new HashMap<>();
    for (Map.Entry<HealthStateType, ServerHealthState> entry : serverHealth.entrySet()) {
        erroredPipelines.put(entry.getValue(), entry.getValue().getPipelineNames(currentConfig));
    }
    pipelinesWithErrors = erroredPipelines;
    LOG.debug("Done recomputing material to pipeline mappings.");
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CruiseConfig(com.thoughtworks.go.config.CruiseConfig)

Example 44 with CruiseConfig

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

the class DefaultWorkCreator method getWork.

public Work getWork(AgentIdentifier agentIdentifier) {
    try {
        CruiseConfig config = GoConfigMother.pipelineHavingJob(PIPELINE_NAME, STAGE_NAME, JOB_PLAN_NAME, ARTIFACT_FILE.getAbsolutePath(), ARTIFACT_FOLDER.getAbsolutePath());
        BuildCause buildCause = BuildCause.createWithEmptyModifications();
        BuildAssignment buildAssignment = BuildAssignment.create(toPlan(config), buildCause, new ArrayList<>(), new File("testdata/" + CruiseConfig.WORKING_BASE_DIR + STAGE_NAME), new EnvironmentVariableContext(), new ArtifactStores());
        return new BuildWork(buildAssignment, "utf-8");
    } catch (Exception e) {
        throw bomb(e);
    }
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) 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 45 with CruiseConfig

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

the class AutoBuild method onModifications.

public BuildCause onModifications(MaterialRevisions originalMaterialRevisions, boolean materialConfigurationChanged, MaterialRevisions previousMaterialRevisions) {
    if (originalMaterialRevisions == null || originalMaterialRevisions.isEmpty()) {
        throw new RuntimeException("Cannot find modifications, please check your SCM setting or environment.");
    }
    if (!originalMaterialRevisions.hasDependencyMaterials()) {
        return BuildCause.createWithModifications(originalMaterialRevisions, GoConstants.DEFAULT_APPROVED_BY);
    }
    CruiseConfig cruiseConfig = goConfigService.currentCruiseConfig();
    MaterialRevisions recomputedBasedOnDependencies;
    if (systemEnvironment.enforceRevisionCompatibilityWithUpstream()) {
        recomputedBasedOnDependencies = fanInOn(originalMaterialRevisions, cruiseConfig, new CaseInsensitiveString(pipelineName));
    } else {
        recomputedBasedOnDependencies = fanInOffTriangleDependency(originalMaterialRevisions, cruiseConfig);
    }
    if (recomputedBasedOnDependencies != null && canRunWithRecomputedRevisions(materialConfigurationChanged, previousMaterialRevisions, recomputedBasedOnDependencies)) {
        return BuildCause.createWithModifications(recomputedBasedOnDependencies, GoConstants.DEFAULT_APPROVED_BY);
    }
    return null;
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

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