Search in sources :

Example 1 with Native

use of org.jenkinsci.test.acceptance.junit.Native in project acceptance-test-harness by jenkinsci.

the class GroovyPluginTest method use_native_groovy.

@Test
@Native("groovy")
public void use_native_groovy() {
    GroovyInstallation groovy = ToolInstallation.addTool(jenkins, GroovyInstallation.class);
    groovy.name.set("local-groovy");
    groovy.useNative();
    groovy.getPage().save();
    configureJob();
    final GroovyStep step = job.addBuildStep(GroovyStep.class);
    step.version.select("local-groovy");
    step.script("println 'version: ' + groovy.lang.GroovySystem.getVersion()");
    job.save();
    Build build = job.startBuild().shouldSucceed();
    String expectedVersion = localGroovyVersion();
    build.shouldContainsConsoleOutput("version: " + expectedVersion);
}
Also used : GroovyStep(org.jenkinsci.test.acceptance.plugins.groovy.GroovyStep) SystemGroovyStep(org.jenkinsci.test.acceptance.plugins.groovy.SystemGroovyStep) GroovyInstallation(org.jenkinsci.test.acceptance.plugins.groovy.GroovyInstallation) Build(org.jenkinsci.test.acceptance.po.Build) Native(org.jenkinsci.test.acceptance.junit.Native) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 2 with Native

use of org.jenkinsci.test.acceptance.junit.Native in project acceptance-test-harness by jenkinsci.

the class JdkTest method usePreinstalledJdk.

// This actually tests any installed JDK, not necessarily oracle.
@Test
@Native("java")
public void usePreinstalledJdk() {
    String expectedVersion = localJavaVersion();
    JdkInstallation jdk = ToolInstallation.addTool(jenkins, JdkInstallation.class);
    jdk.name.set("preinstalled");
    jdk.useNative();
    jdk.getPage().save();
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    job.addShellStep("java -version");
    job.save();
    job.startBuild().shouldSucceed().shouldContainsConsoleOutput(expectedVersion);
}
Also used : JdkInstallation(org.jenkinsci.test.acceptance.po.JdkInstallation) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Native(org.jenkinsci.test.acceptance.junit.Native) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 3 with Native

use of org.jenkinsci.test.acceptance.junit.Native in project acceptance-test-harness by jenkinsci.

the class AntPluginTest method locallyInstalledAnt.

@Test
@Native("ant")
public void locallyInstalledAnt() {
    AntInstallation ant = ToolInstallation.addTool(jenkins, AntInstallation.class);
    ant.name.set("native_ant");
    String antHome = ant.useNative();
    ant.getPage().save();
    job.configure();
    job.copyResource(resource("ant/echo-helloworld.xml"), "build.xml");
    AntBuildStep step = job.addBuildStep(AntBuildStep.class);
    step.antName.select("native_ant");
    step.targets.set("-version");
    job.save();
    String expectedVersion = localAntVersion(antHome);
    job.startBuild().shouldSucceed().shouldContainsConsoleOutput(Pattern.quote(expectedVersion));
}
Also used : AntBuildStep(org.jenkinsci.test.acceptance.plugins.ant.AntBuildStep) AntInstallation(org.jenkinsci.test.acceptance.plugins.ant.AntInstallation) Native(org.jenkinsci.test.acceptance.junit.Native) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 4 with Native

use of org.jenkinsci.test.acceptance.junit.Native in project acceptance-test-harness by jenkinsci.

the class WorkflowPluginTest method parallelTests.

@WithPlugins({ "workflow-job", "workflow-cps@2.10", "workflow-basic-steps@2.1", "workflow-durable-task-step", "parallel-test-executor@1.11", "junit@1.18", "git@2.3" })
@Native("mvn")
@Test
public void parallelTests() throws Exception {
    for (int i = 0; i < 3; i++) {
        slaveController.install(jenkins);
    }
    WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
    job.script.set("node('built-in || master') {\n" + // TODO could be switched to multibranch, in which case this initial `node` is unnecessary, and each branch can just `checkout scm`
    "  git 'https://github.com/jenkinsci/parallel-test-executor-plugin-sample.git'\n" + "  stash 'sources'\n" + "}\n" + "def splits = splitTests parallelism: count(3), estimateTestsFromFiles: true\n" + "def branches = [:]\n" + "for (int i = 0; i < splits.size(); i++) {\n" + "  def exclusions = splits.get(i);\n" + "  branches[\"split${i}\"] = {\n" + "    node('!master') {\n" + "      sh 'rm -rf *'\n" + "      unstash 'sources'\n" + "      writeFile file: 'exclusions.txt', text: exclusions.join(\"\\n\")\n" + // TODO would be useful for ToolInstallation to support the URL installer, hosting the tool ZIP ourselves somewhere cached.
    "      sh 'mvn -B -Dmaven.test.failure.ignore test'\n" + "      junit 'target/surefire-reports/*.xml'\n" + "    }\n" + "  }\n" + "}\n" + "parallel branches");
    job.sandbox.check();
    job.save();
    Build build = job.startBuild();
    try {
        build.shouldSucceed();
    } catch (AssertionError x) {
        // cf. linearFlow
        build.shouldBeUnstable();
    }
    assertThat(build.getConsole(), containsString("No record available"));
    build = job.startBuild();
    try {
        build.shouldSucceed();
    } catch (AssertionError x) {
        build.shouldBeUnstable();
    }
    assertThat(build.getConsole(), containsString("divided into 3 sets"));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) Native(org.jenkinsci.test.acceptance.junit.Native) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Aggregations

AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)4 Native (org.jenkinsci.test.acceptance.junit.Native)4 Test (org.junit.Test)4 Build (org.jenkinsci.test.acceptance.po.Build)2 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)1 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)1 AntBuildStep (org.jenkinsci.test.acceptance.plugins.ant.AntBuildStep)1 AntInstallation (org.jenkinsci.test.acceptance.plugins.ant.AntInstallation)1 GroovyInstallation (org.jenkinsci.test.acceptance.plugins.groovy.GroovyInstallation)1 GroovyStep (org.jenkinsci.test.acceptance.plugins.groovy.GroovyStep)1 SystemGroovyStep (org.jenkinsci.test.acceptance.plugins.groovy.SystemGroovyStep)1 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)1 JdkInstallation (org.jenkinsci.test.acceptance.po.JdkInstallation)1 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)1