hudson.matrix.TextAxis Java Examples

The following examples show how to use hudson.matrix.TextAxis. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JUnitResultArchiverTest.java    From junit-plugin with MIT License 6 votes vote down vote up
@Test public void specialCharsInRelativePath() throws Exception {
    Assume.assumeFalse(Functions.isWindows());
    final String ID_PREFIX = "test-../a=%3C%7C%23)/testReport/org.twia.vendor/VendorManagerTest/testCreateAdjustingFirm/";
    final String EXPECTED = "org.twia.dao.DAOException: [S2001] Hibernate encountered an error updating Claim [null]";

    MatrixProject p = j.jenkins.createProject(MatrixProject.class, "test-" + j.jenkins.getItems().size());
    p.setAxes(new AxisList(new TextAxis("a", "<|#)")));
    p.setScm(new SingleFileSCM("report.xml", getClass().getResource("junit-report-20090516.xml")));
    p.getPublishersList().add(new JUnitResultArchiver("report.xml"));

    MatrixBuild b = p.scheduleBuild2(0).get();
    j.assertBuildStatus(Result.UNSTABLE, b);

    WebClient wc = j.createWebClient();
    HtmlPage page = wc.getPage(b, "testReport");

    assertThat(page.asText(), not(containsString(EXPECTED)));

    ((HtmlAnchor) page.getElementById(ID_PREFIX + "-showlink")).click();
    wc.waitForBackgroundJavaScript(10000L);
    assertThat(page.asText(), containsString(EXPECTED));

    ((HtmlAnchor) page.getElementById(ID_PREFIX + "-hidelink")).click();
    wc.waitForBackgroundJavaScript(10000L);
    assertThat(page.asText(), not(containsString(EXPECTED)));
}
 
Example #2
Source File: GitLabEnvironmentContributorTest.java    From gitlab-plugin with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void matrixProjectTest() throws IOException, InterruptedException, ExecutionException {
    EnvVars env;
    MatrixProject p = jenkins.jenkins.createProject(MatrixProject.class, "matrixbuild");
    GitLabWebHookCause cause = new GitLabWebHookCause(generateCauseData());
    // set up 2x2 matrix
    AxisList axes = new AxisList();
    axes.add(new TextAxis("db","mysql","oracle"));
    axes.add(new TextAxis("direction","north","south"));
    p.setAxes(axes);

    MatrixBuild build = p.scheduleBuild2(0, cause).get();
    List<MatrixRun> runs = build.getRuns();
    assertEquals(4,runs.size());
    for (MatrixRun run : runs) {
        env = run.getEnvironment(listener);
        assertNotNull(env.get("db"));
        assertEnv(env);
    }
}
 
Example #3
Source File: MatrixJobITest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * Build a matrix job with three configurations. For each configuration a different set of warnings will be parsed
 * with the same parser (GCC). After the successful build the total number of warnings at the root level should be
 * set to 12 (sum of all three configurations). Moreover, for each configuration the total number of warnings is
 * also verified (4, 6, and 2 warnings).
 *
 * @throws Exception in case of an error
 */
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
@Test
public void shouldCreateIndividualAxisResults() throws Exception {
    MatrixProject project = createProject(MatrixProject.class);
    copySingleFileToWorkspace(project, "matrix-warnings-one.txt", "user_axis/one/warnings.txt");
    copySingleFileToWorkspace(project, "matrix-warnings-two.txt", "user_axis/two/warnings.txt");
    copySingleFileToWorkspace(project, "matrix-warnings-three.txt", "user_axis/three/warnings.txt");
    IssuesRecorder publisher = new IssuesRecorder();
    Gcc4 tool = new Gcc4();
    tool.setPattern("**/*.txt");
    publisher.setTools(tool);
    project.getPublishersList().add(publisher);

    AxisList axis = new AxisList();
    TextAxis userAxis = new TextAxis("user_axis", "one two three");
    axis.add(userAxis);
    project.setAxes(axis);

    Map<String, Integer> warningsPerAxis = new HashMap<>();
    warningsPerAxis.put("one", 4);
    warningsPerAxis.put("two", 6);
    warningsPerAxis.put("three", 2);

    MatrixBuild build = project.scheduleBuild2(0).get();
    for (MatrixRun run : build.getRuns()) {
        getJenkins().assertBuildStatus(Result.SUCCESS, run);

        AnalysisResult result = getAnalysisResult(run);

        String currentAxis = run.getBuildVariables().values().iterator().next();
        assertThat(result.getTotalSize()).as("Result of axis " + currentAxis).isEqualTo(warningsPerAxis.get(currentAxis));
    }
    AnalysisResult aggregation = getAnalysisResult(build);
    assertThat(aggregation.getTotalSize()).isEqualTo(12);
}
 
