Elffuss BraidHub

kikocis/java-driver public

Merge pull request #670 from datastax/appveyor-enablement

Appveyor CI enablement
Changeseta19925ef7c84818929b26b519f8687ea2e34ecfd6a45a2ddd2eeca3b06dd31d4
AuthorOlivier Michallat <olim7t@users.noreply.github.com> · 2016-07-13 13:14 -07:00
CommitterGitHub <noreply@github.com> · 2016-07-13 13:14 -07:00
Parentse967f87184b2, 1bc6dee8bb72

Browse the files at this changeset

14 files changed

modified README.md +1 −1
@@ -1,6 +1,6 @@
11 # Datastax Java Driver for Apache Cassandra
22
3-[![Build Status](https://travis-ci.org/datastax/java-driver.svg?branch=3.0.x)](https://travis-ci.org/datastax/java-driver)
3+[![Build Status](https://travis-ci.org/datastax/java-driver.svg?branch=3.0.x)](https://travis-ci.org/datastax/java-driver) [![Build status](https://ci.appveyor.com/api/projects/status/717ysg5l1si1h3pi/branch/3.0.x?svg=true)](https://ci.appveyor.com/project/DataStax/java-driver/branch/3.0.x)
44
55 *If you're reading this on github.com, please note that this is the readme
66 for the development version and that some features described here might
added ci/appveyor.ps1 +129 −0
@@ -0,0 +1,129 @@
1+Add-Type -AssemblyName System.IO.Compression.FileSystem
2+
3+$dep_dir="C:\Users\appveyor\deps"
4+If (!(Test-Path $dep_dir)) {
5+ Write-Host "Creating $($dep_dir)"
6+ New-Item -Path $dep_dir -ItemType Directory -Force
7+}
8+
9+$apr_platform = "Win32"
10+$openssl_platform = "Win32"
11+$vc_platform = "x86"
12+$env:PYTHON="C:\Python27"
13+$env:OPENSSL_PATH="C:\OpenSSL-Win32"
14+If ($env:PLATFORM -eq "X64") {
15+ $apr_platform = "x64"
16+ $vc_platform = "x64"
17+ $env:PYTHON="C:\Python27-x64"
18+ $env:OPENSSL_PATH="C:\OpenSSL-Win64"
19+}
20+
21+$env:JAVA_HOME="C:\Program Files\Java\jdk$($env:java_version)"
22+$env:JAVA_8_HOME="C:\Program Files\Java\jdk1.8.0"
23+$env:PATH="$($env:PYTHON);$($env:PYTHON)\Scripts;$($env:JAVA_HOME)\bin;$($env:OPENSSL_PATH)\bin;$($env:PATH)"
24+$env:CCM_PATH="$($dep_dir)\ccm"
25+
26+$apr_dist_path = "$($dep_dir)\apr"
27+# Build APR if it hasn't been previously built.
28+If (!(Test-Path $apr_dist_path)) {
29+ Write-Host "Cloning APR"
30+ $apr_path = "C:\Users\appveyor\apr"
31+ Start-Process git -ArgumentList "clone --branch=1.5.2 --depth=1 https://github.com/apache/apr.git $($apr_path)" -Wait -nnw
32+ Write-Host "Setting Visual Studio Environment to VS 2015"
33+ Push-Location "$($env:VS140COMNTOOLS)\..\..\VC"
34+ cmd /c "vcvarsall.bat $vc_platform & set" |
35+ foreach {
36+ if ($_ -match "=") {
37+ $v = $_.split("="); Set-Item -force -path "ENV:\$($v[0])" -value "$($v[1])"
38+ }
39+ }
40+ Pop-Location
41+ Write-Host "Building APR (an error may be printed, but it will still build)"
42+ Push-Location $($apr_path)
43+ cmd /c nmake -f Makefile.win ARCH="$apr_platform Release" PREFIX=$($apr_dist_path) buildall install
44+ Pop-Location
45+ Write-Host "Done Building APR"
46+}
47+$env:PATH="$($apr_dist_path)\bin;$($env:PATH)"
48+
49+# Install Ant and Maven
50+$ant_base = "$($dep_dir)\ant"
51+$ant_path = "$($ant_base)\apache-ant-1.9.7"
52+If (!(Test-Path $ant_path)) {
53+ Write-Host "Installing Ant"
54+ $ant_url = "https://www.dropbox.com/s/lgx95x1jr6s787l/apache-ant-1.9.7-bin.zip?dl=1"
55+ $ant_zip = "C:\Users\appveyor\apache-ant-1.9.7-bin.zip"
56+ (new-object System.Net.WebClient).DownloadFile($ant_url, $ant_zip)
57+ [System.IO.Compression.ZipFile]::ExtractToDirectory($ant_zip, $ant_base)
58+}
59+$env:PATH="$($ant_path)\bin;$($env:PATH)"
60+
61+$maven_base = "$($dep_dir)\maven"
62+$maven_path = "$($maven_base)\apache-maven-3.2.5"
63+If (!(Test-Path $maven_path)) {
64+ Write-Host "Installing Maven"
65+ $maven_url = "https://www.dropbox.com/s/fh9kffmexprsmha/apache-maven-3.2.5-bin.zip?dl=1"
66+ $maven_zip = "C:\Users\appveyor\apache-maven-3.2.5-bin.zip"
67+ (new-object System.Net.WebClient).DownloadFile($maven_url, $maven_zip)
68+ [System.IO.Compression.ZipFile]::ExtractToDirectory($maven_zip, $maven_base)
69+}
70+$env:PATH="$($maven_path)\bin;$($env:PATH)"
71+
72+$jdks = @("1.6.0", "1.7.0", "1.8.0")
73+foreach ($jdk in $jdks) {
74+ $java_dir = "C:\Program Files\Java\jdk$jdk"
75+ $jce_target = "$java_dir\jre\lib\security"
76+ $jce_indicator = "$jce_target\README.txt"
77+ # Install Java Cryptographic Extensions, needed for SSL.
78+ # If this file doesn't exist we know JCE hasn't been installed.
79+ If (!(Test-Path $jce_indicator)) {
80+ Write-Host "Installing JCE for $jdk"
81+ $zip = "$dep_dir\jce_policy-$jdk.zip"
82+ $url = "https://www.dropbox.com/s/po4308hlwulpvep/UnlimitedJCEPolicyJDK7.zip?dl=1"
83+ $extract_folder = "UnlimitedJCEPolicy"
84+ If ($jdk -eq "1.8.0") {
85+ $url = "https://www.dropbox.com/s/al1e6e92cjdv7m7/jce_policy-8.zip?dl=1"
86+ $extract_folder = "UnlimitedJCEPolicyJDK8"
87+ }
88+ ElseIf ($jdk -eq "1.6.0") {
89+ $url = "https://www.dropbox.com/s/dhrtucxcif4n11k/jce_policy-6.zip?dl=1"
90+ $extract_folder = "jce"
91+ }
92+ # Download zip to staging area if it doesn't exist, we do this because
93+ # we extract it to the directory based on the platform and we want to cache
94+ # this file so it can apply to all platforms.
95+ if(!(Test-Path $zip)) {
96+ (new-object System.Net.WebClient).DownloadFile($url, $zip)
97+ }
98+
99+ [System.IO.Compression.ZipFile]::ExtractToDirectory($zip, $jce_target)
100+
101+ $jcePolicyDir = "$jce_target\$extract_folder"
102+ Move-Item $jcePolicyDir\* $jce_target\ -force
103+ Remove-Item $jcePolicyDir
104+ }
105+}
106+
107+# Install Python Dependencies for CCM.
108+Write-Host "Installing Python Dependencies for CCM"
109+Start-Process python -ArgumentList "-m pip install psutil pyYaml six" -Wait -nnw
110+
111+# Clone ccm from git and use master.
112+If (!(Test-Path $env:CCM_PATH)) {
113+ Write-Host "Cloning CCM"
114+ Start-Process git -ArgumentList "clone https://github.com/pcmanus/ccm.git $($env:CCM_PATH)" -Wait -nnw
115+}
116+
117+# Copy ccm -> ccm.py so windows knows to run it.
118+If (!(Test-Path $env:CCM_PATH\ccm.py)) {
119+ Copy-Item "$env:CCM_PATH\ccm" "$env:CCM_PATH\ccm.py"
120+}
121+$env:PYTHONPATH="$($env:CCM_PATH);$($env:PYTHONPATH)"
122+$env:PATH="$($env:CCM_PATH);$($env:PATH)"
123+
124+# Predownload cassandra version for CCM if it isn't already downloaded.
125+If (!(Test-Path C:\Users\appveyor\.ccm\repository\$env:cassandra_version)) {
126+ Write-Host "Preinstalling C* $($env:cassandra_version)"
127+ Start-Process python -ArgumentList "$($env:CCM_PATH)\ccm.py create -v $($env:cassandra_version) -n 1 predownload" -Wait -nnw
128+ Start-Process python -ArgumentList "$($env:CCM_PATH)\ccm.py remove predownload" -Wait -nnw
129+}
added ci/appveyor.yml +21 −0
@@ -0,0 +1,21 @@
1+environment:
2+ test_profile: default
3+ cassandra_version: 3.5
4+ matrix:
5+ - java_version: 1.6.0
6+ - java_version: 1.7.0
7+ - java_version: 1.8.0
8+ test_profile: short
9+platform: x64
10+install:
11+ - ps: .\ci\appveyor.ps1
12+build_script:
13+ - mvn -B install -DskipTests=true
14+test_script:
15+ - "mvn -B -Dccm.java.home=\"%JAVA_8_HOME%\" -Dccm.maxNumberOfNodes=1 -Dcassandra.version=%cassandra_version% verify -P%test_profile%"
16+on_finish:
17+ - ps: .\ci\uploadtests.ps1
18+cache:
19+ - C:\Users\appveyor\.m2
20+ - C:\Users\appveyor\.ccm\repository
21+ - C:\Users\appveyor\deps -> .\ci\appveyor.ps1
added ci/uploadtests.ps1 +17 −0
@@ -0,0 +1,17 @@
1+$testResults=Get-ChildItem TEST-TestSuite.xml -Recurse
2+
3+Write-Host "Uploading test results."
4+
5+$url = "https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)"
6+$wc = New-Object 'System.Net.WebClient'
7+
8+foreach ($testResult in $testResults) {
9+ try {
10+ Write-Host -ForegroundColor Green "Uploading $testResult -> $url."
11+ $wc.UploadFile($url, $testResult)
12+ } catch [Net.WebException] {
13+ Write-Host -ForegroundColor Red "Failed Uploading $testResult -> $url. $_"
14+ }
15+}
16+
17+Write-Host "Done uploading test results."
modified driver-core/pom.xml +1 −1
@@ -130,7 +130,7 @@
130130 <dependency>
131131 <groupId>io.netty</groupId>
132132 <artifactId>netty-tcnative</artifactId>
133- <version>1.1.33.Fork17</version>
133+ <version>1.1.33.Fork18</version>
134134 <classifier>${os.detected.classifier}</classifier>
135135 <scope>test</scope>
136136 </dependency>
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +18 −5
@@ -167,7 +167,7 @@
167167 }
168168
169169 if (isWindows()) {
170- CCM_COMMAND = "cmd /c ccm.py";
170+ CCM_COMMAND = "powershell.exe -ExecutionPolicy Unrestricted ccm.py";
171171 } else {
172172 CCM_COMMAND = "ccm";
173173 }
@@ -193,7 +193,7 @@
193193 *
194194 * @return <code>true</code> if the operating system is a Windows one, <code>false</code> otherwise.
195195 */
196- private static boolean isWindows() {
196+ public static boolean isWindows() {
197197
198198 String osName = System.getProperty("os.name");
199199 return osName != null && osName.startsWith("Windows");
@@ -386,7 +386,11 @@
386386 if (logger.isDebugEnabled())
387387 logger.debug("Starting: {} - free memory: {} MB", this, TestUtils.getFreeMemoryMB());
388388 try {
389- execute(CCM_COMMAND + " start --wait-other-notice --wait-for-binary-proto" + jvmArgs);
389+ String cmd = CCM_COMMAND + " start --wait-other-notice --wait-for-binary-proto" + jvmArgs;
390+ if (isWindows() && this.version.compareTo(VersionNumber.parse("2.2.4")) >= 0) {
391+ cmd += " --quiet-windows";
392+ }
393+ execute(cmd);
390394 } catch (CCMException e) {
391395 logger.error("Could not start " + this, e);
392396 logger.error("CCM output:\n{}", e.getOut());
@@ -444,7 +448,11 @@
444448 public void start(int n) {
445449 logger.debug(String.format("Starting: node %s (%s%s:%s) in %s", n, TestUtils.IP_PREFIX, n, binaryPort, this));
446450 try {
447- execute(CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto" + jvmArgs, n);
451+ String cmd = CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto" + jvmArgs;
452+ if (isWindows() && this.version.compareTo(VersionNumber.parse("2.2.4")) >= 0) {
453+ cmd += " --quiet-windows";
454+ }
455+ execute(cmd, n);
448456 } catch (CCMException e) {
449457 logger.error(String.format("Could not start node %s in %s", n, this), e);
450458 logger.error("CCM output:\n{}", e.getOut());
@@ -875,9 +883,14 @@
875883
876884 private String joinJvmArgs() {
877885 StringBuilder allJvmArgs = new StringBuilder("");
886+ String quote = isWindows() ? "\"" : "";
878887 for (String jvmArg : jvmArgs) {
879- allJvmArgs.append(" --jvm_arg=");
888+ // Windows requires jvm arguments to be quoted, while *nix requires unquoted.
889+ allJvmArgs.append(" ");
890+ allJvmArgs.append(quote);
891+ allJvmArgs.append("--jvm_arg=");
880892 allJvmArgs.append(randomizePorts(jvmArg));
893+ allJvmArgs.append(quote);
881894 }
882895 return allJvmArgs.toString();
883896 }
modified driver-core/src/test/java/com/datastax/driver/core/HostConnectionPoolTest.java +39 −19
@@ -19,6 +19,7 @@
1919 import com.datastax.driver.core.exceptions.BusyConnectionException;
2020 import com.datastax.driver.core.exceptions.ConnectionException;
2121 import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
22+import com.google.common.base.Predicate;
2223 import com.google.common.util.concurrent.*;
2324 import org.scassandra.cql.PrimitiveType;
2425 import org.scassandra.http.client.PrimingRequest;
@@ -33,6 +34,7 @@
3334 import java.util.concurrent.atomic.AtomicReference;
3435
3536 import static com.datastax.driver.core.Assertions.assertThat;
37+import static com.datastax.driver.core.ConditionChecker.check;
3638 import static com.google.common.collect.Lists.newArrayList;
3739 import static java.util.Collections.singletonList;
3840 import static java.util.concurrent.TimeUnit.SECONDS;
@@ -49,6 +51,22 @@
4951 cluster.close();
5052 }
5153
54+ /**
55+ * Ensure the given pool has the given size within 5 seconds.
56+ *
57+ * @param pool Pool to check.
58+ * @param expectedSize Expected size of pool.
59+ */
60+ private void assertPoolSize(HostConnectionPool pool, final int expectedSize) {
61+ check().before(5, TimeUnit.SECONDS)
62+ .that(pool, new Predicate<HostConnectionPool>() {
63+ @Override
64+ public boolean apply(HostConnectionPool input) {
65+ return input.connections.size() == expectedSize;
66+ }
67+ }).becomesTrue();
68+ }
69+
5270 /**
5371 * Sends 101 requests on pool, asserting that the connection used is in expectedConnections, except for the last request.
5472 */
@@ -157,7 +175,8 @@
157175 requests.addAll(fillConnectionToThreshold(pool, coreConnections));
158176
159177 // Allow time for new connection to be spawned.
160- verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class));
178+ verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class));
179+ assertPoolSize(pool, 2);
161180
162181 // Borrow more and ensure the connection returned is a non-core connection.
163182 for (int i = 0; i < 100; i++) {
@@ -203,8 +222,8 @@
203222 requests.addAll(fillConnectionToThreshold(pool, singletonList(core)));
204223
205224 // Reaching the threshold should have triggered the creation of an extra one
206- verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class));
207- assertThat(pool.connections).hasSize(2);
225+ verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class));
226+ assertPoolSize(pool, 2);
208227 } finally {
209228 completeRequests(requests);
210229 cluster.close();
@@ -231,8 +250,8 @@
231250
232251 requests.addAll(fillConnectionToThreshold(pool, singletonList(connection1)));
233252
234- verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class));
235- assertThat(pool.connections).hasSize(2);
253+ verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class));
254+ assertPoolSize(pool, 2);
236255 Connection connection2 = pool.connections.get(1);
237256
238257 assertThat(connection1.inFlight.get()).isEqualTo(101);
@@ -259,7 +278,8 @@
259278
260279 // Borrowing one more time should resurrect the trashed connection
261280 requests.addAll(sendRequests(1, pool));
262- verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class));
281+ verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class));
282+ assertPoolSize(pool, 2);
263283
264284 assertThat(pool.connections).containsExactly(connection2, connection1);
265285 assertThat(pool.trash).isEmpty();
@@ -291,9 +311,9 @@
291311
292312 requests.addAll(fillConnectionToThreshold(pool, singletonList(connection1)));
293313
294- verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class));
314+ verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class));
315+ assertPoolSize(pool, 2);
295316 reset(factory);
296- assertThat(pool.connections).hasSize(2);
297317 Connection connection2 = pool.connections.get(1);
298318
299319 assertThat(connection1.inFlight.get()).isEqualTo(101);
@@ -323,7 +343,8 @@
323343 // Fill the live connection to go over the threshold where a second one is needed
324344 requests.addAll(fillConnectionToThreshold(pool, singletonList(connection2)));
325345 assertThat(connection2.inFlight.get()).isEqualTo(101);
326- verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class));
346+ verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class));
347+ assertPoolSize(pool, 2);
327348
328349 // Borrow again to get the new connection
329350 MockRequest request = MockRequest.send(pool);
@@ -358,7 +379,7 @@
358379 // Fill core connection enough to trigger creation of another one
359380 requests.addAll(fillConnectionToThreshold(pool, singletonList(connection1)));
360381
361- verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class));
382+ verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class));
362383 assertThat(pool.connections).hasSize(2);
363384
364385 // Return enough times to get back under the threshold where one connection is enough
@@ -408,7 +429,7 @@
408429
409430 requests.addAll(fillConnectionToThreshold(pool, singletonList(core)));
410431
411- verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class));
432+ verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class));
412433 assertThat(pool.connections).hasSize(2);
413434
414435 // Grab the new non-core connection and replace it with a spy.
@@ -675,7 +696,7 @@
675696 }
676697
677698 // Pool should grow by 1.
678- verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class));
699+ verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class));
679700 assertThat(pool.connections).hasSize(2);
680701
681702 // Reset factory mock as we'll be checking for new open() invokes later.
@@ -710,12 +731,13 @@
710731
711732 // After some time the a connection should attempt to be opened (but will fail).
712733 verify(factory, timeout(readTimeout)).open(any(HostConnectionPool.class));
734+ assertPoolSize(pool, 1);
713735 assertThat(pool.connections).hasSize(1);
714736
715737 // Wait some reasonable amount of time for connection to reestablish then check pool size.
716738 Uninterruptibles.sleepUninterruptibly(readTimeout * 2, TimeUnit.MILLISECONDS);
717739 // Reconnecting failed since listening was enabled.
718- assertThat(pool.connections).hasSize(1);
740+ assertPoolSize(pool, 1);
719741
720742 // Re enable listening then wait for reconnect.
721743 currentClient.enableListener();
@@ -792,8 +814,7 @@
792814 requests.add(MockRequest.send(pool));
793815 verify(factory, timeout(readTimeout)).open(any(HostConnectionPool.class));
794816 reset(factory);
795- Uninterruptibles.sleepUninterruptibly(readTimeout, TimeUnit.MILLISECONDS);
796- assertThat(pool.connections).hasSize(i);
817+ assertPoolSize(pool, i);
797818 }
798819 } finally {
799820 completeRequests(requests);
@@ -896,8 +917,7 @@
896917
897918 // Should create up to core connections.
898919 verify(factory, timeout(readTimeout * 8).times(8)).open(any(HostConnectionPool.class));
899- Uninterruptibles.sleepUninterruptibly(readTimeout, TimeUnit.MILLISECONDS);
900- assertThat(pool.connections).hasSize(8);
920+ assertPoolSize(pool, 8);
901921 } finally {
902922 cluster.close();
903923 }
@@ -959,10 +979,10 @@
959979 }
960980
961981 /**
962- * <p/>
982+ * <p>
963983 * This test uses a table named "Java349" with 1000 column and performs asynchronously 100k insertions. While the
964984 * insertions are being executed, the number of opened connection is monitored.
965- * <p/>
985+ * <p>
966986 * If at anytime, the number of opened connections is negative, this test will fail.
967987 *
968988 * @jira_ticket JAVA-349
modified driver-core/src/test/java/com/datastax/driver/core/ProtocolV1Test.java +8 −0
@@ -16,6 +16,7 @@
1616 package com.datastax.driver.core;
1717
1818 import com.datastax.driver.core.exceptions.UnsupportedFeatureException;
19+import org.testng.SkipException;
1920 import org.testng.annotations.Test;
2021
2122 import static com.datastax.driver.core.ProtocolVersion.V1;
@@ -33,6 +34,13 @@
3334 .withProtocolVersion(V1);
3435 }
3536
37+ @Override
38+ public void beforeTestClass(Object testInstance) throws Exception {
39+ if (CCMBridge.isWindows())
40+ throw new SkipException("C* 1.2 is not supported on Windows.");
41+ super.beforeTestClass(testInstance);
42+ }
43+
3644 /**
3745 * Validates that a simple query with no variables is correctly executed.
3846 * @jira_ticket JAVA-1132
modified driver-core/src/test/java/com/datastax/driver/core/ReadTimeoutTest.java +1 −1
@@ -55,7 +55,7 @@
5555
5656 @Test(groups = "short")
5757 public void should_use_statement_timeout_if_overridden() {
58- Statement statement = new SimpleStatement(query).setReadTimeoutMillis(200);
58+ Statement statement = new SimpleStatement(query).setReadTimeoutMillis(10000);
5959 session.execute(statement);
6060 }
6161
modified driver-core/src/test/java/com/datastax/driver/core/SessionLeakTest.java +1 −1
@@ -34,7 +34,7 @@
3434
3535 SocketChannelMonitor channelMonitor;
3636
37- @Test(groups = "short")
37+ @Test(groups = "long")
3838 public void connectionLeakTest() throws Exception {
3939 // Checking for JAVA-342
4040 channelMonitor = new SocketChannelMonitor();
modified driver-core/src/test/java/com/datastax/driver/core/SpeculativeExecutionIntegrationTest.java +25 −12
@@ -20,7 +20,7 @@
2020 import org.mockito.Mockito;
2121 import org.testng.annotations.Test;
2222
23-import static org.assertj.core.api.Assertions.assertThat;
23+import static org.assertj.core.api.Assertions.fail;
2424 import static org.mockito.Mockito.times;
2525
2626 /**
@@ -41,8 +41,7 @@
4141 timestampGenerator = Mockito.spy(ServerSideTimestampGenerator.INSTANCE);
4242 return Cluster.builder()
4343 .withTimestampGenerator(timestampGenerator)
44- .withQueryOptions(new QueryOptions().setDefaultIdempotence(true))
45- // Set an artificially low timeout to force speculative execution
44+ // Set an artificially low timeout to force speculative execution
4645 .withSpeculativeExecutionPolicy(new ConstantSpeculativeExecutionPolicy(1, 2));
4746 }
4847
@@ -58,16 +57,30 @@
5857 public void should_use_same_default_timestamp_for_all_executions() {
5958 Metrics.Errors errors = cluster().getMetrics().getErrorMetrics();
6059
61- Mockito.reset(timestampGenerator);
62- long execStartCount = errors.getSpeculativeExecutions().getCount();
63-
64- BatchStatement batch = new BatchStatement();
65- for (int k = 0; k < 1000; k++) {
66- batch.add(new SimpleStatement("insert into foo(k,v) values (?,1)", k));
60+ // The check is attempted up to 10 times to account for the small possibility that a
61+ // scheduled execution is not needed/exercised. Even though the policy is set up
62+ // to schedule an execution after 1ms, the timeout might not fire before the response is received.
63+ int tryCount = 0;
64+ int maxTries = 10;
65+ while (tryCount++ < maxTries) {
66+ Mockito.reset(timestampGenerator);
67+ long execStartCount = errors.getSpeculativeExecutions().getCount();
68+
69+ BatchStatement batch = new BatchStatement();
70+ for (int k = 0; k < 1000; k++) {
71+ batch.add(new SimpleStatement("insert into foo(k,v) values (?,1)", k).setIdempotent(true));
72+ }
73+ batch.setIdempotent(true);
74+ session().execute(batch);
75+
76+ if (errors.getSpeculativeExecutions().getCount() == execStartCount + 1) {
77+ Mockito.verify(timestampGenerator, times(1)).next();
78+ break;
79+ }
6780 }
68- session().execute(batch);
6981
70- assertThat(errors.getSpeculativeExecutions().getCount()).isEqualTo(execStartCount + 1);
71- Mockito.verify(timestampGenerator, times(1)).next();
82+ if (tryCount == maxTries) {
83+ fail("Observed no speculative executions in 10 attempts");
84+ }
7285 }
7386 }
modified driver-core/src/test/java/com/datastax/driver/core/SpeculativeExecutionTest.java +1 −0
@@ -123,6 +123,7 @@
123123 ResultSet rs = session.execute(statement);
124124 Row row = rs.one();
125125
126+ assertThat(row).isNotNull();
126127 assertThat(row.getString("result")).isEqualTo("result1");
127128 assertThat(errors.getSpeculativeExecutions().getCount()).isEqualTo(execStartCount);
128129 assertThat(errors.getRetriesOnReadTimeout().getCount()).isEqualTo(retriesStartCount + 1);
modified manual/ssl/README.md +1 −1
@@ -154,7 +154,7 @@
154154
155155 There are known runtime incompatibilities between newer versions of
156156 netty-tcnative and the version of netty that the driver uses. For best
157-results, use version 1.1.33.Fork17.
157+results, use version 1.1.33.Fork18.
158158
159159 Using netty-tcnative requires JDK 1.7 or above and requires the presence of
160160 OpenSSL on the system. It will not fall back to the JDK implementation.
modified pom.xml +1 −1
@@ -66,7 +66,7 @@
6666 <assertj.version>1.7.0</assertj.version>
6767 <mockito.version>1.10.8</mockito.version>
6868 <commons-exec.version>1.3</commons-exec.version>
69- <scassandra.version>1.0.3</scassandra.version>
69+ <scassandra.version>1.0.9</scassandra.version>
7070 <main.basedir>${project.basedir}</main.basedir>
7171 <ipprefix>127.0.1.</ipprefix>
7272 <test.groups>unit</test.groups>