use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class GerritTriggerTest method gerrit_trigger_build_when_changes_merged.
@Test
public void gerrit_trigger_build_when_changes_merged() {
GerritTriggerNewServer newServer = new GerritTriggerNewServer(jenkins);
newServer.saveNewTestServerConfigIfNone(gtHostname);
GerritTriggerServer server = new GerritTriggerServer(jenkins, gtHostname);
server.saveTestServerConfig(gtHostname, gtGerritFrontUrl, gtGerrituser, gtPrivateKey);
Job j = jenkins.jobs.create(FreeStyleJob.class);
String jobName = j.name;
GerritTriggerJob job = new GerritTriggerJob(jenkins, jobName);
job.saveTestJobConfig(GerritTriggerJob.EventToTriggerOn.ChangeMerged, gtHostname, gtProject);
try {
String changeId = pushChangeForMerge(jobName);
changes.add(changeId);
Build b = new Build(j, j.getNextBuildNumber());
assertTrue(b.waitUntilFinished().isSuccess());
elasticSleep(10000);
ProcessBuilder gerritQuery = new ProcessBuilder("ssh", "-p", "29418", "-i", gtPrivateKey, gtGerrituser + "@" + gtHostname, "gerrit", "query", "change_id=" + changeId, "--all-approvals", "--format JSON");
String json = removeLastLine(stringFrom(logProcessBuilderIssues(gerritQuery, "gerrit query")));
checkApprovalValueFromJSON(json, "Verified", 1);
checkApprovalValueFromJSON(json, "Code-Review", 1);
} catch (InterruptedException | IOException e) {
fail(e.getMessage());
}
}
use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class JobsGridPortlet method getJob.
/**
* Opens and returns the job at the given position in the grid.
*
* @param column the column of the job
* @param row the row of the job
* @return The job at the given position. Null if the position exists, but is empty.
* @throws NoSuchElementException if column or row are below 0 or higher than the column- or row-number of the grid.
*/
@CheckForNull
public Job getJob(int row, int column) throws NoSuchElementException {
getPage().open();
getTable().findElement(By.xpath("//tbody/tr[" + row + "]/td[" + column + "]"));
try {
WebElement link = getTable().findElement(By.xpath("//tbody/tr[" + row + "]/td[" + column + "]/a[2]"));
String name = link.getText();
URL url = new URL(link.getAttribute("href"));
return new Job(injector, url, name);
} catch (NoSuchElementException e) {
// position exists in grid, but is empty
return null;
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class GerritTriggerTest method gerrit_trigger_build_when_draft_published.
@Test
public void gerrit_trigger_build_when_draft_published() {
GerritTriggerNewServer newServer = new GerritTriggerNewServer(jenkins);
newServer.saveNewTestServerConfigIfNone(gtHostname);
GerritTriggerServer server = new GerritTriggerServer(jenkins, gtHostname);
server.saveTestServerConfig(gtHostname, gtGerritFrontUrl, gtGerrituser, gtPrivateKey);
Job j = jenkins.jobs.create(FreeStyleJob.class);
GerritTriggerJob job = new GerritTriggerJob(jenkins, j.name);
job.saveTestJobConfig(GerritTriggerJob.EventToTriggerOn.DraftPublished, gtHostname, gtProject);
try {
String changeId = pushDraftForPublishing(j.name);
changes.add(changeId);
Build b = new Build(j, j.getNextBuildNumber());
assertTrue(b.waitUntilFinished().isSuccess());
elasticSleep(10000);
ProcessBuilder gerritQuery = new ProcessBuilder("ssh", "-p", "29418", "-i", gtPrivateKey, gtGerrituser + "@" + gtHostname, "gerrit", "query", "change_id=" + changeId, "--all-approvals", "--format JSON");
String json = removeLastLine(stringFrom(logProcessBuilderIssues(gerritQuery, "gerrit query")));
LOGGER.info(json);
checkApprovalValueFromJSON(json, "Verified", 1);
checkApprovalValueFromJSON(json, "Code-Review", 1);
} catch (InterruptedException | IOException e) {
fail(e.getMessage());
}
}
use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class GerritTriggerTest method gerrit_has_review_flags_checked_after_jenkins_set_them.
@Test
public void gerrit_has_review_flags_checked_after_jenkins_set_them() {
GerritTriggerNewServer newServer = new GerritTriggerNewServer(jenkins);
newServer.saveNewTestServerConfigIfNone(gtHostname);
GerritTriggerServer server = new GerritTriggerServer(jenkins, gtHostname);
server.saveTestServerConfig(gtHostname, gtGerritFrontUrl, gtGerrituser, gtPrivateKey);
Job j = jenkins.jobs.create(FreeStyleJob.class);
String jobName = j.name;
GerritTriggerJob job = new GerritTriggerJob(jenkins, jobName);
job.saveTestJobConfig(GerritTriggerJob.EventToTriggerOn.PatchsetCreated, gtHostname, gtProject);
try {
String changeId = pushChangeForReview(jobName).changeId;
changes.add(changeId);
Build b = new Build(j, j.getNextBuildNumber());
assertTrue(b.waitUntilFinished().isSuccess());
elasticSleep(10000);
ProcessBuilder gerritQuery = new ProcessBuilder("ssh", "-p", "29418", "-i", gtPrivateKey, gtGerrituser + "@" + gtHostname, "gerrit", "query", "change_id=" + changeId, "--all-approvals", "--format JSON");
String json = removeLastLine(stringFrom(logProcessBuilderIssues(gerritQuery, "gerrit query")));
checkApprovalValueFromJSON(json, "Verified", 1);
checkApprovalValueFromJSON(json, "Code-Review", 1);
} catch (InterruptedException | IOException e) {
fail(e.getMessage());
}
}
use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_create_job.
@Test
@WithPlugins({ "sidebar-link", "build-name-setter", "envinject" })
public void should_create_job() {
// Arrange
String jobName = "MyJob";
String jobDescription = "My sample description";
String jobDisplayName = "My job display name";
String jobLabel = "!ubuntu";
String linkUrl = "https://jenkins.io";
String linkLabel = "jenkins.io";
String jobDslScript = String.format(multiline("job('%s') {", " description('%s');", " displayName('%s');", " label('%s');", " customWorkspace('/tmp/custom-workspace')", " environmentVariables(varname: 'varval')", " properties {", " sidebarLinks {", " link('%s', '%s')", " }", " };", " wrappers { buildName('custom-name') }", " concurrentBuild();", " steps {", " shell('sleep 10')", " }", "}"), jobName, jobDescription, jobDisplayName, jobLabel, linkUrl, linkLabel);
Job seed = createSeedJobWithJobDsl(jobDslScript);
seed.startBuild().shouldSucceed();
// Verify configuration
Job job = jenkins.jobs.get(Job.class, jobName);
job.open();
assertThat(job.getDescription(), containsString(jobDescription));
assertThat(job.getDisplayName(), containsString(jobDisplayName));
assertThat(driver, hasElement(by.href(linkUrl)));
job.configure();
WebElement labelElement = driver.findElement(By.xpath("//input[@name='_.label']"));
assertEquals(jobLabel, labelElement.getAttribute("value"));
Build build = job.scheduleBuild().waitUntilStarted();
{
// Verify concurrent build
Build secondBuild = job.scheduleBuild().waitUntilStarted();
assertTrue(build.isInProgress());
assertTrue(secondBuild.isInProgress());
build.stop();
secondBuild.stop();
build.waitUntilFinished();
secondBuild.waitUntilFinished();
}
build.open();
assertThat(build.getDisplayName(), containsString("custom-name"));
build.open();
driver.findElement(By.partialLinkText("Environment Variables")).click();
assertThat(driver, hasElement(by.xpath(String.format("//tr/td[contains(text(), '%s')]", "varname"))));
assertThat(build.getConsole(), containsString("/tmp/custom-workspace"));
}
Aggregations