Elffuss BraidHub

kikocis/java-driver public

Support cassandra.directory and cassandra.branch props for CCMBridge.

Adds optional cassandra.directory and cassandra.branch properties as
a means of running cassandra with CCM beyond deployed cassandra
versions.

The order of precedence for what is used is:

1. cassandra.directory
2. cassandra.branch
3. cassandra.version

cassandra.version is still required for @CassandraVersion annotation
checks for tests, but won't be used to launch CCM if either
cassandra.directory or cassandra.branch is present.
Changesetacbdda3ac0cc15abb721ff5ff515bdfdb5a43e2735c2463ad43c88b655a79adb
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-09-15 16:01 -05:00
Committerolim7t <omichallat+github@gmail.com> · 2015-09-29 16:42 -07:00
Parents9e2d831fa720

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