Search in sources :

Example 1 with GerritTriggerJob

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());
    }
}
Also used : GerritTriggerNewServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer) GerritTriggerServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer) Build(org.jenkinsci.test.acceptance.po.Build) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) IOException(java.io.IOException) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 2 with GerritTriggerJob

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());
    }
}
Also used : GerritTriggerNewServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer) GerritTriggerServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer) Build(org.jenkinsci.test.acceptance.po.Build) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) IOException(java.io.IOException) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 3 with GerritTriggerJob

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());
    }
}
Also used : GerritTriggerNewServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer) GerritTriggerServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer) Build(org.jenkinsci.test.acceptance.po.Build) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) IOException(java.io.IOException) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 4 with GerritTriggerJob

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());
    }
}
Also used : GerritTriggerNewServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer) GerritTriggerServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer) Build(org.jenkinsci.test.acceptance.po.Build) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) IOException(java.io.IOException) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 5 with GerritTriggerJob

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());
    }
}
Also used : GerritTriggerNewServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer) GerritTriggerServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer) Build(org.jenkinsci.test.acceptance.po.Build) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) IOException(java.io.IOException) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)5 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)5 GerritTriggerJob (org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob)5 GerritTriggerNewServer (org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer)5 GerritTriggerServer (org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer)5 Build (org.jenkinsci.test.acceptance.po.Build)5 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)5 Job (org.jenkinsci.test.acceptance.po.Job)5 Test (org.junit.Test)5