db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1065061 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store: BootLockMinion.java BootLockTest.java
Date Sat, 29 Jan 2011 16:27:11 GMT
Author: kmarsden
Date: Sat Jan 29 16:27:11 2011
New Revision: 1065061

URL: http://svn.apache.org/viewvc?rev=1065061&view=rev
Log:
DERBY-4987 BootLockTest can hang reading spawned process output

The test will now only attempt to get the error output if BootLockMinion has exited and also
has a max timeout of ten minutes which won't slow down normal runs of the test but hopefully
be long enough without risk of hanging again. 


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockMinion.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockMinion.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockMinion.java?rev=1065061&r1=1065060&r2=1065061&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockMinion.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockMinion.java
Sat Jan 29 16:27:11 2011
@@ -38,6 +38,8 @@ import org.apache.derby.jdbc.EmbeddedSim
  */
 
 public class BootLockMinion {
+    private static int WAIT_FOR_DESTROY_MAX_MILLIS = BootLockTest.MINION_WAIT_MAX_MILLIS;
+    
     public static void main(String[] args) {
         String dbName = args[0];
         Connection con;
@@ -60,10 +62,13 @@ public class BootLockMinion {
             File checkFile = new File(BootLockTest.minionCompleteFileName);
             checkFile.createNewFile();
             //infinite loop until we get killed by BootLockTest.java
-            for(;;)
+            int wait = WAIT_FOR_DESTROY_MAX_MILLIS;
+            while(wait > 0)
             {
-                Thread.sleep(30000);
+                Thread.sleep(10000);
+                wait -= 10000;
             }
+            System.err.println("BootLockMinion exceeded maximum wait for destroy");
         }
         catch (Exception e) {
             e.printStackTrace();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockTest.java?rev=1065061&r1=1065060&r2=1065061&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootLockTest.java
Sat Jan 29 16:27:11 2011
@@ -74,6 +74,8 @@ public class BootLockTest extends BaseJD
 
     private final static String DATA_MULTIPLE_JBMS_ON_DB = "XSDB6";
     private final static String DATA_MULTIPLE_JBMS_FORCE_LOCK = "XSDB8";
+    // Ten minutes should hopefully be enough!
+    public static final int MINION_WAIT_MAX_MILLIS = 600000;
 
     /**
      * Constructor
@@ -130,7 +132,7 @@ public class BootLockTest extends BaseJD
         Process p = null;
 
         p = execJavaCmd(cmd);
-        waitForMinionBoot(p,60000);
+        waitForMinionBoot(p,MINION_WAIT_MAX_MILLIS);
 
         // We now know minion has booted
 
@@ -174,6 +176,8 @@ public class BootLockTest extends BaseJD
     }
 
     private void waitForMinionBoot(Process p, int waitmillis) throws InterruptedException
{
+        boolean minionComplete;
+        int minionExitValue;
         StringBuffer failmsg = new StringBuffer();
         // boolean set to true once we find the  lock file
         File lockFile = new File(dbLockFile);
@@ -202,22 +206,38 @@ public class BootLockTest extends BaseJD
         
         // If we got here, the database did not boot. Try to print the error.
         failmsg.append(
-                "Minion did not start or boot db in 60 seconds.\n" +
-                "----Minion's stderr:\n");
-        do {
-            try {
-                minionErrLine = minionSysErr.readLine();
-            } catch (Exception ioe) {
-                // may not always work, so just bail out.
-                failmsg.append("could not read minion's stderr");
-            }
-
-            if (minionErrLine != null) {
-                failmsg.append(minionErrLine);
-            }
-        } while (minionErrLine != null);
+                "Minion did not start or boot db in " +
+                (MINION_WAIT_MAX_MILLIS/1000) +
+                " seconds.\n");                
+        try {
+            minionExitValue = p.exitValue();
+            minionComplete =true;
+            failmsg.append("exitValue = " + minionExitValue);
+        }catch (IllegalThreadStateException e )
+        {
+            // got exception on exitValue.
+            // still running ..
+            minionComplete=false;
+        }
+        // If the process exited try to print why.
+        if (minionComplete) {
+            failmsg.append("----Process exited. Minion's stderr:\n");
+            do {
+                try {
+                    minionErrLine = minionSysErr.readLine();
+                } catch (Exception ioe) {
+                    // may not always work, so just bail out.
+                    failmsg.append("could not read minion's stderr");
+                }
+
+                if (minionErrLine != null) {
+                    failmsg.append(minionErrLine);
+                }
+            } while (minionErrLine != null);
 
-        failmsg.append("\n----Minion's stderr ended");
+            failmsg.append("\n----Minion's stderr ended");
+        }
+        
         p.destroy();
         p.waitFor();
         fail(failmsg.toString());



Mime
View raw message