Skip to content

Commit 8303257

Browse files
committed
Improve diagnostics for JUnit tests which crashed or timed out on Jenkins
Add test container memory events printing to check if Linux OOM killer was active Fix thread dump printing on junit test timeout Process.pid() API is available since JDK9 patch by Dmitry Konstantinov; reviewed by Michael Semb Wever for CASSANDRA-21172
1 parent 32154ee commit 8303257

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

.jenkins/Jenkinsfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,11 @@ def test(command, cell) {
433433
if (!cell.step.startsWith("microbench")) {
434434
junit testResults: "test/**/TEST-*.xml,test/**/cqlshlib*.xml,test/**/nosetests*.xml", testDataPublishers: [[$class: 'StabilityTestDataPublisher']]
435435
}
436+
// check if we had Linux OOM killer active within the test container which could kill forked JUnit JVM processes
437+
sh """
438+
echo "docker memory/oomkiller debug:"
439+
cat /sys/fs/cgroup/docker/memory.events || true
440+
"""
436441
sh """
437442
find test/output -type f -name "*.xml" -print0 | xargs -0 -r -n1 -P"\$(nproc)" xz -f
438443
echo "test result files compressed"; find test/output -type f -name "*.xml.xz" | wc -l

test/unit/org/apache/cassandra/JStackJUnitTask.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.io.BufferedReader;
2121
import java.io.IOException;
2222
import java.io.InputStreamReader;
23-
import java.lang.reflect.Field;
2423

2524
import org.apache.tools.ant.BuildException;
2625
import org.apache.tools.ant.taskdefs.ExecuteWatchdog;
@@ -77,6 +76,7 @@ public synchronized void timeoutOccured(Watchdog w)
7776
ProcessBuilder pb = new ProcessBuilder("jstack","-l", String.valueOf(pid));
7877
try
7978
{
79+
pb.redirectErrorStream(true);
8080
Process p = pb.start();
8181
try (BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())))
8282
{
@@ -100,22 +100,15 @@ public synchronized void timeoutOccured(Watchdog w)
100100

101101
private long getPid(Process process)
102102
{
103-
if (process.getClass().getName().equals("java.lang.UNIXProcess"))
103+
try
104104
{
105-
try
106-
{
107-
Field f = process.getClass().getDeclaredField("pid");
108-
f.setAccessible(true);
109-
long pid = f.getLong(process);
110-
f.setAccessible(false);
111-
return pid;
112-
}
113-
catch (IllegalAccessException | NoSuchFieldException e)
114-
{
115-
System.err.println("Could not get PID");
116-
}
105+
return process.pid();
106+
}
107+
catch (UnsupportedOperationException e)
108+
{
109+
System.err.println("Could not get PID");
110+
return -1;
117111
}
118-
return -1;
119112
}
120113
}
121114

0 commit comments

Comments
 (0)