Search in sources :

Example 46 with WithPlugins

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

the class PluginManagerTest method uninstall_plugin.

@Test
@WithPlugins("gerrit-trigger")
public void uninstall_plugin() throws InterruptedException, ExecutionException {
    assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
    jenkins.getPluginManager().visit("installed");
    WebElement form = find(by.action("plugin/gerrit-trigger/uninstall"));
    form.submit();
    waitFor(form).until(CapybaraPortingLayerImpl::isStale);
    clickButton("Yes");
    jenkins.restart();
    jenkins.getPluginManager().visit("installed");
    assertThrows(NoSuchElementException.class, () -> find(by.url("plugin/gerrit-trigger")));
}
Also used : WebElement(org.openqa.selenium.WebElement) CapybaraPortingLayerImpl(org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 47 with WithPlugins

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

the class WorkflowPluginTest method grapeLibrary.

@WithPlugins({ "workflow-cps-global-lib@2.3", "workflow-basic-steps@2.1", "workflow-job@2.5" })
@Issue("JENKINS-26192")
@Test
public void grapeLibrary() throws Exception {
    assumeThat("TODO otherwise we would need to set up SSH access to push via Git, which seems an awful hassle", controller, instanceOf(LocalController.class));
    File workflowLibs = /* WorkflowLibRepository.workspace() */
    new File(((LocalController) controller).getJenkinsHome(), "workflow-libs");
    // Cf. GrapeTest.useBinary using JenkinsRule:
    FileUtils.write(new File(workflowLibs, "src/pkg/Lists.groovy"), "package pkg\n" + "@Grab('commons-primitives:commons-primitives:1.0')\n" + "import org.apache.commons.collections.primitives.ArrayIntList\n" + "static def arrayInt() {new ArrayIntList()}");
    WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
    job.script.set("echo(/got ${pkg.Lists.arrayInt()}/)");
    job.sandbox.check();
    job.save();
    assertThat(job.startBuild().shouldSucceed().getConsole(), containsString("got []"));
}
Also used : LocalController(org.jenkinsci.test.acceptance.controller.LocalController) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) File(java.io.File) Issue(org.jvnet.hudson.test.Issue) 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)

Example 48 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins 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)

Example 49 with WithPlugins

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

the class WorkflowPluginTest method linearFlow.

@WithPlugins({ "workflow-job", "workflow-cps@2.10", "workflow-basic-steps@2.1", "workflow-durable-task-step", "pipeline-input-step", "junit@1.18", "git@2.3" })
@Test
public void linearFlow() throws Exception {
    assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
    MavenInstallation.installMaven(jenkins, "M3", "3.5.0");
    final DumbSlave slave = (DumbSlave) slaveController.install(jenkins).get();
    slave.configure(() -> slave.labels.set("remote"));
    WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
    job.script.set("node('remote') {\n" + "  git 'https://github.com/jglick/simple-maven-project-with-tests.git'\n" + "  def v = version()\n" + "  if (v) {\n" + "    echo(/Building version $v/)\n" + "  }\n" + "  def mvnHome = tool 'M3'\n" + "  withEnv([\"PATH+MAVEN=$mvnHome/bin\", \"M2_HOME=$mvnHome\"]) {\n" + "    sh 'mvn -B -Dmaven.test.failure.ignore verify'\n" + "  }\n" + "  input 'Ready to go?'\n" + "  archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true\n" + "  junit '**/target/surefire-reports/TEST-*.xml'\n" + "}\n" + "def version() {\n" + "  def matcher = readFile('pom.xml') =~ '<version>(.+)</version>'\n" + "  matcher ? matcher[0][1] : null\n" + "}");
    job.sandbox.check();
    job.save();
    final Build build = job.startBuild();
    waitFor().until(new Wait.Predicate<Boolean>() {

        @Override
        public Boolean apply() throws Exception {
            return build.getConsole().contains("Ready to go?");
        }

        @Override
        public String diagnose(Throwable lastException, String message) {
            return "Console output:\n" + build.getConsole() + "\n";
        }
    });
    assertThat(build.getConsole(), containsString("Building version 1.0-SNAPSHOT"));
    jenkins.restart();
    // Default 120s timeout of Build.waitUntilFinished sometimes expires waiting for RetentionStrategy.Always to tick (after initial failure of CommandLauncher.launch: EOFException: unexpected stream termination):
    // TODO rather wait for build output: "Ready to run"
    slave.waitUntilOnline();
    visit(build.getConsoleUrl());
    clickLink("Proceed");
    try {
        build.shouldSucceed();
    } catch (AssertionError x) {
        // Tests in this project are currently designed to fail at random, so either status is OK.
        // TODO if resultIs were public and there were a disjunction combinator for Matcher we could use it here.
        build.shouldBeUnstable();
    }
    new Artifact(build, "target/simple-maven-project-with-tests-1.0-SNAPSHOT.jar").assertThatExists(true);
    build.open();
    clickLink("Test Result");
    assertThat(driver, hasContent("All Tests"));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) Matchers.containsString(org.hamcrest.Matchers.containsString) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) Wait(org.jenkinsci.test.acceptance.junit.Wait) IOException(java.io.IOException) Artifact(org.jenkinsci.test.acceptance.po.Artifact) 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)

Example 50 with WithPlugins

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

the class JavadocPluginTest method publish_javadoc_from_matrix_job.

@Test
@WithPlugins("matrix-project")
public void publish_javadoc_from_matrix_job() {
    MatrixProject job = jenkins.jobs.create(MatrixProject.class);
    setup(job);
    job.startBuild().shouldSucceed();
    MatrixConfiguration def = job.getConfiguration("default");
    assertThat(def, hasAction(JAVADOC_ACTION));
    assertJavadoc(def);
}
Also used : MatrixProject(org.jenkinsci.test.acceptance.po.MatrixProject) MatrixConfiguration(org.jenkinsci.test.acceptance.po.MatrixConfiguration) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Aggregations

WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)89 Test (org.junit.Test)89 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)71 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)53 Build (org.jenkinsci.test.acceptance.po.Build)39 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)31 Issue (org.jvnet.hudson.test.Issue)25 Job (org.jenkinsci.test.acceptance.po.Job)19 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)15 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)15 ListView (org.jenkinsci.test.acceptance.po.ListView)13 View (org.jenkinsci.test.acceptance.po.View)13 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)12 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)11 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)10 Matchers.containsString (org.hamcrest.Matchers.containsString)9 GlobalSecurityConfig (org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)9 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)8 Ignore (org.junit.Ignore)8 WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)5