Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-13696

Fitnesse should run on the slave of the build, not on the head node

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • fitnesse-plugin
    • None
    • Distributed builds

      The setup I use for jenkins is to have a single non building head node, and several build slaves. In this case, the jenkins fitnesse plugin tries to run fitnesse on the head node instead of the slave the build is running on.. Attached is the fix I applied locally...

          [JENKINS-13696] Fitnesse should run on the slave of the build, not on the head node

          Attaching the patch does not seem to work, so I copy /paste it here:

          diff --git a/src/main/java/hudson/plugins/fitnesse/FitnesseExecutor.java b/src/main/java/hudson/plugins/fitnesse/FitnesseExecutor.java
          index 99f795c..af91fbf 100644
          --- a/src/main/java/hudson/plugins/fitnesse/FitnesseExecutor.java
          +++ b/src/main/java/hudson/plugins/fitnesse/FitnesseExecutor.java
          @@ -3,9 +3,10 @@ package hudson.plugins.fitnesse;
           import hudson.EnvVars;
           import hudson.FilePath;
           import hudson.Launcher;
          -import hudson.Proc;
           import hudson.Launcher.ProcStarter;
          +import hudson.Proc;
           import hudson.model.AbstractBuild;
          +import hudson.model.Computer;
          
           import java.io.ByteArrayOutputStream;
           import java.io.File;
          @@ -214,9 +215,16 @@ public class FitnesseExecutor {
                          return bucket.toByteArray();
                  }
          
          -       public URL getFitnessePageCmdURL() throws MalformedURLException {
          +       // FRANKC: fixme
          +       public URL getFitnessePageCmdURL() throws IOException, InterruptedException {
          +               String hostName = builder.getFitnesseHost();
          +               if (builder._LOCALHOST.equals(hostName)) {
          +                       // Frankc: get the slave name:
          +                       Computer current = Computer.currentComputer();
          +                       hostName = current.getHostName();
          +               }
                          return new URL("http",
          -                               builder.getFitnesseHost(),
          +                               hostName,
                                          builder.getFitnessePort(),
                                          getFitnessePageCmd());
                  }
          diff --git a/src/test/java/hudson/plugins/fitnesse/FitnesseExecutorTest.java b/src/test/java/hudson/plugins/fitnesse/FitnesseExecutorTest.java
          index 5308a7d..b15b403 100644
          --- a/src/test/java/hudson/plugins/fitnesse/FitnesseExecutorTest.java
          +++ b/src/test/java/hudson/plugins/fitnesse/FitnesseExecutorTest.java
          @@ -163,7 +163,7 @@ public class FitnesseExecutorTest {
                  }
                  
                  @Test
          -       public void fitnessePageCmdURLShouldIncludeHostPortAndPageCmd() throws MalformedURLException {
          +       public void fitnessePageCmdURLShouldIncludeHostPortAndPageCmd() throws Exception {
                          executor = getExecutorForBuilder(
                                          new String[] {FitnesseBuilder.FITNESSE_HOST, FitnesseBuilder.FITNESSE_PORT, FitnesseBuilder.TARGET_PAGE, FitnesseBuilder.TARGET_IS_SUITE},
                                          new String[] {"host", "1234", "WikiPage", "true"});
          @@ -172,7 +172,7 @@ public class FitnesseExecutorTest {
                  }
           
                  @Test
          -       public void fitnessePageCmdURLShouldIncludeLocalHostIfStartedByHudson() throws MalformedURLException {
          +       public void fitnessePageCmdURLShouldIncludeLocalHostIfStartedByHudson() throws Exception {
                          executor = getExecutorForBuilder(
                                  new String[] {FitnesseBuilder.START_FITNESSE, FitnesseBuilder.FITNESSE_HOST, FitnesseBuilder.FITNESSE_PORT, FitnesseBuilder.TARGET_PAGE, FitnesseBuilder.TARGET_IS_SUITE},
                                  new String[] {"true", "unknown_host", "8989", "WikiPage", "true"});
          
          

          Frank Cornelissen added a comment - Attaching the patch does not seem to work, so I copy /paste it here: diff --git a/src/main/java/hudson/plugins/fitnesse/FitnesseExecutor.java b/src/main/java/hudson/plugins/fitnesse/FitnesseExecutor.java index 99f795c..af91fbf 100644 --- a/src/main/java/hudson/plugins/fitnesse/FitnesseExecutor.java +++ b/src/main/java/hudson/plugins/fitnesse/FitnesseExecutor.java @@ -3,9 +3,10 @@ package hudson.plugins.fitnesse; import hudson.EnvVars; import hudson.FilePath; import hudson.Launcher; -import hudson.Proc; import hudson.Launcher.ProcStarter; +import hudson.Proc; import hudson.model.AbstractBuild; +import hudson.model.Computer; import java.io.ByteArrayOutputStream; import java.io.File; @@ -214,9 +215,16 @@ public class FitnesseExecutor { return bucket.toByteArray(); } - public URL getFitnessePageCmdURL() throws MalformedURLException { + // FRANKC: fixme + public URL getFitnessePageCmdURL() throws IOException, InterruptedException { + String hostName = builder.getFitnesseHost(); + if (builder._LOCALHOST.equals(hostName)) { + // Frankc: get the slave name: + Computer current = Computer.currentComputer(); + hostName = current.getHostName(); + } return new URL("http", - builder.getFitnesseHost(), + hostName, builder.getFitnessePort(), getFitnessePageCmd()); } diff --git a/src/test/java/hudson/plugins/fitnesse/FitnesseExecutorTest.java b/src/test/java/hudson/plugins/fitnesse/FitnesseExecutorTest.java index 5308a7d..b15b403 100644 --- a/src/test/java/hudson/plugins/fitnesse/FitnesseExecutorTest.java +++ b/src/test/java/hudson/plugins/fitnesse/FitnesseExecutorTest.java @@ -163,7 +163,7 @@ public class FitnesseExecutorTest { } @Test - public void fitnessePageCmdURLShouldIncludeHostPortAndPageCmd() throws MalformedURLException { + public void fitnessePageCmdURLShouldIncludeHostPortAndPageCmd() throws Exception { executor = getExecutorForBuilder( new String[] {FitnesseBuilder.FITNESSE_HOST, FitnesseBuilder.FITNESSE_PORT, FitnesseBuilder.TARGET_PAGE, FitnesseBuilder.TARGET_IS_SUITE}, new String[] {"host", "1234", "WikiPage", "true"}); @@ -172,7 +172,7 @@ public class FitnesseExecutorTest { } @Test - public void fitnessePageCmdURLShouldIncludeLocalHostIfStartedByHudson() throws MalformedURLException { + public void fitnessePageCmdURLShouldIncludeLocalHostIfStartedByHudson() throws Exception { executor = getExecutorForBuilder( new String[] {FitnesseBuilder.START_FITNESSE, FitnesseBuilder.FITNESSE_HOST, FitnesseBuilder.FITNESSE_PORT, FitnesseBuilder.TARGET_PAGE, FitnesseBuilder.TARGET_IS_SUITE}, new String[] {"true", "unknown_host", "8989", "WikiPage", "true"});

          David T added a comment -

          If I understand this issue correctly, I am having the same problem. It appears that the plugin is trying to connect to FitNesse on the master (the FitNesse server is started correctly on the slave). As a work around, I need to start the FitNesse server manually on the slave machine, and specify the option "Fitnesse instance is already running"

          My error is

          Connnecting to http://localhost:8085/RiskManagement.SomeSuitePage.AnotherSuitePage?suite&format=xml&includehtml
          java.net.ConnectException: Connection refused: connect
          

          My versions are
          Jenkins: 1.578
          Hudson Fitnesse plugin: 1.9

          David T added a comment - If I understand this issue correctly, I am having the same problem. It appears that the plugin is trying to connect to FitNesse on the master (the FitNesse server is started correctly on the slave). As a work around, I need to start the FitNesse server manually on the slave machine, and specify the option "Fitnesse instance is already running" My error is Connnecting to http: //localhost:8085/RiskManagement.SomeSuitePage.AnotherSuitePage?suite&format=xml&includehtml java.net.ConnectException: Connection refused: connect My versions are Jenkins: 1.578 Hudson Fitnesse plugin: 1.9

          The workaround is to set the HOST_NAME on EACH slave.
          Check out the wiki article.
          https://wiki.jenkins-ci.org/display/JENKINS/FitNesse+Plugin
          But still it should be fixed.

          Andreas Markussen added a comment - The workaround is to set the HOST_NAME on EACH slave. Check out the wiki article. https://wiki.jenkins-ci.org/display/JENKINS/FitNesse+Plugin But still it should be fixed.

          jaruzafa added a comment -

          Fixed with fitnesse-plugin 1.29

          jaruzafa added a comment - Fixed with fitnesse-plugin 1.29

            Unassigned Unassigned
            frankc Frank Cornelissen
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: