Skip to content

Commit

Permalink
Merge pull request #6727 from alyokaz/enable-apitest-debugging-suspend
Browse files Browse the repository at this point in the history
Suspend instances in Apitest by CSV list in apitest.properties
  • Loading branch information
alejandrogarcia83 authored Jul 6, 2023
2 parents ee9109d + b5b68b5 commit a3da020
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -261,6 +265,12 @@ public ApiTestConfig(String... args) {
.withRequiredArg()
.ofType(Boolean.class)
.defaultsTo(true);

ArgumentAcceptingOptionSpec<String> suspendInstancesOpt =
parser.accepts(SUSPEND_INSTANCE, "Suspended the given instances when debugging")
.withRequiredArg()
.ofType(String.class)
.defaultsTo(EMPTY);
try {
CompositeOptionSet options = new CompositeOptionSet();

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions apitest/src/main/java/bisq/apitest/linux/BisqProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
: "";
}

Expand Down

0 comments on commit a3da020

Please sign in to comment.