Search in sources :

Example 11 with DumbSlave

use of org.jenkinsci.test.acceptance.po.DumbSlave in project acceptance-test-harness by jenkinsci.

the class SshSlavesPluginTest method newSlaveWithExistingCredential.

@Test
public void newSlaveWithExistingCredential() throws Exception {
    String username = "xyz";
    String description = "ssh_creds";
    String privateKey = "1212121122121212";
    CredentialsPage c = new CredentialsPage(jenkins, "_");
    c.open();
    SshPrivateKeyCredential sc = c.add(SshPrivateKeyCredential.class);
    sc.username.set(username);
    sc.description.set(description);
    sc.selectEnterDirectly().privateKey.set(privateKey);
    c.create();
    // now verify
    ManagedCredentials mc = new ManagedCredentials(jenkins);
    String href = mc.credentialById("ssh_creds");
    c.setConfigUrl(href);
    verifyValueForCredential(c, sc.username, username);
    // See https://jenkins.io/doc/developer/security/secrets/#secrets-and-configuration-forms, available from Jenkins 2.171
    if (jenkins.getVersion().isNewerThan(new VersionNumber("2.170"))) {
        verifyUnexpectedValueForCredential("Credentials in plain text should not be accessible from Web UI", c, sc.selectEnterDirectly().privateKey, privateKey);
    }
    // Just to make sure the dumb slave is set up properly, we should seed it
    // with a FS root and executors
    final DumbSlave s = jenkins.slaves.create(DumbSlave.class);
    SshSlaveLauncher l = s.setLauncher(SshSlaveLauncher.class);
    l.host.set("127.0.0.1");
    l.credentialsId.select(String.format("%s (%s)", username, description));
}
Also used : SshPrivateKeyCredential(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshPrivateKeyCredential) SshSlaveLauncher(org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher) CredentialsPage(org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage) Matchers.containsString(org.hamcrest.Matchers.containsString) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) ManagedCredentials(org.jenkinsci.test.acceptance.plugins.credentials.ManagedCredentials) VersionNumber(hudson.util.VersionNumber) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Example 12 with DumbSlave

use of org.jenkinsci.test.acceptance.po.DumbSlave in project acceptance-test-harness by jenkinsci.

the class SshSlavesPluginTest method newSlave.

@Test
@Since("1.560")
public void newSlave() {
    // Just to make sure the dumb slave is set up properly, we should seed it
    // with a FS root and executors
    final DumbSlave s = jenkins.slaves.create(DumbSlave.class);
    {
        SshSlaveLauncher l = s.setLauncher(SshSlaveLauncher.class);
        String username = "user1";
        String privateKey = "1212122112";
        String description = "Ssh key";
        l.host.set("127.0.0.1");
        // make sure this exists
        l.credentialsId.resolve();
        try {
            l.credentialsId.select(String.format("%s (%s)", username, description));
            fail();
        } catch (NoSuchElementException e) {
        // ignore
        }
        SshCredentialDialog f = l.addCredential();
        {
            SshPrivateKeyCredential sc = f.select(SshPrivateKeyCredential.class);
            sc.description.set(description);
            sc.username.set(username);
            sc.selectEnterDirectly().privateKey.set(privateKey);
        }
        f.add();
        l.credentialsId.select(String.format("%s (%s)", username, description));
    }
    s.save();
}
Also used : SshSlaveLauncher(org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher) SshPrivateKeyCredential(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshPrivateKeyCredential) SshCredentialDialog(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog) Matchers.containsString(org.hamcrest.Matchers.containsString) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) NoSuchElementException(org.openqa.selenium.NoSuchElementException) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest) Since(org.jenkinsci.test.acceptance.junit.Since)

Example 13 with DumbSlave

use of org.jenkinsci.test.acceptance.po.DumbSlave in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method createAndBuildCompileJobOnAgent.

private WarningsAction createAndBuildCompileJobOnAgent(Resource resource, String command) {
    DumbSlave dockerSlave = createDockerAgent();
    FreeStyleJob job = prepareDockerSlave(dockerSlave);
    job.configure();
    job.copyResource(resource);
    ShellBuildStep shellBuildStep = job.addBuildStep(ShellBuildStep.class);
    shellBuildStep.command(command);
    WarningsPublisher warningsPublisher = job.addPublisher(WarningsPublisher.class);
    warningsPublisher.addConsoleScanner(JAVA_ID);
    job.save();
    Build build = buildSuccessfulJob(job);
    assertThatActionExists(job, build, "Java Warnings");
    WarningsAction action = createJavaResultAction(build);
    action.open();
    return action;
}
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) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave)

Example 14 with DumbSlave

use of org.jenkinsci.test.acceptance.po.DumbSlave in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_scan_files_on_slave.

@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_scan_files_on_slave() {
    DumbSlave dockerSlave = createDockerAgent();
    FreeStyleJob job = prepareDockerSlave(dockerSlave);
    job.configure();
    job.copyResource(resource("/warnings_plugin/out.txt"));
    job.addPublisher(WarningsPublisher.class).addWorkspaceFileScanner(JAVA_ID, "out.txt");
    job.save();
    Build build = job.startBuild().shouldSucceed();
    assertThatActionExists(job, build, "Java Warnings");
    build.open();
    assertThat(driver, hasContent("Java Warnings: " + 2));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WarningsPublisher(org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) 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 15 with DumbSlave

use of org.jenkinsci.test.acceptance.po.DumbSlave 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

DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)17 Test (org.junit.Test)12 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)8 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)8 SshSlaveLauncher (org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher)7 Matchers.containsString (org.hamcrest.Matchers.containsString)6 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)5 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)5 Build (org.jenkinsci.test.acceptance.po.Build)5 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)5 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)4 SshPrivateKeyCredential (org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshPrivateKeyCredential)4 WarningsPublisher (org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher)3 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)3 Issue (org.jvnet.hudson.test.Issue)3 IOException (java.io.IOException)2 Since (org.jenkinsci.test.acceptance.junit.Since)2 CredentialsPage (org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage)2 ManagedCredentials (org.jenkinsci.test.acceptance.plugins.credentials.ManagedCredentials)2 SshCredentialDialog (org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog)2