Search in sources :

Example 6 with WithCredentials

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

the class OpenstackCloudPluginTest method useSingleUseSlave.

@Test
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { MACHINE_USERNAME, "/openstack_plugin/unsafe" })
@TestActivation({ "HARDWARE_ID", "IMAGE_ID", "KEY_PAIR_NAME", "NETWORK_ID" })
public void useSingleUseSlave() {
    configureCloudInit("cloud-init");
    configureProvisioning("SSH", "label");
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    job.setLabelExpression("label");
    job.addBuildWrapper(OpenstackOneOffSlave.class);
    job.save();
    Build build = job.scheduleBuild().waitUntilFinished(PROVISIONING_TIMEOUT).shouldSucceed();
    assertTrue(build.getNode().isTemporarillyOffline());
}
Also used : MatrixBuild(org.jenkinsci.test.acceptance.po.MatrixBuild) Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) TestActivation(org.jenkinsci.test.acceptance.junit.TestActivation)

Example 7 with WithCredentials

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

the class OpenstackCloudPluginTest method provisionSshSlave.

@Test
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { MACHINE_USERNAME, "/openstack_plugin/unsafe" })
@TestActivation({ "HARDWARE_ID", "IMAGE_ID", "KEY_PAIR_NAME", "NETWORK_ID" })
public void provisionSshSlave() {
    configureCloudInit("cloud-init");
    configureProvisioning("SSH", "label");
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    job.setLabelExpression("label");
    job.save();
    job.scheduleBuild().waitUntilFinished(PROVISIONING_TIMEOUT).shouldSucceed();
}
Also used : FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) TestActivation(org.jenkinsci.test.acceptance.junit.TestActivation)

Example 8 with WithCredentials

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

the class WarningsPluginTest method should_parse_codenarc_on_agent.

@Test
@Issue("JENKINS-17787")
@WithPlugins({ "violations", "ssh-slaves" })
@WithDocker
@Ignore("Reproduces JENKINS-17787")
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
public void should_parse_codenarc_on_agent() {
    DumbSlave dockerSlave = createDockerAgent();
    FreeStyleJob job = prepareDockerSlave(dockerSlave);
    assertThatCodeNarcActionExists(job);
}
Also used : FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) Ignore(org.junit.Ignore) Issue(org.jvnet.hudson.test.Issue) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 9 with WithCredentials

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

the class WarningsPluginTest method should_scan_console_log_of_slave_build.

@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_scan_console_log_of_slave_build() throws ExecutionException, InterruptedException {
    DumbSlave dockerSlave = createDockerAgent();
    FreeStyleJob job = prepareDockerSlave(dockerSlave);
    job.configure();
    job.copyResource(resource(RESOURCE_WARNING_MAIN_JAVA_PATH));
    ShellBuildStep shellBuildStep = job.addBuildStep(ShellBuildStep.class);
    shellBuildStep.command(CMD_WARNING_MAIN_JAVA_CONSOLE);
    WarningsPublisher warningsPublisher = job.addPublisher(WarningsPublisher.class);
    warningsPublisher.addConsoleScanner(JAVA_ID);
    job.save();
    Build build = job.startBuild().shouldSucceed();
    assertThatActionExists(job, build, "Java Warnings");
    WarningsAction action = createJavaResultAction(build);
    assertThatWarningsCountInSummaryIs(action, 3);
    String codeLine = action.getLinkedSourceFileText(AnalysisAction.Tab.DETAILS, "WarningMain.java", 10);
    String[] codeLineArr = codeLine.trim().split("\\s+", 2);
    assertThat("Warning should be at line", codeLineArr[0], is("10"));
    assertThat("Assert failed comparing code line is", codeLineArr[1], is("text =  (TextClass) text2;"));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WarningsPublisher(org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher) ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 10 with WithCredentials

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

the class JiraPluginTest method jira_ticket_gets_updated_with_a_build_link.

@Test
@WithCredentials(credentialType = WithCredentials.USERNAME_PASSWORD, values = { USERNAME, PASSWORD }, id = CREDENTIALS_ID)
public void jira_ticket_gets_updated_with_a_build_link() throws Exception {
    JiraContainer jira = docker.get();
    jira.waitForReady(this);
    jira.createProject("ABC");
    jira.createIssue("ABC");
    jira.createIssue("ABC");
    jenkins.configure();
    {
        new JiraGlobalConfig(jenkins).addSite(jira.getURL(), CREDENTIALS_ID);
    }
    jenkins.save();
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    {
        job.useScm(GitScm.class).url(git.dir.toString());
        job.addPublisher(JiraUpdater.class);
    }
    job.save();
    git.changeAndCommitFoo("initial commit");
    job.startBuild().shouldSucceed();
    git.changeAndCommitFoo("[ABC-1] fixed");
    git.changeAndCommitFoo("[ABC-2] fixed");
    Build b = job.startBuild().shouldSucceed();
    b.open();
    find(by.link("ABC-1"));
    find(by.link("ABC-2"));
    String buildUrl = job.build(b.getNumber()).url.toString();
    for (RemoteComment c : jira.getComments("ABC-1")) {
        if (c.getBody().contains(buildUrl)) {
            return;
        }
    }
    fail("Comment back to Jenkins not found");
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) JiraGlobalConfig(org.jenkinsci.test.acceptance.plugins.jira.JiraGlobalConfig) RemoteComment(hudson.plugins.jira.soap.RemoteComment) JiraContainer(org.jenkinsci.test.acceptance.docker.fixtures.JiraContainer) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) JiraUpdater(org.jenkinsci.test.acceptance.plugins.jira.JiraUpdater) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Aggregations

WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)21 Test (org.junit.Test)21 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)14 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)13 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)11 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)10 TestActivation (org.jenkinsci.test.acceptance.junit.TestActivation)8 Build (org.jenkinsci.test.acceptance.po.Build)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)5 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)5 Issue (org.jvnet.hudson.test.Issue)5 WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)3 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)3 Matchers.containsString (org.hamcrest.Matchers.containsString)2 SvnContainer (org.jenkinsci.test.acceptance.docker.fixtures.SvnContainer)2 SubversionScm (org.jenkinsci.test.acceptance.plugins.subversion.SubversionScm)2 WarningsPublisher (org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher)2 MatrixBuild (org.jenkinsci.test.acceptance.po.MatrixBuild)2 Node (org.jenkinsci.test.acceptance.po.Node)2