-
Notifications
You must be signed in to change notification settings - Fork 1.5k
JAVA-6155 add thread dumps to evergreen logs on failed test cases #1932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| com.mongodb.internal.diagnostics.ThreadDumpOnFailureExtension |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| junit.jupiter.extensions.autodetection.enabled=true | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||
| * Copyright 2008-present MongoDB, Inc. | ||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||||||||||||||
| * you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||||||||||||||
| * You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||
| * Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||||||||||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||||||||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||||||||||
| * See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||||||||||
| * limitations under the License. | ||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| package com.mongodb.internal.diagnostics; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| import java.lang.management.ManagementFactory; | ||||||||||||||||||||||||||||||||||||||||
| import java.lang.management.ThreadInfo; | ||||||||||||||||||||||||||||||||||||||||
| import java.lang.management.ThreadMXBean; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| import com.mongodb.internal.diagnostics.logging.Logger; | ||||||||||||||||||||||||||||||||||||||||
| import com.mongodb.internal.diagnostics.logging.Loggers; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| import org.junit.jupiter.api.extension.ExtensionContext; | ||||||||||||||||||||||||||||||||||||||||
| import org.junit.jupiter.api.extension.TestWatcher; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+30
|
||||||||||||||||||||||||||||||||||||||||
| import java.lang.management.ManagementFactory; | |
| import java.lang.management.ThreadInfo; | |
| import java.lang.management.ThreadMXBean; | |
| import com.mongodb.internal.diagnostics.logging.Logger; | |
| import com.mongodb.internal.diagnostics.logging.Loggers; | |
| import org.junit.jupiter.api.extension.ExtensionContext; | |
| import org.junit.jupiter.api.extension.TestWatcher; | |
| import com.mongodb.internal.diagnostics.logging.Logger; | |
| import com.mongodb.internal.diagnostics.logging.Loggers; | |
| import org.junit.jupiter.api.extension.ExtensionContext; | |
| import org.junit.jupiter.api.extension.TestWatcher; | |
| import java.lang.management.ManagementFactory; | |
| import java.lang.management.ThreadInfo; | |
| import java.lang.management.ThreadMXBean; |
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testFailed ignores the provided cause, so the log entry won’t include the exception/stack trace that triggered the failure. Logging the throwable (e.g., using the error(String, Throwable) overload) would keep the failure reason adjacent to the thread dump in Evergreen/local logs.
| LOGGER.error("Test failed: " + testName + "\nThread dump:\n" + threadDump); | |
| LOGGER.error("Test failed: " + testName + "\nThread dump:\n" + threadDump, cause); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the cause will already be provided on assertion fail I don't think duplicating it for thread dumps makes sense
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logs a full JVM thread dump on every failed test. When failures cascade (e.g., environment outage causing many tests to fail), this can produce very large Evergreen logs and make the original failures harder to find. Consider throttling (e.g., only dump once per JVM via an AtomicBoolean, or once per test class) and/or adding a clear header/footer delimiter so each dump is easy to locate in the log stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
junit-platform.propertiesis included indriver-core’stestArtifactsJAR (seebuildSrc/src/main/kotlin/conventions/test-artifacts.gradle.kts:26-29), and several other modules depend on:driver-core:testArtifactsfor their tests (e.g.,driver-sync/build.gradle.kts:37-39). That means this setting may unintentionally enable JUnit Jupiter extension autodetection beyonddriver-coredepending on classpath resource resolution. If the intent is to scope this behavior to a specific module/test task, consider enabling it via the GradleTesttask/system property instead, or placing a shared properties file in a deliberately shared test-resources location.