Search in sources :

Example 1 with MissionControlView

use of org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView in project acceptance-test-harness by jenkinsci.

the class MissionControlTest method testJobStatuses.

/**
 * Test Case: Check the correct highlighting of different jobs statuses.
 */
@Test
public void testJobStatuses() {
    // create new mission control view and configure it
    MissionControlView view = jenkins.views.create(MissionControlView.class, "mission-control-sample-view");
    view.configure();
    view.setHideBuildHistory(false);
    view.setHideJobs(false);
    view.save();
    view.reloadConfiguration();
    // create freestyle jobs with different statuses
    String strJobNotBuild = "simple-job-not-build";
    String strBuildSuccess = "simple-job-success";
    String strBuildFailed = "simple-job-failed";
    FreeStyleJob jobNotBuild = jenkins.jobs.create(FreeStyleJob.class, strJobNotBuild);
    FreeStyleJob jobSuccess = jenkins.jobs.create(FreeStyleJob.class, strBuildSuccess);
    jobSuccess.startBuild().waitUntilFinished();
    FreeStyleJob jobFailed = jenkins.jobs.create(FreeStyleJob.class, strBuildFailed);
    jobFailed.configure();
    // add invalid shell build step to cause the job to fail
    jobFailed.addShellStep("sh <");
    jobFailed.save();
    jobFailed.startBuild().waitUntilFinished();
    view.open();
    // check for the correct highlighting of the jobs
    assertThat(view.getJobStatusArea().getStatusOfJob(strJobNotBuild), containsString("invert-text-color"));
    assertThat(view.getJobStatusArea().getStatusOfJob(strBuildSuccess), containsString("success"));
    assertThat(view.getJobStatusArea().getStatusOfJob(strBuildFailed), containsString("danger"));
}
Also used : MissionControlView(org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView) Matchers.containsString(org.jenkinsci.test.acceptance.Matchers.containsString) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 2 with MissionControlView

use of org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView in project acceptance-test-harness by jenkinsci.

the class MissionControlTest method testBuildQueue.

/**
 * Test the existence and number of builds in the queue.
 */
@Test
public void testBuildQueue() {
    MissionControlView view = jenkins.views.create(MissionControlView.class, "mission-control-sample-view");
    view.configure(() -> view.setHideBuildQueue(true));
    view.open();
    assertThat(driver, not(hasContent("Build queue")));
    view.configure(() -> view.setHideBuildQueue(false));
    JenkinsConfig master = jenkins.getConfigPage();
    master.configure(() -> master.labels.set("notQueued"));
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, "queuedJob");
    job.configure(() -> job.setLabelExpression("queued"));
    job.scheduleBuild();
    view.open();
    assertThat(view.getBuildQueueArea().getBuildQueueSize(), is(1));
    job.configure(() -> job.setLabelExpression("notQueued"));
    job.getLastBuild().waitUntilFinished();
    view.open();
    assertThat(view.getBuildQueueArea().getBuildQueueSize(), is(0));
}
Also used : MissionControlView(org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView) JenkinsConfig(org.jenkinsci.test.acceptance.po.JenkinsConfig) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 3 with MissionControlView

use of org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView in project acceptance-test-harness by jenkinsci.

the class MissionControlTest method testBuildHistory.

/**
 * Test Case: Check the existence and size of the build history, as well as
 * the correct highlighting of the builds.
 */
@Test
public void testBuildHistory() {
    // Create new mission control view and configure it
    int historySize = 8;
    MissionControlView view = jenkins.views.create(MissionControlView.class, "mission-control-sample-view");
    view.configure();
    view.setHideBuildHistory(false);
    view.setHistorySize(historySize);
    view.save();
    String strSimpleJob = "simple-job";
    String strFailedJob = "simple-failed-job";
    // Create new freestyle job and build it n-times
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, strSimpleJob);
    for (int i = 0; i < historySize; ++i) {
        job.startBuild().waitUntilFinished();
    }
    job = jenkins.jobs.create(FreeStyleJob.class, strFailedJob);
    job.configure();
    // Add invalid shell build step to cause the job to fail
    job.addShellStep("sh <");
    job.save();
    job.startBuild().waitUntilFinished();
    // Open mission control view and assert that no build entries are being displayed
    // (after the creation of a new mission control view the configuration needs to be reloaded)
    view.open();
    assertThat(view.getBuildHistoryArea().getBuildHistorySize(), is(0));
    // Reload configuration (alternative: jenkins.restart(), very inefficient for this task)
    view.reloadConfiguration();
    // Open mission control view again and assert that the n-builds are being displayed now
    view.open();
    assertThat(view.getBuildHistoryArea().getBuildHistorySize(), is(historySize));
    // Check for correct highlighting of the builds
    // Also, according to the made settings, there should be 1 failed and historySize - 1 successful builds
    // in the build history
    assertThat(view.getBuildHistoryArea().getFailedBuildsOfJob(strFailedJob), hasSize(1));
    assertThat(view.getBuildHistoryArea().getSuccessfulBuildsOfJob(strSimpleJob), hasSize(historySize - 1));
}
Also used : MissionControlView(org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView) Matchers.containsString(org.jenkinsci.test.acceptance.Matchers.containsString) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 4 with MissionControlView

use of org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView in project acceptance-test-harness by jenkinsci.

the class MissionControlTest method testNodeStatuses.

/**
 * Test the correct highlighting of jenkins nodes.
 */
@Test
public void testNodeStatuses() {
    MissionControlView view = jenkins.views.create(MissionControlView.class, "mission-control-sample-view");
    view.configure(() -> view.setHideNodes(true));
    view.open();
    assertThat(driver, not(hasContent("Nodes")));
    DumbSlave slave = jenkins.slaves.create(DumbSlave.class, "test");
    slave.configure(() -> slave.setExecutors(15));
    view.configure(() -> view.setHideNodes(false));
    view.open();
    assertThat(view.getNodeStatusArea().getNumberOfNodes(), is(2));
    assertThat(view.getNodeStatusArea().getStatusOfNode("test / 15"), containsString("danger"));
    assertThat(view.getNodeStatusArea().getStatusOfNode("master / 2"), containsString("success"));
}
Also used : MissionControlView(org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)4 MissionControlView (org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView)4 Test (org.junit.Test)4 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)3 Matchers.containsString (org.jenkinsci.test.acceptance.Matchers.containsString)2 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)1 JenkinsConfig (org.jenkinsci.test.acceptance.po.JenkinsConfig)1