Env var to debug child processes. (#5305)

* adds env var to specify a port to wait for a debugger to connect to so child processes can be debugged in acceptance tests

---------

Signed-off-by: Justin Florentine <justin+github@florentine.us>
pull/5320/head
Justin Florentine 2 years ago committed by GitHub
parent 8950af3ff4
commit 89cf6b829d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java

@ -421,6 +421,24 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
+ "acceptance-tests/tests/build/resources/test/acceptanceTesting.security");
// add additional environment variables
processBuilder.environment().putAll(node.getEnvironment());
try {
int debugPort = Integer.parseInt(System.getenv("BESU_DEBUG_CHILD_PROCESS_PORT"));
LOG.warn("Waiting for debugger to attach to SUSPENDED child process");
String debugOpts =
" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:" + debugPort;
String prevJavaOpts = processBuilder.environment().get("JAVA_OPTS");
if (prevJavaOpts == null) {
processBuilder.environment().put("JAVA_OPTS", debugOpts);
} else {
processBuilder.environment().put("JAVA_OPTS", prevJavaOpts + debugOpts);
}
} catch (NumberFormatException e) {
LOG.debug(
"Child process may be attached to by exporting BESU_DEBUG_CHILD_PROCESS_PORT=<port> to env");
}
try {
checkState(
isNotAliveOrphan(node.getName()),

Loading…
Cancel
Save