Search in sources :

Example 1 with JNLPLauncher

use of hudson.slaves.JNLPLauncher in project support-core-plugin by jenkinsci.

the class AboutJenkinsTest method testAboutNodesContent.

@Test
@Issue("JENKINS-65097")
public void testAboutNodesContent() throws Exception {
    DumbSlave tcp1 = j.createSlave("tcp1", "test", null);
    tcp1.setLauncher(new JNLPLauncher(false));
    ((JNLPLauncher) tcp1.getLauncher()).setWebSocket(false);
    tcp1.save();
    String aboutMdToString = SupportTestUtils.invokeComponentToString(Objects.requireNonNull(ExtensionList.lookup(Component.class).get(AboutJenkins.class)));
    assertThat(aboutMdToString, containsString("  * `" + tcp1.getNodeName() + "` (`hudson.slaves.DumbSlave`)"));
    assertThat(aboutMdToString, containsString("      - Launch method:  `hudson.slaves.JNLPLauncher`"));
    assertThat(aboutMdToString, containsString("      - WebSocket:      false"));
    ((JNLPLauncher) tcp1.getLauncher()).setWebSocket(true);
    tcp1.save();
    aboutMdToString = SupportTestUtils.invokeComponentToString(Objects.requireNonNull(ExtensionList.lookup(Component.class).get(AboutJenkins.class)));
    assertThat(aboutMdToString, containsString("  * `" + tcp1.getNodeName() + "` (`hudson.slaves.DumbSlave`)"));
    assertThat(aboutMdToString, containsString("      - Launch method:  `hudson.slaves.JNLPLauncher`"));
    assertThat(aboutMdToString, containsString("      - WebSocket:      true"));
}
Also used : JNLPLauncher(hudson.slaves.JNLPLauncher) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DumbSlave(hudson.slaves.DumbSlave) Component(com.cloudbees.jenkins.support.api.Component) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 2 with JNLPLauncher

use of hudson.slaves.JNLPLauncher in project vsphere-cloud-plugin by jenkinsci.

the class CloudProvisioningStateTest method createRecord.

private CloudProvisioningRecord createRecord(CloudProvisioningState instance) {
    recordNumber++;
    final String cloneNamePrefix = "prefix" + recordNumber;
    final vSphereCloudSlaveTemplate template = new vSphereCloudSlaveTemplate(cloneNamePrefix, "masterImageName", null, "snapshotName", false, "cluster", "resourcePool", "datastore", "folder", "customizationSpec", "templateDescription", 0, 1, "remoteFS", "", Mode.NORMAL, false, false, 0, 0, false, "targetResourcePool", "targetHost", null, new JNLPLauncher(), RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList(), Collections.<VSphereGuestInfoProperty>emptyList());
    stubVSphereCloudTemplates.add(template);
    final List<vSphereCloudSlaveTemplate> templates = new ArrayList<vSphereCloudSlaveTemplate>();
    templates.add(template);
    final List<CloudProvisioningRecord> records = instance.calculateProvisionableTemplates(templates);
    assertThat(records, IsIterableWithSize.<CloudProvisioningRecord>iterableWithSize(1));
    final CloudProvisioningRecord record = records.get(0);
    return record;
}
Also used : ArrayList(java.util.ArrayList) JNLPLauncher(hudson.slaves.JNLPLauncher) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) org.jenkinsci.plugins.vSphereCloudSlaveTemplate(org.jenkinsci.plugins.vSphereCloudSlaveTemplate)

Example 3 with JNLPLauncher

use of hudson.slaves.JNLPLauncher in project configuration-as-code-plugin by jenkinsci.

the class BuildAgentsTest method configure_build_agents.

