|
22 | 22 | import org.junit.Before; |
23 | 23 | import org.junit.Rule; |
24 | 24 | import org.junit.Test; |
| 25 | +import org.junit.rules.TestWatcher; |
| 26 | +import org.junit.runner.Description; |
25 | 27 |
|
26 | 28 | import java.util.List; |
| 29 | +import java.util.Map; |
27 | 30 | import java.util.Random; |
28 | 31 | import java.util.concurrent.ExecutorService; |
29 | 32 | import java.util.concurrent.Executors; |
|
45 | 48 | public class SessionPoolingStressIT |
46 | 49 | { |
47 | 50 | @Rule |
48 | | - public TestNeo4j neo4j = new TestNeo4j(); |
| 51 | + public final TestNeo4j neo4j = new TestNeo4j(); |
| 52 | + |
| 53 | + @Rule |
| 54 | + public final TestWatcher testWatcher = new TestWatcher() |
| 55 | + { |
| 56 | + @Override |
| 57 | + protected void failed( Throwable e, Description description ) |
| 58 | + { |
| 59 | + super.failed( e, description ); |
| 60 | + |
| 61 | + StringBuilder sb = new StringBuilder(); |
| 62 | + Map<Thread,StackTraceElement[]> allStackTraces = Thread.getAllStackTraces(); |
| 63 | + for ( Map.Entry<Thread,StackTraceElement[]> entry : allStackTraces.entrySet() ) |
| 64 | + { |
| 65 | + Thread thread = entry.getKey(); |
| 66 | + sb.append( thread ).append( " -- " ).append( thread.getState() ).append( System.lineSeparator() ); |
| 67 | + for ( StackTraceElement element : entry.getValue() ) |
| 68 | + { |
| 69 | + sb.append( " " ).append( element ).append( System.lineSeparator() ); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + System.out.println( sb.toString() ); |
| 74 | + } |
| 75 | + }; |
49 | 76 |
|
50 | 77 | private static final int N_THREADS = 50; |
51 | | - private static final int MAX_TIME = 10000; |
| 78 | + private static final int TEST_TIME = 10000; |
52 | 79 |
|
53 | 80 | private static final List<String> QUERIES = asList( |
54 | 81 | "RETURN 1295 + 42", "UNWIND range(1,10000) AS x CREATE (n {prop:x}) DELETE n " ); |
@@ -90,11 +117,11 @@ public void shouldWorkFine() throws Throwable |
90 | 117 |
|
91 | 118 | doWork( stop, failureReference ); |
92 | 119 |
|
93 | | - Thread.sleep( MAX_TIME ); |
| 120 | + Thread.sleep( TEST_TIME ); |
94 | 121 |
|
95 | 122 | stop.set( true ); |
96 | 123 | executor.shutdown(); |
97 | | - assertTrue( executor.awaitTermination( MAX_TIME, TimeUnit.MILLISECONDS ) ); |
| 124 | + assertTrue( executor.awaitTermination( 20, TimeUnit.SECONDS ) ); |
98 | 125 |
|
99 | 126 | Throwable failure = failureReference.get(); |
100 | 127 | if ( failure != null ) |
|
0 commit comments