use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class PipelinePauseServiceIntegrationTest method shouldTruncatePauseMessageIfGreaterThanAllowedLength.
@Test
public void shouldTruncatePauseMessageIfGreaterThanAllowedLength() throws Exception {
String name = "pipeline-name";
CruiseConfig cruiseConfig = GoConfigMother.configWithPipelines(name);
configHelper.writeConfigFile(cruiseConfig);
cachedGoConfig.forceReload();
Username userName = new Username(new CaseInsensitiveString("UserFoo"));
pipelinePauseService.pause(name, "tiny pause cause", userName);
assertThat(pipelinePauseService.pipelinePauseInfo(name).getPauseCause(), is("tiny pause cause"));
pipelinePauseService.unpause(name);
String stringWith255Chars = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
pipelinePauseService.pause(name, stringWith255Chars + "aa", userName);
assertThat(pipelinePauseService.pipelinePauseInfo(name).getPauseCause(), is(stringWith255Chars));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class ConfigRepoServiceIntegrationTest method shouldUpdateSpecifiedConfigRepository.
@Test
public void shouldUpdateSpecifiedConfigRepository() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
configHelper.enableSecurity();
goConfigDao.updateConfig(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
cruiseConfig.getConfigRepos().add(configRepo);
return cruiseConfig;
}
});
String newRepoId = "repo-2";
ConfigRepoConfig toUpdateWith = new ConfigRepoConfig(new GitMaterialConfig("http://bar.git", "master"), "yaml-plugin", newRepoId);
assertThat(configRepoService.getConfigRepos().size(), is(1));
assertThat(configRepoService.getConfigRepo(repoId), is(configRepo));
configRepoService.updateConfigRepo(repoId, toUpdateWith, entityHashingService.md5ForEntity(configRepo), user, result);
assertThat(result.toString(), result.isSuccessful(), Is.is(true));
assertThat(configRepoService.getConfigRepos().size(), is(1));
assertThat(configRepoService.getConfigRepo(newRepoId), is(toUpdateWith));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class FaninDependencyResolutionTest method shouldPickTheRightRevisionsWhenMaterialIsRemovedAndPutBack.
@Test
public void shouldPickTheRightRevisionsWhenMaterialIsRemovedAndPutBack() {
GitMaterial git1 = u.wf(new GitMaterial("git1-url"), "git-folder1");
GitMaterial git2 = u.wf(new GitMaterial("git2-url"), "git-folder2");
GitMaterial git3 = u.wf(new GitMaterial("git3-url"), "git-folder3");
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(git1), u.m(git2));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(git2));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(p1), u.m(p2), u.m(git1));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p3), u.m(git2));
u.checkinInOrder(git1, "git1_1");
u.checkinInOrder(git2, "git2_1");
String p1_1 = u.runAndPass(p1, "git1_1", "git2_1");
String p2_1 = u.runAndPass(p2, "git2_1");
String p3_1 = u.runAndPass(p3, p1_1, p2_1, "git1_1");
String p4_1 = u.runAndPass(p4, p3_1, "git2_1");
u.checkinInOrder(git1, "git1_2");
u.checkinInOrder(git2, "git2_2");
String p1_2 = u.runAndPass(p1, "git1_2", "git2_2");
String p2_2 = u.runAndPass(p2, "git2_2");
String p3_2 = u.runAndPass(p3, p1_2, p2_2, "git1_2");
String p4_2 = u.runAndPass(p4, p3_2, "git2_2");
configHelper.setMaterialConfigForPipeline("P2", git3.config());
CruiseConfig cruiseConfig = goConfigDao.load();
p2 = new ScheduleTestUtil.AddedPipeline(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("P2")), p2.material);
u.checkinInOrder(git1, "git1_3");
u.checkinInOrder(git2, "git2_3");
u.checkinInOrder(git3, "git3_1");
String p1_3 = u.runAndPass(p1, "git1_3", "git2_3");
String p2_3 = u.runAndPass(p2, "git3_1");
String p3_3 = u.runAndPass(p3, p1_3, p2_3, "git1_3");
// check wat happens to p4
MaterialRevisions given = u.mrs(new MaterialRevision[] { u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3) });
MaterialRevisions expected = u.mrs(new MaterialRevision[] { u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3) });
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
assertThat(finalRevisions, is(expected));
// bring back git2 in p2
configHelper.setMaterialConfigForPipeline("P2", git2.config());
cruiseConfig = goConfigDao.load();
p2 = new ScheduleTestUtil.AddedPipeline(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("P2")), p2.material);
// check wat happend to p4
given = u.mrs(u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3));
expected = u.mrs(new MaterialRevision[] { u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3) });
finalRevisions = getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
assertThat(finalRevisions, is(expected));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class FaninDependencyResolutionTest method shouldRestoreMaterialNamesBasedOnMaterialConfig.
@Test
public void shouldRestoreMaterialNamesBasedOnMaterialConfig() throws Exception {
/*
g -> up -> down
+-> mid -+
*/
GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
u.checkinInOrder(git, "g1");
ScheduleTestUtil.AddedPipeline up = u.saveConfigWith("up", u.m(git));
ScheduleTestUtil.MaterialDeclaration upForMid = u.m(up);
((DependencyMaterial) upForMid.material).setName(new CaseInsensitiveString("up-for-mid"));
ScheduleTestUtil.AddedPipeline mid = u.saveConfigWith("mid", upForMid);
ScheduleTestUtil.MaterialDeclaration upForDown = u.m(up);
((DependencyMaterial) upForDown.material).setName(new CaseInsensitiveString("up-for-down"));
ScheduleTestUtil.AddedPipeline down = u.saveConfigWith("down", u.m(mid), upForDown);
CruiseConfig cruiseConfig = goConfigDao.load();
String up_1 = u.runAndPass(up, "g1");
String mid_1 = u.runAndPass(mid, up_1);
String down_1 = u.runAndPass(down, mid_1, up_1);
MaterialRevisions given = u.mrs(u.mr(mid, false, mid_1), u.mr(up, false, up_1));
MaterialRevisions revisionsBasedOnDependencies = getRevisionsBasedOnDependencies(down, cruiseConfig, given);
for (MaterialRevision revisionsBasedOnDependency : revisionsBasedOnDependencies) {
DependencyMaterial dependencyPipeline = (DependencyMaterial) revisionsBasedOnDependency.getMaterial();
if (dependencyPipeline.getPipelineName().equals(new CaseInsensitiveString("up"))) {
assertThat(dependencyPipeline.getName(), is(new CaseInsensitiveString("up-for-down")));
}
}
assertThat(revisionsBasedOnDependencies, is(given));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class FaninDependencyResolutionTest method shouldResolveWithModifiedStageDefinitionOfRootNode.
@Test
public void shouldResolveWithModifiedStageDefinitionOfRootNode() throws Exception {
/**
* git -------+
* | |
* | |
* v v
* P1 -----> P2
*/
GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
String[] git_revs = { "g1", "g2" };
int i = 0;
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(p1), u.m(git));
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1");
setMaxBackTrackLimit(2);
for (int j = 1; j <= maxBackTrackLimit() + 1; j++) {
u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1, "g1");
}
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2");
p2 = u.changeStagenameForToPipeline("P2", "s", "new-stage");
CruiseConfig cruiseConfig = goConfigDao.load();
MaterialRevisions given = u.mrs(u.mr(p1, true, p1_2), u.mr(git, true, "g2"));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p2, cruiseConfig, given);
assertThat(finalRevisions, is(given));
}
Aggregations