Example #4
Source File: MatrixProjectITest.java    From github-integration-plugin with MIT License 5 votes vote down vote up
@Test
public void testChildStatuses() throws Exception {
    final MatrixProject matrixProject = jRule.jenkins.createProject(MatrixProject.class, "matrix-project");

    matrixProject.addProperty(getPreconfiguredProperty(ghRule.getGhRepo()));
    matrixProject.addTrigger(getPreconfiguredPRTrigger());

    matrixProject.getBuildersList().add(new GitHubPRStatusBuilder());
    matrixProject.getBuildersList().add(new Shell("sleep 10"));

    matrixProject.getPublishersList().add(new GitHubPRBuildStatusPublisher());
    matrixProject.getPublishersList().add(new GitHubPRCommentPublisher(new GitHubPRMessage("Comment"), null, null));

    matrixProject.setAxes(
            new AxisList(
                    new TextAxis("first_axis", "first_value1", "first_value2"),
                    new TextAxis("second_axis", "sec_value1", "sec_value2")
            )
    );

    matrixProject.save();

    super.basicTest(matrixProject);

    for (MatrixBuild build : matrixProject.getBuilds()) {
        for (MatrixRun matrixRun : build.getRuns()) {
            jRule.assertLogNotContains("\tat", matrixRun);
        }
    }
}
 
Example #5
Source File: AbortRunningJobRunnerCauseTest.java    From github-integration-plugin with MIT License 4 votes vote down vote up
@Test
@RandomlyFails(value = "No idea why matrix doesn't work normally")
public void testAbortRunningMatrixProject() throws Exception {

    MockFolder folder = j.createFolder("Matrix_folder");

    MatrixProject job1 = folder.createProject(MatrixProject.class, "project1");
    job1.setDisplayName("project1 display name");
    job1.setConcurrentBuild(true);
    job1.getBuildersList().add(new SleepBuilder());
    job1.setAxes(
            new AxisList(
                    new TextAxis("first_axis", "first_value1"),
                    new TextAxis("second_axis", "sec_value1")
            )
    );
    configRoundTripUnsecure(job1);
    job1.save();

    MatrixProject job2 = folder.createProject(MatrixProject.class, "project2");
    job2.setDisplayName("project1 display name");
    job2.setConcurrentBuild(true);
    job2.getBuildersList().add(new SleepBuilder());
    job2.setAxes(
            new AxisList(
                    new TextAxis("first_axis", "first_value1"),
                    new TextAxis("second_axis", "sec_value1")
            )
    );
    configRoundTripUnsecure(job2);
    job2.save();

    MatrixProject job3 = folder.createProject(MatrixProject.class, "project3");
    job3.setDisplayName("project1 display name");
    job3.setConcurrentBuild(true);
    job3.getBuildersList().add(new SleepBuilder());
    job3.setAxes(
            new AxisList(
                    new TextAxis("first_axis", "first_value1"),
                    new TextAxis("second_axis", "sec_value1")
            )
    );
    configRoundTripUnsecure(job3);
    job3.save();

    testAbortRunning(job1, job2, job3);

    assertThat(job1.getBuilds(), hasSize(3));

    for (MatrixBuild matrixBuild : job1.getBuilds()) {
        assertThat(matrixBuild.getResult(), is(Result.ABORTED));
        assertThat(matrixBuild.getRuns(), not(empty()));
        for (MatrixRun matrixRun : matrixBuild.getRuns()) {
            assertThat(matrixRun.getResult(), is(Result.ABORTED));
        }
    }
}