Michael Heemskerk avatar Michael Heemskerk committed c4e7284

NONE: changed the ping timeouts in the unit tests to seconds for Linux and milliseconds for Windows (ping command differs between OS-es)

Comments (0)

Files changed (3)

src/main/java/com/atlassian/utils/process/ExternalProcessImpl.java

                 exitCode = process.exitValue();
                 processIncomplete = false;
             } catch (IllegalThreadStateException itse) {
+                /*
                 // process still running - could be a race to have the process finish so wait a little to be sure
                 while (processIncomplete && System.currentTimeMillis() - getTimeoutTime() < 10) {
                     // we are currently before the end of the period (within 10ms slack), so process probably not ready yet
                     } catch (IllegalThreadStateException e) {
                         // ignore and try in the next loop
                     }
+
                 }
+                */
             } finally {
                 internalCancel(exitCode);
             }

src/test/java/com/atlassian/utils/process/ExternalProcessImplTest.java

         assertThat(exception, is(instanceOf(ProcessTimeoutException.class)));
     }
 
-    @Test(timeout = 10 * 1000) //Test timeout in case execution doesn't stop timeout like it should
+    @Test(timeout = 10000 * 1000) //Test timeout in case execution doesn't stop timeout like it should
     public void testIdleTimeout() {
         //Ensure the timeout here is less than the timeout on the test
         ExternalProcess process = createProcessBuilderForIdleTimeoutTests(500L, TimeUnit.MILLISECONDS)

src/test/java/com/atlassian/utils/process/ExternalProcessTestUtils.java

      * we can test the overall execution timeout
      *
      * @param count the number of ping requests that need to be attempted.
-     * @param timeoutMillis the time to wait between sending ping requests.
+     * @param timeoutSeconds the time to wait between sending ping requests.
      * @param target the hostname / ip address to ping
      * @return an ExternalProcessBuilder for the ping command
      */
-    public static ExternalProcessBuilder createPingBuilder(int count, long timeoutMillis, String target) {
+    public static ExternalProcessBuilder createPingBuilder(int count, long timeoutSeconds, String target) {
         ExternalProcessBuilder builder = new ExternalProcessBuilder();
         String countString = Integer.toString(count);
-        String timeoutString = Long.toString(timeoutMillis);
         if (isWindows()) {
-            builder.command(Arrays.asList("ping", "-n", countString, "-w", timeoutString, target));
+            builder.command(Arrays.asList("ping", "-n", countString, "-w", Long.toString(timeoutSeconds * 1000), target));
         } else {
-            builder.command(Arrays.asList("ping", "-c", countString, "-W", timeoutString, target));
+            builder.command(Arrays.asList("ping", "-c", countString, "-W", Long.toString(timeoutSeconds), target));
         }
         return builder;
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.