Elffuss BraidHub

kikocis/java-driver public

Merge pull request #454 from datastax/ccm_branch_dir

Support cassandra.directory and cassandra.branch props for CCMBridge.
Changeset801e028e39fe06be0c6be0585c6408611e7c5f54d28411c4d5e884f697c89598
AuthorOlivier Michallat <olim7t@users.noreply.github.com> · 2015-09-29 16:42 -07:00
CommitterOlivier Michallat <olim7t@users.noreply.github.com> · 2015-09-29 16:42 -07:00
Parents9e2d831fa720, acbdda3ac0cc

Browse the files at this changeset

2 files changed

modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +13 −12
@@ -53,10 +53,10 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)
modified driver-core/src/test/java/com/datastax/driver/core/TestListener.java +1 −1
@@ -30,7 +30,7 @@
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