kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | b5a08ee3ce3d7b6eb34961341deb90eccef57216ef6d6defc94f1a05d9c2ee37 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2016-12-06 17:06 -06:00 |
| Committer | Andrew Tolbert <andrew.tolbert@datastax.com> · 2016-12-14 17:44 -06:00 |
| Parents | eb74149ffde9 |
5 files changed
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +63 −14
| @@ -86,11 +86,26 @@ | ||
| 86 | 86 | * {@link #getCassandraVersion()}. If C* version cannot be derived, the method makes a 'best guess'. |
| 87 | 87 | */ |
| 88 | 88 | private static final Map<String, String> dseToCassandraVersions = ImmutableMap.<String, String>builder() |
| 89 | - .put("5.0", "3.0") | |
| 89 | + .put("5.0.4", "3.0.10") | |
| 90 | + .put("5.0.3", "3.0.9") | |
| 91 | + .put("5.0.2", "3.0.8") | |
| 92 | + .put("5.0.1", "3.0.7") | |
| 93 | + .put("5.0", "3.0.7") | |
| 94 | + .put("4.8.11", "2.1.17") | |
| 95 | + .put("4.8.10", "2.1.15") | |
| 96 | + .put("4.8.9", "2.1.15") | |
| 97 | + .put("4.8.8", "2.1.14") | |
| 98 | + .put("4.8.7", "2.1.14") | |
| 99 | + .put("4.8.6", "2.1.13") | |
| 100 | + .put("4.8.5", "2.1.13") | |
| 101 | + .put("4.8.4", "2.1.12") | |
| 90 | 102 | .put("4.8.3", "2.1.11") |
| 91 | 103 | .put("4.8.2", "2.1.11") |
| 92 | 104 | .put("4.8.1", "2.1.11") |
| 93 | 105 | .put("4.8", "2.1.9") |
| 106 | + .put("4.7.9", "2.1.15") | |
| 107 | + .put("4.7.8", "2.1.13") | |
| 108 | + .put("4.7.7", "2.1.12") | |
| 94 | 109 | .put("4.7.6", "2.1.11") |
| 95 | 110 | .put("4.7.5", "2.1.11") |
| 96 | 111 | .put("4.7.4", "2.1.11") |
| @@ -698,7 +713,7 @@ | ||
| 698 | 713 | |
| 699 | 714 | int[] nodes = {1}; |
| 700 | 715 | private boolean start = true; |
| 701 | - private boolean isDSE = isDSE(); | |
| 716 | + private Boolean isDSE = null; | |
| 702 | 717 | private String version = getCassandraVersion(); |
| 703 | 718 | private Set<String> createOptions = new LinkedHashSet<String>(getInstallArguments()); |
| 704 | 719 | private Set<String> jvmArgs = new LinkedHashSet<String>(); |
| @@ -759,11 +774,18 @@ | ||
| 759 | 774 | * Sets this cluster to be a DSE cluster (defaults to {@link #isDSE()} if this is never called). |
| 760 | 775 | */ |
| 761 | 776 | public Builder withDSE() { |
| 762 | - this.createOptions.add("--dse"); | |
| 763 | 777 | this.isDSE = true; |
| 764 | 778 | return this; |
| 765 | 779 | } |
| 766 | 780 | |
| 781 | + /** | |
| 782 | + * Sets this cluster to be a non-DSE cluster (defaults to {@link #isDSE()} if this is never called). | |
| 783 | + */ | |
| 784 | + public Builder withoutDSE() { | |
| 785 | + this.isDSE = false; | |
| 786 | + return this; | |
| 787 | + } | |
| 788 | + | |
| 767 | 789 | /** |
| 768 | 790 | * The Cassandra or DSE version to use (defaults to {@link #getCassandraVersion()} if this is never called). |
| 769 | 791 | */ |
| @@ -846,24 +868,38 @@ | ||
| 846 | 868 | public CCMBridge build() { |
| 847 | 869 | // be careful NOT to alter internal state (hashCode/equals) during build! |
| 848 | 870 | String clusterName = TestUtils.generateIdentifier("ccm_"); |
| 871 | + boolean dse = isDSE == null ? isDSE() : isDSE; | |
| 872 | + | |
| 849 | 873 | Map<String, Object> cassandraConfiguration = randomizePorts(this.cassandraConfiguration); |
| 850 | - Map<String, Object> dseConfiguration = randomizePorts(this.dseConfiguration); | |
| 851 | 874 | VersionNumber version = VersionNumber.parse(this.version); |
| 852 | 875 | int storagePort = Integer.parseInt(cassandraConfiguration.get("storage_port").toString()); |
| 853 | 876 | int thriftPort = Integer.parseInt(cassandraConfiguration.get("rpc_port").toString()); |
| 854 | 877 | int binaryPort = Integer.parseInt(cassandraConfiguration.get("native_transport_port").toString()); |
| 855 | - final CCMBridge ccm = new CCMBridge(clusterName, isDSE, version, storagePort, thriftPort, binaryPort, joinJvmArgs()); | |
| 878 | + final CCMBridge ccm = new CCMBridge(clusterName, dse, version, storagePort, thriftPort, binaryPort, joinJvmArgs()); | |
| 879 | + | |
| 856 | 880 | Runtime.getRuntime().addShutdownHook(new Thread() { |
| 857 | 881 | @Override |
| 858 | 882 | public void run() { |
| 859 | 883 | ccm.close(); |
| 860 | 884 | } |
| 861 | 885 | }); |
| 862 | - ccm.execute(buildCreateCommand(clusterName)); | |
| 886 | + ccm.execute(buildCreateCommand(clusterName, dse)); | |
| 863 | 887 | updateNodeConf(ccm); |
| 864 | 888 | ccm.updateConfig(cassandraConfiguration); |
| 865 | - if (!dseConfiguration.isEmpty()) | |
| 866 | - ccm.updateDSEConfig(dseConfiguration); | |
| 889 | + if (dse) { | |
| 890 | + Map<String, Object> dseConfiguration = Maps.newLinkedHashMap(this.dseConfiguration); | |
| 891 | + /* TODO: Use version passed in if present, there is currently a conflation of C* and DSE versions | |
| 892 | + * when it comes to this that don't want to disturb. No tests are currently using withVersion with | |
| 893 | + * dse, so its not an issue at the moment. */ | |
| 894 | + if (VersionNumber.parse(CCMBridge.getDSEVersion()).getMajor() >= 5) { | |
| 895 | + // randomize DSE specific ports if dse present and greater than 5.0 | |
| 896 | + dseConfiguration.put("lease_netty_server_port", RANDOM_PORT); | |
| 897 | + dseConfiguration.put("internode_messaging_options.port", RANDOM_PORT); | |
| 898 | + } | |
| 899 | + dseConfiguration = randomizePorts(dseConfiguration); | |
| 900 | + if (!dseConfiguration.isEmpty()) | |
| 901 | + ccm.updateDSEConfig(dseConfiguration); | |
| 902 | + } | |
| 867 | 903 | for (Map.Entry<Integer, Workload[]> entry : workloads.entrySet()) { |
| 868 | 904 | ccm.setWorkload(entry.getKey(), entry.getValue()); |
| 869 | 905 | } |
| @@ -895,7 +931,7 @@ | ||
| 895 | 931 | return allJvmArgs.toString(); |
| 896 | 932 | } |
| 897 | 933 | |
| 898 | - private String buildCreateCommand(String clusterName) { | |
| 934 | + private String buildCreateCommand(String clusterName, boolean dse) { | |
| 899 | 935 | StringBuilder result = new StringBuilder(CCM_COMMAND + " create"); |
| 900 | 936 | result.append(" ").append(clusterName); |
| 901 | 937 | result.append(" -i ").append(TestUtils.IP_PREFIX); |
| @@ -909,7 +945,20 @@ | ||
| 909 | 945 | result.append(node); |
| 910 | 946 | } |
| 911 | 947 | } |
| 912 | - result.append(" ").append(Joiner.on(" ").join(randomizePorts(createOptions))); | |
| 948 | + | |
| 949 | + // If not DSE, remove --dse if in createOptions. | |
| 950 | + Set<String> lCreateOptions = new LinkedHashSet<String>(createOptions); | |
| 951 | + if (!dse) { | |
| 952 | + Iterator<String> it = lCreateOptions.iterator(); | |
| 953 | + while (it.hasNext()) { | |
| 954 | + String option = it.next(); | |
| 955 | + // remove any version previously set and | |
| 956 | + // install-dir, which is incompatible | |
| 957 | + if (option.equals("--dse")) | |
| 958 | + it.remove(); | |
| 959 | + } | |
| 960 | + } | |
| 961 | + result.append(" ").append(Joiner.on(" ").join(randomizePorts(lCreateOptions))); | |
| 913 | 962 | return result.toString(); |
| 914 | 963 | } |
| 915 | 964 | |
| @@ -1000,14 +1049,14 @@ | ||
| 1000 | 1049 | if (this == o) return true; |
| 1001 | 1050 | if (o == null || getClass() != o.getClass()) return false; |
| 1002 | 1051 | Builder builder = (Builder) o; |
| 1003 | - if (isDSE != builder.isDSE) return false; | |
| 1004 | 1052 | if (!Arrays.equals(nodes, builder.nodes)) return false; |
| 1053 | + if (isDSE != null ? !isDSE.equals(builder.isDSE) : builder.isDSE != null) return false; | |
| 1054 | + if (!version.equals(builder.version)) return false; | |
| 1005 | 1055 | if (!createOptions.equals(builder.createOptions)) return false; |
| 1006 | 1056 | if (!jvmArgs.equals(builder.jvmArgs)) return false; |
| 1007 | 1057 | if (!cassandraConfiguration.equals(builder.cassandraConfiguration)) return false; |
| 1008 | 1058 | if (!dseConfiguration.equals(builder.dseConfiguration)) return false; |
| 1009 | - if (!workloads.equals(builder.workloads)) return false; | |
| 1010 | - return version.equals(builder.version); | |
| 1059 | + return workloads.equals(builder.workloads); | |
| 1011 | 1060 | } |
| 1012 | 1061 | |
| 1013 | 1062 | @Override |
| @@ -1015,7 +1064,7 @@ | ||
| 1015 | 1064 | // do not include cluster name and start, only |
| 1016 | 1065 | // properties relevant to the settings of the cluster |
| 1017 | 1066 | int result = Arrays.hashCode(nodes); |
| 1018 | - result = 31 * result + (isDSE ? 1 : 0); | |
| 1067 | + result = 31 * result + (isDSE != null ? isDSE.hashCode() : 0); | |
| 1019 | 1068 | result = 31 * result + createOptions.hashCode(); |
| 1020 | 1069 | result = 31 * result + jvmArgs.hashCode(); |
| 1021 | 1070 | result = 31 * result + cassandraConfiguration.hashCode(); |
modified driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +16 −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()) |
| @@ -913,6 +919,12 @@ | ||
| 913 | 919 | } |
| 914 | 920 | LOGGER.debug("Using {}", ccm); |
| 915 | 921 | } |
| 922 | + | |
| 923 | + // Check to ensure binary protocol is listening before proceeding. | |
| 924 | + for (InetSocketAddress node : getContactPointsWithPorts()) { | |
| 925 | + LOGGER.debug("Waiting for binary protocol to show up for {}", node); | |
| 926 | + TestUtils.waitUntilPortIsUp(node); | |
| 927 | + } | |
| 916 | 928 | } |
| 917 | 929 | |
| 918 | 930 | protected void initTestCluster(Object testInstance) throws Exception { |
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/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); |