From fcab232701a33c00fa3ab3b36aff7febcfd97773 Mon Sep 17 00:00:00 2001 From: AllyKaz Date: Sat, 10 Jun 2023 11:39:44 +0100 Subject: [PATCH] Suspend instances in Apitest by CSV list in apitest.properties Enable instances to be suspended in debugging mode by the inclusion of the instance name in a CSV list in apitest.properties --- .../main/java/bisq/apitest/config/ApiTestConfig.java | 11 +++++++++++ .../src/main/java/bisq/apitest/linux/BisqProcess.java | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java b/apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java index ec2076e885e..1526e5d6698 100644 --- a/apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java +++ b/apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java @@ -85,6 +85,8 @@ public class ApiTestConfig { static final String ENABLE_BISQ_DEBUGGING = "enableBisqDebugging"; static final String REGISTER_DISPUTE_AGENTS = "registerDisputeAgents"; + static final String SUSPEND_INSTANCE = "suspendInstance"; + // Default values for certain options static final String DEFAULT_CONFIG_FILE_NAME = "apitest.properties"; @@ -126,6 +128,8 @@ public class ApiTestConfig { public final String baseBuildResourcesDir; public final String baseSrcResourcesDir; + public final String suspendedInstances; + // The parser that will be used to parse both cmd line and config file options private final OptionParser parser = new OptionParser(); @@ -261,6 +265,12 @@ public ApiTestConfig(String... args) { .withRequiredArg() .ofType(Boolean.class) .defaultsTo(true); + + ArgumentAcceptingOptionSpec suspendInstancesOpt = + parser.accepts(SUSPEND_INSTANCE, "Suspended the given instances when debugging") + .withRequiredArg() + .ofType(String.class) + .defaultsTo(EMPTY); try { CompositeOptionSet options = new CompositeOptionSet(); @@ -319,6 +329,7 @@ public ApiTestConfig(String... args) { this.callRateMeteringConfigPath = options.valueOf(callRateMeteringConfigPathOpt); this.enableBisqDebugging = options.valueOf(enableBisqDebuggingOpt); this.registerDisputeAgents = options.valueOf(registerDisputeAgentsOpt); + this.suspendedInstances = options.valueOf(suspendInstancesOpt); // Assign values to special-case static fields. BASH_PATH_VALUE = bashPath; diff --git a/apitest/src/main/java/bisq/apitest/linux/BisqProcess.java b/apitest/src/main/java/bisq/apitest/linux/BisqProcess.java index a3a9374d0b5..bd02ea087c4 100644 --- a/apitest/src/main/java/bisq/apitest/linux/BisqProcess.java +++ b/apitest/src/main/java/bisq/apitest/linux/BisqProcess.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import lombok.extern.slf4j.Slf4j; @@ -66,8 +67,9 @@ public BisqProcess(BisqAppConfig bisqAppConfig, ApiTestConfig config) { this.useDevPrivilegeKeys = true; this.findBisqPidScript = (config.isRunningTest ? "." : "./apitest") + "/scripts/get-bisq-pid.sh"; - this.debugOpts = config.enableBisqDebugging - ? " -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:" + bisqAppConfig.remoteDebugPort + this.debugOpts = config.enableBisqDebugging? " -agentlib:jdwp=transport=dt_socket,server=y," + + "suspend=" + (Arrays.asList(config.suspendedInstances.split(",")).contains(bisqAppConfig.name())?"y":"n") + + ",address=*:" + bisqAppConfig.remoteDebugPort : ""; }