Michael Heemskerk avatar Michael Heemskerk committed f4c4f97

Increasing test timeouts to make the tests more tolerant of (really) slow build agents

Comments (0)

Files changed (2)

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

      * start and finish.
      */
     public void start() {
+        if (startTime != -1L) {
+            throw new IllegalStateException("An ExternalProcess can only be started once. Create a new instance if " +
+                    "you need to rerun a process.");
+        }
         try {
             notifyBeforeStart();
             this.startTime = System.currentTimeMillis();

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

 @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
 public class ExternalProcessImplTest {
 
-    @Test(timeout = 3 * 1000) //Test timeout in case execution doesn't timeout like it should
+    @Test(timeout = 10 * 1000) //Test timeout in case execution doesn't timeout like it should
     public void testExecutionTimeout() {
         ExternalProcess process = createProcessBuilderForExecutionTimeoutTests(1)
                 .handlers(new StringOutputHandler()) //Will ensure we don't idle out
         assertTrue(exception instanceof ProcessTimeoutException);
     }
 
-    @Test(timeout = 3 * 1000) //Test timeout in case execution doesn't stop timeout like it should
+    @Test(timeout = 10 * 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)
                 .build();
     }
 
-    @Test(timeout = 2 * 1000) // Test timeout in case execution doesn't stop as it should
+    @Test(timeout = 10 * 1000) // Test timeout in case execution doesn't stop as it should
     public void testBlockingInputHandlerAbortsWhenProcessFinishes() {
         ExternalProcess process = buildProcessWithBlockingInputHandler();
 
         assertEquals(0, process.getHandler().getExitCode());
     }
 
-    @Test(timeout = 2 * 1000) // Test timeout in case execution doesn't stop as it should
+    @Test(timeout = 10 * 1000) // Test timeout in case execution doesn't stop as it should
     public void testBlockingInputHandlerAbortsWhenProcessFinishes2() {
         ExternalProcess process = buildProcessWithBlockingInputHandler();
 
         assertEquals(0, process.getHandler().getExitCode());
     }
 
-    @Test(timeout = 3 * 1000)
+    @Test(timeout = 10 * 1000)
     public void testNativeWindowsKilling() {
         if (isWindows()) {
             ExternalProcess process = new ExternalProcessBuilder()
      * Not sure whether this code path makes a whole lot of sense, but there's quite a bit of code for dealing with
      * this condition, so better to test that it works..
      */
-    @Test(timeout = 250)
+    @Test(timeout = 10 * 1000)
     public void testFinishWithoutStart() {
         ExternalProcess process = buildProcessWithBlockingInputHandler();
 
         process.finish();
     }
 
-    @Test(timeout = 250)
+    @Test(timeout = 10 * 1000)
     public void testFinishWithTimeoutWithoutStart() {
         ExternalProcess process = buildProcessWithBlockingInputHandler();
 
         assertTrue(process.finish(100));
     }
 
+    @Test(expected = IllegalStateException.class)
+    public void testExecuteTwice() {
+        StringOutputHandler handler = new StringOutputHandler();
+
+        ExternalProcess process = createProcessBuilderThatExecutesFor(1)
+                .handlers(handler)
+                .build();
+
+        process.execute();
+
+        // second process executio should trigger an IllegalStateException
+        process.execute();
+    }
+
     private boolean isWindows() {
         return System.getProperty("os.name").toLowerCase().contains("windows");
     }
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.