@Test
@ConfiguredWithReadme(value = "build_agents/README.md")
public void configure_build_agents() {
    assertThat(j.getInstance().getComputers().length, is(3));
    Slave slave = (Slave) j.getInstance().getNode("utility-node");
    assertThat(slave.getRemoteFS(), is("/home/user1"));
    JNLPLauncher jnlpLauncher = ((JNLPLauncher) slave.getLauncher());
    assertThat(jnlpLauncher.getWorkDirSettings().getWorkDirPath(), is("/tmp"));
    assertThat(jnlpLauncher.getWorkDirSettings().getInternalDir(), is("remoting"));
    assertTrue(jnlpLauncher.getWorkDirSettings().isDisabled());
    assertFalse(jnlpLauncher.getWorkDirSettings().isFailIfWorkDirIsMissing());
    assertThat(j.getInstance().getNode("utility-node-2").getNumExecutors(), is(4));
    assertThat(j.getInstance().getNode("utility-node-2").getMode(), is(Mode.NORMAL));
    slave = (Slave) j.getInstance().getNode("utility-node-2");
    assertThat(slave.getRemoteFS(), is("/home/user2"));
    SSHLauncher launcher = ((SSHLauncher) slave.getLauncher());
    assertThat(launcher.getHost(), is("192.168.1.1"));
    assertThat(launcher.getPort(), is(22));
    assertThat(launcher.getCredentialsId(), is("test"));
    assertThat(launcher.getMaxNumRetries(), is(3));
    assertThat(launcher.getRetryWaitTime(), is(30));
}
Also used : Slave(hudson.model.Slave) SSHLauncher(hudson.plugins.sshslaves.SSHLauncher) JNLPLauncher(hudson.slaves.JNLPLauncher) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 4 with JNLPLauncher

use of hudson.slaves.JNLPLauncher in project vsphere-cloud-plugin by jenkinsci.

the class vSphereCloudSlaveTemplate method determineLauncher.

private ComputerLauncher determineLauncher(final VSphere vSphere, final String cloneName) throws VSphereException {
    if (launcher instanceof JNLPLauncher) {
        return launcher;
    }
    if (launcher instanceof CommandLauncher) {
        return launcher;
    }
    if (launcher instanceof SSHLauncher) {
        final SSHLauncher sshLauncher = (SSHLauncher) launcher;
        LOGGER.log(Level.FINER, "Slave {0} uses SSHLauncher - obtaining IP address...", cloneName);
        final String ip = vSphere.getIp(vSphere.getVmByName(cloneName), 1000);
        LOGGER.log(Level.FINER, "Slave {0} has IP address {1}", new Object[] { cloneName, ip });
        final SSHLauncher launcherWithIPAddress = new SSHLauncher(ip, sshLauncher.getPort(), sshLauncher.getCredentialsId(), sshLauncher.getJvmOptions(), sshLauncher.getJavaPath(), sshLauncher.getPrefixStartSlaveCmd(), sshLauncher.getSuffixStartSlaveCmd(), sshLauncher.getLaunchTimeoutSeconds(), sshLauncher.getMaxNumRetries(), sshLauncher.getRetryWaitTime());
        return launcherWithIPAddress;
    }
    throw new IllegalStateException("Unsupported launcher (" + launcher + ") in template configuration");
}
Also used : CommandLauncher(hudson.slaves.CommandLauncher) SSHLauncher(hudson.plugins.sshslaves.SSHLauncher) JNLPLauncher(hudson.slaves.JNLPLauncher)

Aggregations

JNLPLauncher (hudson.slaves.JNLPLauncher)4 SSHLauncher (hudson.plugins.sshslaves.SSHLauncher)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2 Component (com.cloudbees.jenkins.support.api.Component)1 Slave (hudson.model.Slave)1 CommandLauncher (hudson.slaves.CommandLauncher)1 DumbSlave (hudson.slaves.DumbSlave)1 ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)1 ArrayList (java.util.ArrayList)1 org.jenkinsci.plugins.vSphereCloudSlaveTemplate (org.jenkinsci.plugins.vSphereCloudSlaveTemplate)1 Issue (org.jvnet.hudson.test.Issue)1