Skip to content

Commit

Permalink
Suspend instances in Apitest by CSV list in apitest.properties
Browse files Browse the repository at this point in the history
Enable instances to be suspended in debugging mode by the inclusion of the
instance name in a CSV list in apitest.properties
  • Loading branch information
alyokaz committed Jun 10, 2023
1 parent c8c256f commit fcab232
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 fcab232

Please sign in to comment.