Skip to content

Commit f188871

Browse files
committed
Merge pull request apache#454 from datastax/ccm_branch_dir
Support cassandra.directory and cassandra.branch props for CCMBridge.
2 parents dc23bbb + b455412 commit f188871

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public class CCMBridge {
5353

5454
public static final String IP_PREFIX;
5555

56-
private static final String CASSANDRA_VERSION_REGEXP = "\\d\\.\\d\\.\\d+(-\\w+)?";
57-
static final File CASSANDRA_DIR;
5856
static final String CASSANDRA_VERSION;
5957

58+
static final String CASSANDRA_INSTALL_ARGS;
59+
6060
public static final String DEFAULT_CLIENT_TRUSTSTORE_PASSWORD = "cassandra1sfun";
6161
public static final String DEFAULT_CLIENT_TRUSTSTORE_PATH = "/client.truststore";
6262

@@ -89,13 +89,15 @@ public class CCMBridge {
8989
private static final String CCM_COMMAND;
9090

9191
static {
92-
String version = System.getProperty("cassandra.version");
93-
if (version.matches(CASSANDRA_VERSION_REGEXP)) {
94-
CASSANDRA_DIR = null;
95-
CASSANDRA_VERSION = "-v " + version;
92+
CASSANDRA_VERSION = System.getProperty("cassandra.version");
93+
String installDirectory = System.getProperty("cassandra.directory");
94+
String branch = System.getProperty("cassandra.branch");
95+
if (installDirectory != null && !installDirectory.trim().isEmpty()) {
96+
CASSANDRA_INSTALL_ARGS = "--install-dir=" + new File(installDirectory).getAbsolutePath();
97+
} else if(branch != null && !branch.trim().isEmpty()) {
98+
CASSANDRA_INSTALL_ARGS = "-v git:" + branch;
9699
} else {
97-
CASSANDRA_DIR = new File(version);
98-
CASSANDRA_VERSION = "";
100+
CASSANDRA_INSTALL_ARGS = "-v " + CASSANDRA_VERSION;
99101
}
100102

101103
String ip_prefix = System.getProperty("ipprefix");
@@ -286,7 +288,6 @@ private void execute(String command, Object... args) {
286288
logger.debug("Executing: " + fullCommand);
287289
CommandLine cli = CommandLine.parse(fullCommand);
288290
Executor executor = new DefaultExecutor();
289-
executor.setWorkingDirectory(CASSANDRA_DIR);
290291

291292
LogOutputStream outStream = new LogOutputStream() {
292293
@Override protected void processLine(String line, int logLevel) {
@@ -594,7 +595,7 @@ public static class Builder {
594595
private final String clusterName;
595596
private Integer[] nodes = { 1 };
596597
private boolean start = true;
597-
private String cassandraVersion = CASSANDRA_VERSION;
598+
private String cassandraInstallArgs = CASSANDRA_INSTALL_ARGS;
598599
private String[] startOptions = new String[0];
599600
private Map<String, String> cassandraConfiguration = Maps.newHashMap();
600601

@@ -634,7 +635,7 @@ public Builder notStarted() {
634635

635636
/** Defaults to system property cassandra.version */
636637
public Builder withCassandraVersion(String cassandraVersion) {
637-
this.cassandraVersion = "-v " + cassandraVersion;
638+
this.cassandraInstallArgs = "-v " + cassandraVersion;
638639
return this;
639640
}
640641

@@ -663,7 +664,7 @@ private String buildCreateCommand() {
663664
StringBuilder result = new StringBuilder(CCM_COMMAND + " create");
664665
result.append(" " + clusterName);
665666
result.append(" -i" + IP_PREFIX);
666-
result.append(" " + cassandraVersion);
667+
result.append(" " + cassandraInstallArgs);
667668
if (nodes.length > 0)
668669
result.append(" -n " + Joiner.on(":").join(nodes));
669670
if (startOptions.length > 0)

driver-core/src/test/java/com/datastax/driver/core/TestListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class TestListener extends TestListenerAdapter implements IInvokedMethodL
3030
private int test_index = 0;
3131

3232
static {
33-
System.out.println("[CCMBridge] Using Cassandra version: " + CCMBridge.CASSANDRA_VERSION);
33+
System.out.println("[CCMBridge] Using Cassandra version: " + CCMBridge.CASSANDRA_VERSION + " (install arguments: " + CCMBridge.CASSANDRA_INSTALL_ARGS + ")");
3434
}
3535

3636
@Override

0 commit comments

Comments
 (0)