Michael Heemskerk committed d99db71

Change timeouts on execution tests to fix the unit tests

Comments (0)

Files changed (2)


-    private void internalCancel(int exitCode) {
+    private synchronized void internalCancel(int exitCode) {
         if (inputPump != null) {
             // we determine whether we're going to interrupt the inputPump *after* the process has already finished.
             // if that is the case, we don't treat the InterruptedException that we catch from the inputPump as an error


     public static ExternalProcessBuilder createProcessBuilderForExecutionTimeoutTests(int durationSeconds) {
-        // ensure the process executes a bit longer than the execution timeout
+        // ensure the process executes a longer than the execution timeout
         return createProcessBuilderThatExecutesFor(durationSeconds + 10)
                 .idleTimeout(TimeUnit.SECONDS.toMillis(durationSeconds) + 250);
     public static ExternalProcessBuilder createProcessBuilderThatExecutesFor(int durationSeconds) {
         // 1 ping per second; we need n+1 pings to execute for n seconds
         int pingCount = durationSeconds + 1;
-        return createPingBuilder(pingCount, 1000 * durationSeconds, "localhost");
+        return createPingBuilder(pingCount, durationSeconds, "localhost");
      * @return an ExternalProcessBuilder with that will wait for {@code duration} without providing any output
-    public static ExternalProcessBuilder createProcessBuilderThatIdlesFor(long duration, TimeUnit timeUnit) {
+    public static ExternalProcessBuilder createProcessBuilderThatIdlesFor(long durationSeconds) {
         // ping to a non-existent ip address to force it to idle processing
         // note that the exit code will be 2, so the command will be marked as failed.
-        return createPingBuilder(1, timeUnit.toMillis(duration), "");
+        return createPingBuilder(1, durationSeconds, "");
     public static ExternalProcessBuilder createProcessBuilderForIdleTimeoutTests(long duration, TimeUnit timeUnit) {
         // ensure the process idles a bit longer than the idle timeout
         long durationMillis = timeUnit.toMillis(duration);
-        return createProcessBuilderThatIdlesFor(durationMillis + 10000, TimeUnit.MILLISECONDS)
+        long durationSeconds = (long) Math.ceil(durationMillis / 1000.0d);
+        return createProcessBuilderThatIdlesFor(durationSeconds)
                 .executionTimeout(durationMillis + 250L);
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
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.