Skip to content

Commit 30cecca

Browse files
committed
Increase executor shutdown timeout
Test `SessionPoolingStressIT` seems to be flaky, this commit increases the executor shutdown timeout and adds logging of all stacktraces on failure.
1 parent 78776a7 commit 30cecca

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

driver/src/test/java/org/neo4j/driver/v1/stress/SessionPoolingStressIT.java

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
import org.junit.Before;
2323
import org.junit.Rule;
2424
import org.junit.Test;
25+
import org.junit.rules.TestWatcher;
26+
import org.junit.runner.Description;
2527

2628
import java.util.List;
29+
import java.util.Map;
2730
import java.util.Random;
2831
import java.util.concurrent.ExecutorService;
2932
import java.util.concurrent.Executors;
@@ -45,10 +48,34 @@
4548
public class SessionPoolingStressIT
4649
{
4750
@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+
};
4976

5077
private static final int N_THREADS = 50;
51-
private static final int MAX_TIME = 10000;
78+
private static final int TEST_TIME = 10000;
5279

5380
private static final List<String> QUERIES = asList(
5481
"RETURN 1295 + 42", "UNWIND range(1,10000) AS x CREATE (n {prop:x}) DELETE n " );
@@ -90,11 +117,11 @@ public void shouldWorkFine() throws Throwable
90117

91118
doWork( stop, failureReference );
92119

93-
Thread.sleep( MAX_TIME );
120+
Thread.sleep( TEST_TIME );
94121

95122
stop.set( true );
96123
executor.shutdown();
97-
assertTrue( executor.awaitTermination( MAX_TIME, TimeUnit.MILLISECONDS ) );
124+
assertTrue( executor.awaitTermination( 20, TimeUnit.SECONDS ) );
98125

99126
Throwable failure = failureReference.get();
100127
if ( failure != null )

0 commit comments

Comments
 (0)