kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 7146e07acfa02cb40558667fa6009dadee038c174fb198de79060e212215256d |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2016-12-15 16:08 -06:00 |
| Committer | GitHub <noreply@github.com> · 2016-12-15 16:08 -06:00 |
| Parents | eb74149ffde9, d7b37357011f |
10 files changed
modified build.yaml +8 −1
| @@ -4,7 +4,12 @@ | ||
| 4 | 4 | schedule: per_commit |
| 5 | 5 | matrix: |
| 6 | 6 | exclude: |
| 7 | - - java: [openjdk6, oraclejdk7] | |
| 7 | + # Exclude all java 7 builds | |
| 8 | + - java: oraclejdk7 | |
| 9 | + # Exclude java6 with all versions except latest | |
| 10 | + - java: openjdk6 | |
| 11 | + cassandra: ['1.2', '2.0', '2.1', '2.2', '3.0'] | |
| 12 | + # Exclude 2.2 and 3.0 always since 3.X provides latest protocol version | |
| 8 | 13 | - cassandra: ['2.2', '3.0'] |
| 9 | 14 | env_vars: | |
| 10 | 15 | TEST_GROUP="short" |
| @@ -39,6 +44,7 @@ | ||
| 39 | 44 | cassandra.version=$CCM_CASSANDRA_VERSION |
| 40 | 45 | ccm.java.home=$CCM_JAVA_HOME |
| 41 | 46 | ccm.path=$CCM_JAVA_HOME/bin |
| 47 | + ccm.maxNumberOfNodes=3 | |
| 42 | 48 | failIfNoTests=false |
| 43 | 49 | maven.test.failure.ignore=true |
| 44 | 50 | maven.javadoc.skip=true |
| @@ -51,6 +57,7 @@ | ||
| 51 | 57 | cassandra.version=$CCM_CASSANDRA_VERSION |
| 52 | 58 | ccm.java.home=$CCM_JAVA_HOME |
| 53 | 59 | ccm.path=$CCM_JAVA_HOME/bin |
| 60 | + ccm.maxNumberOfNodes=3 | |
| 54 | 61 | failIfNoTests=false |
| 55 | 62 | maven.test.failure.ignore=true |
| 56 | 63 | maven.javadoc.skip=true |
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +101 −19
| @@ -34,8 +34,7 @@ | ||
| 34 | 34 | import java.util.regex.Matcher; |
| 35 | 35 | import java.util.regex.Pattern; |
| 36 | 36 | |
| 37 | -import static com.datastax.driver.core.TestUtils.executeNoFail; | |
| 38 | -import static com.datastax.driver.core.TestUtils.findAvailablePort; | |
| 37 | +import static com.datastax.driver.core.TestUtils.*; | |
| 39 | 38 | |
| 40 | 39 | public class CCMBridge implements CCMAccess { |
| 41 | 40 | |
| @@ -86,11 +85,26 @@ | ||
| 86 | 85 | * {@link #getCassandraVersion()}. If C* version cannot be derived, the method makes a 'best guess'. |
| 87 | 86 | */ |
| 88 | 87 | private static final Map<String, String> dseToCassandraVersions = ImmutableMap.<String, String>builder() |
| 89 | - .put("5.0", "3.0") | |
| 88 | + .put("5.0.4", "3.0.10") | |
| 89 | + .put("5.0.3", "3.0.9") | |
| 90 | + .put("5.0.2", "3.0.8") | |
| 91 | + .put("5.0.1", "3.0.7") | |
| 92 | + .put("5.0", "3.0.7") | |
| 93 | + .put("4.8.11", "2.1.17") | |
| 94 | + .put("4.8.10", "2.1.15") | |
| 95 | + .put("4.8.9", "2.1.15") | |
| 96 | + .put("4.8.8", "2.1.14") | |
| 97 | + .put("4.8.7", "2.1.14") | |
| 98 | + .put("4.8.6", "2.1.13") | |
| 99 | + .put("4.8.5", "2.1.13") | |
| 100 | + .put("4.8.4", "2.1.12") | |
| 90 | 101 | .put("4.8.3", "2.1.11") |
| 91 | 102 | .put("4.8.2", "2.1.11") |
| 92 | 103 | .put("4.8.1", "2.1.11") |
| 93 | 104 | .put("4.8", "2.1.9") |
| 105 | + .put("4.7.9", "2.1.15") | |
| 106 | + .put("4.7.8", "2.1.13") | |
| 107 | + .put("4.7.7", "2.1.12") | |
| 94 | 108 | .put("4.7.6", "2.1.11") |
| 95 | 109 | .put("4.7.5", "2.1.11") |
| 96 | 110 | .put("4.7.4", "2.1.11") |
| @@ -221,7 +235,9 @@ | ||
| 221 | 235 | |
| 222 | 236 | private boolean closed = false; |
| 223 | 237 | |
| 224 | - private CCMBridge(String clusterName, boolean isDSE, VersionNumber version, int storagePort, int thriftPort, int binaryPort, String jvmArgs) { | |
| 238 | + private final int[] nodes; | |
| 239 | + | |
| 240 | + private CCMBridge(String clusterName, boolean isDSE, VersionNumber version, int storagePort, int thriftPort, int binaryPort, String jvmArgs, int[] nodes) { | |
| 225 | 241 | this.clusterName = clusterName; |
| 226 | 242 | this.version = version; |
| 227 | 243 | this.storagePort = storagePort; |
| @@ -229,6 +245,7 @@ | ||
| 229 | 245 | this.binaryPort = binaryPort; |
| 230 | 246 | this.isDSE = isDSE; |
| 231 | 247 | this.jvmArgs = jvmArgs; |
| 248 | + this.nodes = nodes; | |
| 232 | 249 | this.ccmDir = Files.createTempDir(); |
| 233 | 250 | } |
| 234 | 251 | |
| @@ -379,6 +396,21 @@ | ||
| 379 | 396 | logger.debug("Closed: {}", this); |
| 380 | 397 | } |
| 381 | 398 | |
| 399 | + /** | |
| 400 | + * Based on C* version, return the wait arguments. | |
| 401 | + * | |
| 402 | + * @return For C* 1.x, --wait-other-notice otherwise --no-wait | |
| 403 | + */ | |
| 404 | + private String getStartWaitArguments() { | |
| 405 | + // make a small exception for C* 1.2 as it has a bug where it starts listening on the binary | |
| 406 | + // interface slightly before it joins the cluster. | |
| 407 | + if (getCassandraVersion().startsWith("1.")) { | |
| 408 | + return " --wait-other-notice"; | |
| 409 | + } else { | |
| 410 | + return " --no-wait"; | |
| 411 | + } | |
| 412 | + } | |
| 413 | + | |
| 382 | 414 | @Override |
| 383 | 415 | public synchronized void start() { |
| 384 | 416 | if (started) |
| @@ -386,11 +418,23 @@ | ||
| 386 | 418 | if (logger.isDebugEnabled()) |
| 387 | 419 | logger.debug("Starting: {} - free memory: {} MB", this, TestUtils.getFreeMemoryMB()); |
| 388 | 420 | try { |
| 389 | - String cmd = CCM_COMMAND + " start --wait-other-notice --wait-for-binary-proto" + jvmArgs; | |
| 421 | + String cmd = CCM_COMMAND + " start " + jvmArgs + getStartWaitArguments(); | |
| 390 | 422 | if (isWindows() && this.version.compareTo(VersionNumber.parse("2.2.4")) >= 0) { |
| 391 | 423 | cmd += " --quiet-windows"; |
| 392 | 424 | } |
| 393 | 425 | execute(cmd); |
| 426 | + | |
| 427 | + // Wait for binary interface on each node. | |
| 428 | + int n = 1; | |
| 429 | + for (int dc = 1; dc <= nodes.length; dc++) { | |
| 430 | + int nodesInDc = nodes[dc - 1]; | |
| 431 | + for (int i = 0; i < nodesInDc; i++) { | |
| 432 | + InetSocketAddress addr = new InetSocketAddress(ipOfNode(n), binaryPort); | |
| 433 | + logger.debug("Waiting for binary protocol to show up for {}", addr); | |
| 434 | + TestUtils.waitUntilPortIsUp(addr); | |
| 435 | + n++; | |
| 436 | + } | |
| 437 | + } | |
| 394 | 438 | } catch (CCMException e) { |
| 395 | 439 | logger.error("Could not start " + this, e); |
| 396 | 440 | logger.error("CCM output:\n{}", e.getOut()); |
| @@ -448,11 +492,15 @@ | ||
| 448 | 492 | public void start(int n) { |
| 449 | 493 | logger.debug(String.format("Starting: node %s (%s%s:%s) in %s", n, TestUtils.IP_PREFIX, n, binaryPort, this)); |
| 450 | 494 | try { |
| 451 | - String cmd = CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto" + jvmArgs; | |
| 495 | + String cmd = CCM_COMMAND + " node%d start " + jvmArgs + getStartWaitArguments(); | |
| 452 | 496 | if (isWindows() && this.version.compareTo(VersionNumber.parse("2.2.4")) >= 0) { |
| 453 | 497 | cmd += " --quiet-windows"; |
| 454 | 498 | } |
| 455 | 499 | execute(cmd, n); |
| 500 | + // Wait for binary interface | |
| 501 | + InetSocketAddress addr = new InetSocketAddress(ipOfNode(n), binaryPort); | |
| 502 | + logger.debug("Waiting for binary protocol to show up for {}", addr); | |
| 503 | + TestUtils.waitUntilPortIsUp(addr); | |
| 456 | 504 | } catch (CCMException e) { |
| 457 | 505 | logger.error(String.format("Could not start node %s in %s", n, this), e); |
| 458 | 506 | logger.error("CCM output:\n{}", e.getOut()); |
| @@ -698,7 +746,7 @@ | ||
| 698 | 746 | |
| 699 | 747 | int[] nodes = {1}; |
| 700 | 748 | private boolean start = true; |
| 701 | - private boolean isDSE = isDSE(); | |
| 749 | + private Boolean isDSE = null; | |
| 702 | 750 | private String version = getCassandraVersion(); |
| 703 | 751 | private Set<String> createOptions = new LinkedHashSet<String>(getInstallArguments()); |
| 704 | 752 | private Set<String> jvmArgs = new LinkedHashSet<String>(); |
| @@ -759,11 +807,18 @@ | ||
| 759 | 807 | * Sets this cluster to be a DSE cluster (defaults to {@link #isDSE()} if this is never called). |
| 760 | 808 | */ |
| 761 | 809 | public Builder withDSE() { |
| 762 | - this.createOptions.add("--dse"); | |
| 763 | 810 | this.isDSE = true; |
| 764 | 811 | return this; |
| 765 | 812 | } |
| 766 | 813 | |
| 814 | + /** | |
| 815 | + * Sets this cluster to be a non-DSE cluster (defaults to {@link #isDSE()} if this is never called). | |
| 816 | + */ | |
| 817 | + public Builder withoutDSE() { | |
| 818 | + this.isDSE = false; | |
| 819 | + return this; | |
| 820 | + } | |
| 821 | + | |
| 767 | 822 | /** |
| 768 | 823 | * The Cassandra or DSE version to use (defaults to {@link #getCassandraVersion()} if this is never called). |
| 769 | 824 | */ |
| @@ -846,24 +901,38 @@ | ||
| 846 | 901 | public CCMBridge build() { |
| 847 | 902 | // be careful NOT to alter internal state (hashCode/equals) during build! |
| 848 | 903 | String clusterName = TestUtils.generateIdentifier("ccm_"); |
| 904 | + boolean dse = isDSE == null ? isDSE() : isDSE; | |
| 905 | + | |
| 849 | 906 | Map<String, Object> cassandraConfiguration = randomizePorts(this.cassandraConfiguration); |
| 850 | - Map<String, Object> dseConfiguration = randomizePorts(this.dseConfiguration); | |
| 851 | 907 | VersionNumber version = VersionNumber.parse(this.version); |
| 852 | 908 | int storagePort = Integer.parseInt(cassandraConfiguration.get("storage_port").toString()); |
| 853 | 909 | int thriftPort = Integer.parseInt(cassandraConfiguration.get("rpc_port").toString()); |
| 854 | 910 | int binaryPort = Integer.parseInt(cassandraConfiguration.get("native_transport_port").toString()); |
| 855 | - final CCMBridge ccm = new CCMBridge(clusterName, isDSE, version, storagePort, thriftPort, binaryPort, joinJvmArgs()); | |
| 911 | + final CCMBridge ccm = new CCMBridge(clusterName, dse, version, storagePort, thriftPort, binaryPort, joinJvmArgs(), nodes); | |
| 912 | + | |
| 856 | 913 | Runtime.getRuntime().addShutdownHook(new Thread() { |
| 857 | 914 | @Override |
| 858 | 915 | public void run() { |
| 859 | 916 | ccm.close(); |
| 860 | 917 | } |
| 861 | 918 | }); |
| 862 | - ccm.execute(buildCreateCommand(clusterName)); | |
| 919 | + ccm.execute(buildCreateCommand(clusterName, dse)); | |
| 863 | 920 | updateNodeConf(ccm); |
| 864 | 921 | ccm.updateConfig(cassandraConfiguration); |
| 865 | - if (!dseConfiguration.isEmpty()) | |
| 866 | - ccm.updateDSEConfig(dseConfiguration); | |
| 922 | + if (dse) { | |
| 923 | + Map<String, Object> dseConfiguration = Maps.newLinkedHashMap(this.dseConfiguration); | |
| 924 | + /* TODO: Use version passed in if present, there is currently a conflation of C* and DSE versions | |
| 925 | + * when it comes to this that don't want to disturb. No tests are currently using withVersion with | |
| 926 | + * dse, so its not an issue at the moment. */ | |
| 927 | + if (VersionNumber.parse(CCMBridge.getDSEVersion()).getMajor() >= 5) { | |
| 928 | + // randomize DSE specific ports if dse present and greater than 5.0 | |
| 929 | + dseConfiguration.put("lease_netty_server_port", RANDOM_PORT); | |
| 930 | + dseConfiguration.put("internode_messaging_options.port", RANDOM_PORT); | |
| 931 | + } | |
| 932 | + dseConfiguration = randomizePorts(dseConfiguration); | |
| 933 | + if (!dseConfiguration.isEmpty()) | |
| 934 | + ccm.updateDSEConfig(dseConfiguration); | |
| 935 | + } | |
| 867 | 936 | for (Map.Entry<Integer, Workload[]> entry : workloads.entrySet()) { |
| 868 | 937 | ccm.setWorkload(entry.getKey(), entry.getValue()); |
| 869 | 938 | } |
| @@ -895,7 +964,7 @@ | ||
| 895 | 964 | return allJvmArgs.toString(); |
| 896 | 965 | } |
| 897 | 966 | |
| 898 | - private String buildCreateCommand(String clusterName) { | |
| 967 | + private String buildCreateCommand(String clusterName, boolean dse) { | |
| 899 | 968 | StringBuilder result = new StringBuilder(CCM_COMMAND + " create"); |
| 900 | 969 | result.append(" ").append(clusterName); |
| 901 | 970 | result.append(" -i ").append(TestUtils.IP_PREFIX); |
| @@ -909,7 +978,20 @@ | ||
| 909 | 978 | result.append(node); |
| 910 | 979 | } |
| 911 | 980 | } |
| 912 | - result.append(" ").append(Joiner.on(" ").join(randomizePorts(createOptions))); | |
| 981 | + | |
| 982 | + // If not DSE, remove --dse if in createOptions. | |
| 983 | + Set<String> lCreateOptions = new LinkedHashSet<String>(createOptions); | |
| 984 | + if (!dse) { | |
| 985 | + Iterator<String> it = lCreateOptions.iterator(); | |
| 986 | + while (it.hasNext()) { | |
| 987 | + String option = it.next(); | |
| 988 | + // remove any version previously set and | |
| 989 | + // install-dir, which is incompatible | |
| 990 | + if (option.equals("--dse")) | |
| 991 | + it.remove(); | |
| 992 | + } | |
| 993 | + } | |
| 994 | + result.append(" ").append(Joiner.on(" ").join(randomizePorts(lCreateOptions))); | |
| 913 | 995 | return result.toString(); |
| 914 | 996 | } |
| 915 | 997 | |
| @@ -1000,14 +1082,14 @@ | ||
| 1000 | 1082 | if (this == o) return true; |
| 1001 | 1083 | if (o == null || getClass() != o.getClass()) return false; |
| 1002 | 1084 | Builder builder = (Builder) o; |
| 1003 | - if (isDSE != builder.isDSE) return false; | |
| 1004 | 1085 | if (!Arrays.equals(nodes, builder.nodes)) return false; |
| 1086 | + if (isDSE != null ? !isDSE.equals(builder.isDSE) : builder.isDSE != null) return false; | |
| 1087 | + if (!version.equals(builder.version)) return false; | |
| 1005 | 1088 | if (!createOptions.equals(builder.createOptions)) return false; |
| 1006 | 1089 | if (!jvmArgs.equals(builder.jvmArgs)) return false; |
| 1007 | 1090 | if (!cassandraConfiguration.equals(builder.cassandraConfiguration)) return false; |
| 1008 | 1091 | if (!dseConfiguration.equals(builder.dseConfiguration)) return false; |
| 1009 | - if (!workloads.equals(builder.workloads)) return false; | |
| 1010 | - return version.equals(builder.version); | |
| 1092 | + return workloads.equals(builder.workloads); | |
| 1011 | 1093 | } |
| 1012 | 1094 | |
| 1013 | 1095 | @Override |
| @@ -1015,7 +1097,7 @@ | ||
| 1015 | 1097 | // do not include cluster name and start, only |
| 1016 | 1098 | // properties relevant to the settings of the cluster |
| 1017 | 1099 | int result = Arrays.hashCode(nodes); |
| 1018 | - result = 31 * result + (isDSE ? 1 : 0); | |
| 1100 | + result = 31 * result + (isDSE != null ? isDSE.hashCode() : 0); | |
| 1019 | 1101 | result = 31 * result + createOptions.hashCode(); |
| 1020 | 1102 | result = 31 * result + jvmArgs.hashCode(); |
| 1021 | 1103 | result = 31 * result + cassandraConfiguration.hashCode(); |
modified driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +10 −4
| @@ -271,12 +271,12 @@ | ||
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | @SuppressWarnings("SimplifiableIfStatement") |
| 274 | - private boolean dse() { | |
| 274 | + private Boolean dse() { | |
| 275 | 275 | for (CCMConfig ann : annotations) { |
| 276 | 276 | if (ann != null && ann.dse().length > 0) |
| 277 | 277 | return ann.dse()[0]; |
| 278 | 278 | } |
| 279 | - return false; | |
| 279 | + return null; | |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | @SuppressWarnings("SimplifiableIfStatement") |
| @@ -430,8 +430,14 @@ | ||
| 430 | 430 | } |
| 431 | 431 | if (version() != null) |
| 432 | 432 | ccmBuilder.withVersion(version()); |
| 433 | - if (dse()) | |
| 434 | - ccmBuilder.withDSE(); | |
| 433 | + Boolean dse = dse(); | |
| 434 | + if (dse != null) { | |
| 435 | + if (dse) { | |
| 436 | + ccmBuilder.withDSE(); | |
| 437 | + } else { | |
| 438 | + ccmBuilder.withoutDSE(); | |
| 439 | + } | |
| 440 | + } | |
| 435 | 441 | if (ssl()) |
| 436 | 442 | ccmBuilder.withSSL(); |
| 437 | 443 | if (auth()) |
modified driver-core/src/test/java/com/datastax/driver/core/HeartbeatTest.java +52 −44
| @@ -63,40 +63,44 @@ | ||
| 63 | 63 | .setHeartbeatIntervalSeconds(3)) |
| 64 | 64 | .build()); |
| 65 | 65 | |
| 66 | - // Don't create any session, only the control connection will be established | |
| 67 | - cluster.init(); | |
| 68 | - | |
| 69 | - for (int i = 0; i < 5; i++) { | |
| 70 | - triggerRequestOnControlConnection(cluster); | |
| 71 | - SECONDS.sleep(1); | |
| 66 | + try { | |
| 67 | + // Don't create any session, only the control connection will be established | |
| 68 | + cluster.init(); | |
| 69 | + | |
| 70 | + for (int i = 0; i < 5; i++) { | |
| 71 | + triggerRequestOnControlConnection(cluster); | |
| 72 | + SECONDS.sleep(1); | |
| 73 | + } | |
| 74 | + assertThat(logs.getNext()).doesNotContain("sending heartbeat"); | |
| 75 | + | |
| 76 | + // Ensure heartbeat is sent after no activity. | |
| 77 | + SECONDS.sleep(4); | |
| 78 | + assertThat(logs.getNext()) | |
| 79 | + .contains("sending heartbeat") | |
| 80 | + .contains("heartbeat query succeeded"); | |
| 81 | + | |
| 82 | + // Ensure heartbeat is sent after continued inactivity. | |
| 83 | + SECONDS.sleep(4); | |
| 84 | + assertThat(logs.getNext()) | |
| 85 | + .contains("sending heartbeat") | |
| 86 | + .contains("heartbeat query succeeded"); | |
| 87 | + | |
| 88 | + // Ensure heartbeat is not sent after activity. | |
| 89 | + logs.getNext(); | |
| 90 | + for (int i = 0; i < 5; i++) { | |
| 91 | + triggerRequestOnControlConnection(cluster); | |
| 92 | + SECONDS.sleep(1); | |
| 93 | + } | |
| 94 | + assertThat(logs.getNext()).doesNotContain("sending heartbeat"); | |
| 95 | + | |
| 96 | + // Finally, ensure heartbeat is sent after inactivity. | |
| 97 | + SECONDS.sleep(4); | |
| 98 | + assertThat(logs.getNext()) | |
| 99 | + .contains("sending heartbeat") | |
| 100 | + .contains("heartbeat query succeeded"); | |
| 101 | + } finally { | |
| 102 | + cluster.close(); | |
| 72 | 103 | } |
| 73 | - assertThat(logs.getNext()).doesNotContain("sending heartbeat"); | |
| 74 | - | |
| 75 | - // Ensure heartbeat is sent after no activity. | |
| 76 | - SECONDS.sleep(4); | |
| 77 | - assertThat(logs.getNext()) | |
| 78 | - .contains("sending heartbeat") | |
| 79 | - .contains("heartbeat query succeeded"); | |
| 80 | - | |
| 81 | - // Ensure heartbeat is sent after continued inactivity. | |
| 82 | - SECONDS.sleep(4); | |
| 83 | - assertThat(logs.getNext()) | |
| 84 | - .contains("sending heartbeat") | |
| 85 | - .contains("heartbeat query succeeded"); | |
| 86 | - | |
| 87 | - // Ensure heartbeat is not sent after activity. | |
| 88 | - logs.getNext(); | |
| 89 | - for (int i = 0; i < 5; i++) { | |
| 90 | - triggerRequestOnControlConnection(cluster); | |
| 91 | - SECONDS.sleep(1); | |
| 92 | - } | |
| 93 | - assertThat(logs.getNext()).doesNotContain("sending heartbeat"); | |
| 94 | - | |
| 95 | - // Finally, ensure heartbeat is sent after inactivity. | |
| 96 | - SECONDS.sleep(4); | |
| 97 | - assertThat(logs.getNext()) | |
| 98 | - .contains("sending heartbeat") | |
| 99 | - .contains("heartbeat query succeeded"); | |
| 100 | 104 | } |
| 101 | 105 | |
| 102 | 106 | /** |
| @@ -119,18 +123,22 @@ | ||
| 119 | 123 | .setHeartbeatIntervalSeconds(0)) |
| 120 | 124 | .build()); |
| 121 | 125 | |
| 122 | - // Don't create any session, only the control connection will be established | |
| 123 | - cluster.init(); | |
| 124 | - | |
| 125 | - for (int i = 0; i < 5; i++) { | |
| 126 | - triggerRequestOnControlConnection(cluster); | |
| 127 | - SECONDS.sleep(1); | |
| 126 | + try { | |
| 127 | + // Don't create any session, only the control connection will be established | |
| 128 | + cluster.init(); | |
| 129 | + | |
| 130 | + for (int i = 0; i < 5; i++) { | |
| 131 | + triggerRequestOnControlConnection(cluster); | |
| 132 | + SECONDS.sleep(1); | |
| 133 | + } | |
| 134 | + assertThat(logs.get()).doesNotContain("sending heartbeat"); | |
| 135 | + | |
| 136 | + // Sleep for a while and ensure no heartbeat is sent. | |
| 137 | + SECONDS.sleep(32); | |
| 138 | + assertThat(logs.get()).doesNotContain("sending heartbeat"); | |
| 139 | + } finally { | |
| 140 | + cluster.close(); | |
| 128 | 141 | } |
| 129 | - assertThat(logs.get()).doesNotContain("sending heartbeat"); | |
| 130 | - | |
| 131 | - // Sleep for a while and ensure no heartbeat is sent. | |
| 132 | - SECONDS.sleep(32); | |
| 133 | - assertThat(logs.get()).doesNotContain("sending heartbeat"); | |
| 134 | 142 | } |
| 135 | 143 | |
| 136 | 144 | // Simulates activity on the control connection via the internal API |
modified driver-core/src/test/java/com/datastax/driver/core/HostMetadataIntegrationTest.java +5 −6
| @@ -15,6 +15,7 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | +import com.datastax.driver.core.utils.DseVersion; | |
| 18 | 19 | import org.apache.log4j.Level; |
| 19 | 20 | import org.apache.log4j.Logger; |
| 20 | 21 | import org.testng.annotations.Test; |
| @@ -35,24 +36,22 @@ | ||
| 35 | 36 | * This test is disabled as running DSE with workloads is intensive and has unreliable results |
| 36 | 37 | * when running CCM with multiple workloads. |
| 37 | 38 | * <p/> |
| 38 | - * FIXME: this test is currently disabled because nodes with specific workload | |
| 39 | - * do not seem to come up within the allocated time. | |
| 40 | 39 | * |
| 41 | 40 | * @test_category host:metadata |
| 42 | - * @jira_ticket JAVA1042 | |
| 41 | + * @jira_ticket JAVA-1042 | |
| 43 | 42 | * @see HostMetadataIntegrationTest#should_parse_dse_workload_and_version_if_available() |
| 44 | 43 | */ |
| 45 | - @Test(groups = "long", enabled = false) | |
| 44 | + @Test(groups = "long") | |
| 45 | + @DseVersion(major = 5.0) | |
| 46 | 46 | public void test_mixed_dse_workload() { |
| 47 | 47 | CCMBridge.Builder builder = CCMBridge.builder() |
| 48 | 48 | .withNodes(3) |
| 49 | 49 | .withDSE() |
| 50 | - .withVersion("4.8.3") | |
| 51 | 50 | .withWorkload(2, solr) |
| 52 | 51 | .withWorkload(3, spark); |
| 53 | 52 | CCMAccess ccm = CCMCache.get(builder); |
| 54 | 53 | |
| 55 | - VersionNumber version = VersionNumber.parse("4.8.3"); | |
| 54 | + VersionNumber version = VersionNumber.parse(CCMBridge.getDSEVersion()); | |
| 56 | 55 | |
| 57 | 56 | Cluster cluster = Cluster.builder() |
| 58 | 57 | .addContactPoints(ccm.addressOfNode(1).getAddress()) |
modified driver-core/src/test/java/com/datastax/driver/core/LoadBalancingPolicyBootstrapTest.java +34 −26
| @@ -53,12 +53,16 @@ | ||
| 53 | 53 | .withLoadBalancingPolicy(policy) |
| 54 | 54 | .build()); |
| 55 | 55 | |
| 56 | - cluster.init(); | |
| 57 | - | |
| 58 | - assertThat(policy.history).containsOnly( | |
| 59 | - entry(INIT, TestUtils.findHost(cluster, 1)), | |
| 60 | - entry(INIT, TestUtils.findHost(cluster, 2)) | |
| 61 | - ); | |
| 56 | + try { | |
| 57 | + cluster.init(); | |
| 58 | + | |
| 59 | + assertThat(policy.history).containsOnly( | |
| 60 | + entry(INIT, TestUtils.findHost(cluster, 1)), | |
| 61 | + entry(INIT, TestUtils.findHost(cluster, 2)) | |
| 62 | + ); | |
| 63 | + } finally { | |
| 64 | + cluster.close(); | |
| 65 | + } | |
| 62 | 66 | } |
| 63 | 67 | |
| 64 | 68 | /** |
| @@ -95,27 +99,31 @@ | ||
| 95 | 99 | .withLoadBalancingPolicy(policy) |
| 96 | 100 | .build()); |
| 97 | 101 | |
| 98 | - cluster.init(); | |
| 99 | - | |
| 100 | - if (policy.history.contains(entry(DOWN, TestUtils.findHost(cluster, nodeToStop)))) { | |
| 101 | - // This is the situation we're testing, the control connection tried the stopped node first. | |
| 102 | - assertThat(policy.history).containsExactly( | |
| 103 | - entry(INIT, TestUtils.findHost(cluster, activeNode)), | |
| 104 | - entry(DOWN, TestUtils.findHost(cluster, nodeToStop)) | |
| 105 | - ); | |
| 106 | - break; | |
| 107 | - } else { | |
| 108 | - assertThat(policy.history).containsOnly( | |
| 109 | - entry(INIT, TestUtils.findHost(cluster, 1)), | |
| 110 | - entry(INIT, TestUtils.findHost(cluster, 2)) | |
| 111 | - ); | |
| 112 | - | |
| 113 | - logger.info("Could not get first contact point to fail, retrying"); | |
| 114 | - | |
| 102 | + try { | |
| 103 | + cluster.init(); | |
| 104 | + | |
| 105 | + if (policy.history.contains(entry(DOWN, TestUtils.findHost(cluster, nodeToStop)))) { | |
| 106 | + // This is the situation we're testing, the control connection tried the stopped node first. | |
| 107 | + assertThat(policy.history).containsExactly( | |
| 108 | + entry(INIT, TestUtils.findHost(cluster, activeNode)), | |
| 109 | + entry(DOWN, TestUtils.findHost(cluster, nodeToStop)) | |
| 110 | + ); | |
| 111 | + break; | |
| 112 | + } else { | |
| 113 | + assertThat(policy.history).containsOnly( | |
| 114 | + entry(INIT, TestUtils.findHost(cluster, 1)), | |
| 115 | + entry(INIT, TestUtils.findHost(cluster, 2)) | |
| 116 | + ); | |
| 117 | + | |
| 118 | + logger.info("Could not get first contact point to fail, retrying"); | |
| 119 | + | |
| 120 | + cluster.close(); | |
| 121 | + | |
| 122 | + ccm().start(nodeToStop); | |
| 123 | + ccm().waitForUp(nodeToStop); | |
| 124 | + } | |
| 125 | + } finally { | |
| 115 | 126 | cluster.close(); |
| 116 | - | |
| 117 | - ccm().start(nodeToStop); | |
| 118 | - ccm().waitForUp(nodeToStop); | |
| 119 | 127 | } |
| 120 | 128 | } |
| 121 | 129 |
modified driver-core/src/test/java/com/datastax/driver/core/ProtocolV1Test.java +1 −1
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | /** |
| 26 | 26 | * Tests targeting protocol v1 specifically. |
| 27 | 27 | */ |
| 28 | -@CCMConfig(version = "1.2.19") | |
| 28 | +@CCMConfig(version = "1.2.19", dse = false) | |
| 29 | 29 | public class ProtocolV1Test extends CCMTestsSupport { |
| 30 | 30 | |
| 31 | 31 | @Override |
modified driver-core/src/test/java/com/datastax/driver/core/RecommissionedNodeTest.java +1 −0
| @@ -157,6 +157,7 @@ | ||
| 157 | 157 | .withStoragePort(mainCcm.getStoragePort()) |
| 158 | 158 | .withThriftPort(mainCcm.getThriftPort()) |
| 159 | 159 | .withBinaryPort(mainCcm.getBinaryPort()) |
| 160 | + .withoutDSE() | |
| 160 | 161 | .withVersion("1.2.19"); |
| 161 | 162 | otherCcm = CCMCache.get(otherCcmBuilder); |
| 162 | 163 | otherCcm.waitForUp(1); |
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +1 −1
| @@ -739,7 +739,7 @@ | ||
| 739 | 739 | * @return The desired target protocol version based on the 'cassandra.version' System property. |
| 740 | 740 | */ |
| 741 | 741 | public static ProtocolVersion getDesiredProtocolVersion() { |
| 742 | - String version = System.getProperty("cassandra.version"); | |
| 742 | + String version = CCMBridge.getCassandraVersion(); | |
| 743 | 743 | String[] versionArray = version.split("\\.|-"); |
| 744 | 744 | double major = Double.parseDouble(versionArray[0] + "." + versionArray[1]); |
| 745 | 745 | if (major < 2.0) { |
modified driver-core/src/test/java/com/datastax/driver/core/WarningsTest.java +2 −1
| @@ -23,6 +23,8 @@ | ||
| 23 | 23 | |
| 24 | 24 | import static org.assertj.core.api.Assertions.assertThat; |
| 25 | 25 | |
| 26 | +@CCMConfig(config = {"batch_size_warn_threshold_in_kb:5"}) | |
| 27 | +@CassandraVersion(major = 2.2) | |
| 26 | 28 | public class WarningsTest extends CCMTestsSupport { |
| 27 | 29 | |
| 28 | 30 | @Override |
| @@ -30,7 +32,6 @@ | ||
| 30 | 32 | execute("CREATE TABLE foo(k int primary key, v text)"); |
| 31 | 33 | } |
| 32 | 34 | |
| 33 | - @CassandraVersion(major = 2.2) | |
| 34 | 35 | @Test(groups = "short") |
| 35 | 36 | public void should_expose_warnings_on_execution_info() { |
| 36 | 37 | // the default batch size warn threshold is 5 * 1024 bytes, but after CASSANDRA-10876 there must be |