Skip to content

Adding crash tracking to integration tests #7855

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

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,17 @@ public static void waitForPortToOpen(
}

if (!process.isAlive()) {
throw new RuntimeException("Process died before port " + port + " was opened");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made various improvements to the harness itself to make debugging process that exit abnormally easier

int exitCode = process.exitValue();
if (exitCode != 0) {
throw new RuntimeException(
"Process exited abnormally exitCode="
+ exitCode
+ " before port="
+ port
+ " was opened");
} else {
throw new RuntimeException("Process finished before port=" + port + " was opened");
}
}

if (isPortOpen(port)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ abstract class AbstractServerSmokeTest extends AbstractSmokeTest {
(0..<numberOfProcesses).each { idx ->
def port = httpPorts[idx]
def process = testedProcesses[idx]
PortUtils.waitForPortToOpen(port, 240, TimeUnit.SECONDS, process)

try {
PortUtils.waitForPortToOpen(port, 240, TimeUnit.SECONDS, process)
} catch ( Exception e ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding log information to make debug processes failing to start easier for the next person

throw new RuntimeException(e.getMessage() + " - log file " + logFilePaths[idx], e)
}
}
}

Expand All @@ -77,7 +82,23 @@ abstract class AbstractServerSmokeTest extends AbstractSmokeTest {
if (null != (outputFile = outputs[idx])) {
// check the structures written out to the log,
// and fail the run if anything unexpected was recorded
verifyLog(idx, outputFile)
try {
verifyLog(idx, outputFile)
} catch (FileNotFoundException e) {
if (testedProcesses[idx].isAlive()) {
throw e
}
def exitCode = testedProcesses[idx].exitValue()
if (exitCode == 0) {
throw e
} else {
def logFile = logFilePaths[idx]
// highlight when process exited abnormally, since that may have contributed
// to the log verification failure
throw new RuntimeException(
"Server process exited abnormally - exit code: ${exitCode}; check log file: ${logFile}", e)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,18 @@ abstract class AbstractSmokeTest extends ProcessManager {
"-Ddd.version=${VERSION}"
]

def testCrashTracking() {
return true
}

def javaProperties() {
def tmpDir = "/tmp"

def ret = [
"${getMaxMemoryArgumentForFork()}",
"${getMinMemoryArgumentForFork()}",
"-javaagent:${shadowJarPath}",
isIBM ? "-Xdump:directory=/tmp" : "-XX:ErrorFile=/tmp/hs_err_pid%p.log",
isIBM ? "-Xdump:directory=${tmpDir}" : "-XX:ErrorFile=${tmpDir}/hs_err_pid%p.log",
"-Ddd.trace.agent.port=${server.address.port}",
"-Ddd.env=${ENV}",
"-Ddd.version=${VERSION}",
Expand All @@ -190,9 +195,20 @@ abstract class AbstractSmokeTest extends ProcessManager {
if (testTelemetry()) {
ret += "-Ddd.telemetry.heartbeat.interval=5"
}
// DQH - Nov 2024 - skipping for J9 which doesn't have full crash tracking support
if (testCrashTracking() && !Platform.isJ9()) {
def extension = getScriptExtension()
ret += "-XX:OnError=\"${tmpDir}/dd_crash_uploader.${extension} %p\""
// Unlike crash tracking smoke test, keep the default delay; otherwise, otherwise other tests will fail
// ret += "-Ddd.dogstatsd.start-delay=0"
}
ret as String[]
}

static String getScriptExtension() {
return Platform.isWindows() ? "bat" : "sh"
}

def inferServiceName() {
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ abstract class ProcessManager extends Specification {
outputThreads.captureOutput(p, new File(logFilePaths[idx]))
}
testedProcess = numberOfProcesses == 1 ? testedProcesses[0] : null


(0..<numberOfProcesses).each { idx ->
def curProc = testedProcesses[idx]

if ( !curProc.isAlive() && curProc.exitValue() != 0 ) {
def exitCode = curProc.exitValue()
def logFile = logFilePaths[idx]

throw new RuntimeException("Process exited abormally - exitCode:${exitCode}; logFile=${logFile}")
}
}
}

String javaPath() {
Expand Down
Loading