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));
}
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));
}
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.");
}
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);
}
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class ArtifactDirValidatorTest method shouldThrowExceptionWhenUserProvidesDot.
@Test
public void shouldThrowExceptionWhenUserProvidesDot() throws Exception {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(new ServerConfig(".", null));
ArtifactDirValidator dirValidator = new ArtifactDirValidator();
try {
dirValidator.validate(cruiseConfig);
fail("should throw exception, see dot will make server check out the repository in the wrong place.");
} catch (Exception e) {
}
}
Aggregations