You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2008/03/14 20:55:27 UTC
svn commit: r637234 - in
/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests:
harness/MultiTest.java util/TestUtil.java util/ThreadDump.java
util/build.xml util/derby_tests.policy
Author: kmarsden
Date: Fri Mar 14 12:55:25 2008
New Revision: 637234
URL: http://svn.apache.org/viewvc?rev=637234&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
Added:
db/derby/code/branches/10.4/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.4/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java?rev=637234&r1=637233&r2=637234&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/harness/MultiTest.java Fri Mar 14 12:55:25 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.4/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java?rev=637234&r1=637233&r2=637234&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java Fri Mar 14 12:55:25 2008
@@ -38,6 +38,7 @@
import javax.sql.DataSource;
import org.apache.derby.iapi.services.info.JVMInfo;
+import org.apache.derbyTesting.functionTests.harness.JavaVersionHolder;
import org.apache.derbyTesting.functionTests.harness.RunTest;
@@ -913,5 +914,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.4/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/build.xml?rev=637234&r1=637233&r2=637234&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/build.xml (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/build.xml Fri Mar 14 12:55:25 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,25 @@
</classpath>
<!--exclude name=""/-->
<include name="${this.dir}/XATestUtil.java"/>
+ </javac>
+
+ <javac
+ source="1.5"
+ target="1.5"
+ 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="${java15compile.classpath}"/>
+ </classpath>
+ <include name="${this.dir}/ThreadDump.java"/>
</javac>
</target>
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?rev=637234&r1=637233&r2=637234&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy Fri Mar 14 12:55:25 2008
@@ -165,6 +165,11 @@
permission java.security.SecurityPermission "getPolicy";
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";
+
// These permissions are needed when testing code instrumented with EMMA.
permission java.lang.RuntimePermission "${emma.active}writeFileDescriptor";
};
@@ -205,6 +210,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