From 7131a892bc2be9caf67041d646b9851895745f26 Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Fri, 12 Mar 2021 16:13:32 +1000 Subject: [PATCH] [JENKINS-65097] Add information about websocket in nodes.md --- pom.xml | 2 +- .../jenkins/support/impl/AboutJenkins.java | 4 +++ .../support/impl/AboutJenkinsTest.java | 26 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b9da883ed..c79a72630 100644 --- a/pom.xml +++ b/pom.xml @@ -71,7 +71,7 @@ 2.73 -SNAPSHOT - 2.204.6 + 2.222.1 8 1.36 diff --git a/src/main/java/com/cloudbees/jenkins/support/impl/AboutJenkins.java b/src/main/java/com/cloudbees/jenkins/support/impl/AboutJenkins.java index abd1cf0c9..ff0bcec05 100644 --- a/src/main/java/com/cloudbees/jenkins/support/impl/AboutJenkins.java +++ b/src/main/java/com/cloudbees/jenkins/support/impl/AboutJenkins.java @@ -31,6 +31,7 @@ import hudson.remoting.Launcher; import hudson.remoting.VirtualChannel; import hudson.security.Permission; +import hudson.slaves.JNLPLauncher; import hudson.util.IOUtils; import jenkins.model.Jenkins; import jenkins.model.JenkinsLocationConfiguration; @@ -659,6 +660,9 @@ private String getLabelString(Node n) { if (node instanceof Slave) { Slave slave = (Slave) node; out.println(" - Launch method: " + getDescriptorName(slave.getLauncher())); + if (slave.getLauncher() instanceof JNLPLauncher) { + out.println(" - WebSocket: " + ((JNLPLauncher) slave.getLauncher()).isWebSocket()); + } out.println(" - Availability: " + getDescriptorName(slave.getRetentionStrategy())); } VirtualChannel channel = node.getChannel(); diff --git a/src/test/java/com/cloudbees/jenkins/support/impl/AboutJenkinsTest.java b/src/test/java/com/cloudbees/jenkins/support/impl/AboutJenkinsTest.java index 2f6893ecb..a3c7bf758 100644 --- a/src/test/java/com/cloudbees/jenkins/support/impl/AboutJenkinsTest.java +++ b/src/test/java/com/cloudbees/jenkins/support/impl/AboutJenkinsTest.java @@ -6,6 +6,8 @@ import com.cloudbees.jenkins.support.SupportTestUtils; import com.cloudbees.jenkins.support.api.Component; import hudson.ExtensionList; +import hudson.slaves.DumbSlave; +import hudson.slaves.JNLPLauncher; import jenkins.model.identity.IdentityRootAction; import jenkins.slaves.RemotingVersionInfo; import org.junit.Rule; @@ -29,6 +31,7 @@ public class AboutJenkinsTest { @Test @Issue("JENKINS-56245") public void testAboutJenkinsContent() { + String aboutMdToString = SupportTestUtils.invokeComponentToString(Objects.requireNonNull(ExtensionList.lookup(Component.class).get(AboutJenkins.class))); assertThat(aboutMdToString, containsString(" * Instance ID: `" + j.getInstance().getLegacyInstanceId())); @@ -38,4 +41,27 @@ public void testAboutJenkinsContent() { assertThat(aboutMdToString, containsString(" * Embedded Version: `" + RemotingVersionInfo.getEmbeddedVersion().toString())); assertThat(aboutMdToString, containsString(" * Minimum Supported Version: `" + RemotingVersionInfo.getMinimumSupportedVersion().toString())); } + + @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")); + } }