use of org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob in project acceptance-test-harness by jenkinsci.
the class GerritTriggerTest method build_is_triggered_after_comment_is_added.
@Test
public void build_is_triggered_after_comment_is_added() {
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.CommentAdded, gtHostname, gtProject);
try {
GitLogResult gitLogResult = pushChangeForReview(jobName);
addComment(gitLogResult.commitId);
changes.add(gitLogResult.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=" + gitLogResult.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.plugins.gerrit_trigger.GerritTriggerJob in project acceptance-test-harness by jenkinsci.
the class GerritTriggerTest method build_is_triggered_after_ref_is_updated.
@Test
public void build_is_triggered_after_ref_is_updated() {
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.RefUpdated, gtHostname, gtProject);
try {
pushChangeToGerritNotForReview(jobName);
Build b = new Build(j, j.getNextBuildNumber());
assertTrue(b.waitUntilFinished().isSuccess());
elasticSleep(10000);
} catch (InterruptedException | IOException e) {
fail(e.getMessage());
}
}
use of org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob 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.plugins.gerrit_trigger.GerritTriggerJob 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.plugins.gerrit_trigger.GerritTriggerJob 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());
}
}
Aggregations