db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r637266 - in /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests: harness/MultiTest.java util/TestUtil.java util/ThreadDump.java util/build.xml util/derby_tests.policy
Date Fri, 14 Mar 2008 21:09:47 GMT
Author: kmarsden
Date: Fri Mar 14 14:09:45 2008
New Revision: 637266

URL: http://svn.apache.org/viewvc?rev=637266&view=rev
Log:
DERBY-3503 Change stress.multi to dump thread stacks before killing off testers with jdk 1.5
and higher

port from trunk.  Had to change ThreadDump.java to build with jdk 1.6 since
we don't have a jdk15.compilepath for 10.3


Added:
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/ThreadDump.java
      - copied unchanged from r635625, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ThreadDump.java
Modified:
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java?rev=637266&r1=637265&r2=637266&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java
Fri Mar 14 14:09:45 2008
@@ -34,6 +34,8 @@
 
 import org.apache.derby.iapi.tools.i18n.LocalizedResource;
 import org.apache.derby.iapi.tools.i18n.LocalizedOutput;
+import org.apache.derbyTesting.functionTests.util.TestUtil;
+
 
 /**
  * MultiTest is a multiuser test harness.  It
@@ -285,7 +287,9 @@
 	
 		/*	
 		** Now stop everyone that hasn't already stopped.
+		* First get thread dumps for jdk 15.
 		*/
+		TestUtil.dumpAllStackTracesIfSupported(log);
 		for (i = 0; i < MAX_WAIT_FOR_COMPLETION && (tg.isDestroyed() == false ); i++)

 		{ 
 

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java?rev=637266&r1=637265&r2=637266&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
Fri Mar 14 14:09:45 2008
@@ -39,6 +39,7 @@
 
 import org.apache.derby.iapi.reference.JDBC30Translation;
 import org.apache.derby.iapi.services.info.JVMInfo;
+import org.apache.derbyTesting.functionTests.harness.JavaVersionHolder;
 import org.apache.derbyTesting.functionTests.harness.RunTest;
 
 
@@ -914,5 +915,57 @@
 		return false;
 	}
 
+	/**
+	 * For JDK 1.5 or higher print all stack traces to the
+	 * specified PrintWriter.
+	 * 
+	 * @param log  PrintWriter to print to
+	 */
+    public static void dumpAllStackTracesIfSupported(PrintWriter log)
+	{
+		try {
+			String version =  (String) AccessController.doPrivileged
+				(new java.security.PrivilegedAction(){
+						public Object run(){
+							return System.getProperty("java.version");
+						}
+					}
+				 );
+                   
+			JavaVersionHolder j=  new JavaVersionHolder(version); 
+			
+			if (j.atLeast(1,5)){
+				Class c = Class.forName("org.apache.derbyTesting.functionTests.util.ThreadDump");
+				final Method m = c.getMethod("getStackDumpString",new Class[] {});
+				
+				String dump;
+				try {
+					dump = (String) AccessController.doPrivileged
+						(new PrivilegedExceptionAction(){
+								public Object run() throws 
+									IllegalArgumentException, 
+									IllegalAccessException, 
+									InvocationTargetException{
+									return m.invoke(null, null);
+								}
+							}
+						 );
+				}     catch (PrivilegedActionException e) {
+					throw  e.getException();
+				}
+				log.println(dump);                    
+			}                     
+		}
+		catch (Exception e){
+			// if we get an exception trying to get a thread dump. Just print it to the log and continue.
+			log.println("Error trying to dump thread stack traces");
+			if (e instanceof InvocationTargetException)
+				((InvocationTargetException) e).getTargetException().printStackTrace(log);
+			else
+				e.printStackTrace(log);
+		}
+		
+	}
 }
+
 

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/build.xml?rev=637266&r1=637265&r2=637266&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
Fri Mar 14 14:09:45 2008
@@ -65,6 +65,7 @@
       <include name="${this.dir}/streams/*.java"/> 
       <include name="${this.dir}/corruptio/*.java"/>
       <exclude name="${this.dir}/XATestUtil.java"/>
+      <exclude name="${this.dir}/ThreadDump.java"/>
     </javac>
     <javac
       source="1.4"
@@ -84,6 +85,27 @@
       </classpath>
       <!--exclude name=""/-->
 	  <include name="${this.dir}/XATestUtil.java"/>
+    </javac>
+
+    <javac
+      source="1.5"
+      target="1.5"
+      fork="yes"
+      executable="${jdk16}/bin/javac"
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="true"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}"
+      srcdir="${derby.testing.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+        <pathelement path="${java16compile.classpath}"/>
+      </classpath>
+    <include name="${this.dir}/ThreadDump.java"/>
     </javac>
   </target>
 

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?rev=637266&r1=637265&r2=637266&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
Fri Mar 14 14:09:45 2008
@@ -157,7 +157,13 @@
   // streams. Currently the nist suite runs with useprocess=false.
   permission java.lang.RuntimePermission "setSecurityManager";
   permission java.security.SecurityPermission "getPolicy";
-  permission java.lang.RuntimePermission "setIO"; 
+  permission java.lang.RuntimePermission "setIO";  
+
+  // These permissions are needed by stress.multi to dump the thread stack
+  // traces upon failure.
+  permission java.lang.RuntimePermission "getStackTrace";
+  permission java.lang.RuntimePermission "modifyThreadGroup";
+
 };
 
 //
@@ -196,6 +202,12 @@
   // streams. Currently the nist suite runs with useprocess=false.
   permission java.lang.RuntimePermission "setSecurityManager";
   permission java.lang.RuntimePermission "setIO"; 
+
+  // These permissions are needed by stress.multi to dump the thread stack
+  // traces upon failure.
+  permission java.lang.RuntimePermission "getStackTrace";
+  permission java.lang.RuntimePermission "modifyThreadGroup";
+
 };
 
 // JUnit jar file tries to read junit.properties in the user's



Mime
View raw message