kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | a19925ef7c84818929b26b519f8687ea2e34ecfd6a45a2ddd2eeca3b06dd31d4 |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2016-07-13 13:14 -07:00 |
| Committer | GitHub <noreply@github.com> · 2016-07-13 13:14 -07:00 |
| Parents | e967f87184b2, 1bc6dee8bb72 |
14 files changed
modified README.md +1 −1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # Datastax Java Driver for Apache Cassandra |
| 2 | 2 | |
| 3 | -[](https://travis-ci.org/datastax/java-driver) | |
| 3 | +[](https://travis-ci.org/datastax/java-driver) [](https://ci.appveyor.com/project/DataStax/java-driver/branch/3.0.x) | |
| 4 | 4 | |
| 5 | 5 | *If you're reading this on github.com, please note that this is the readme |
| 6 | 6 | 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 @@ | ||
| 130 | 130 | <dependency> |
| 131 | 131 | <groupId>io.netty</groupId> |
| 132 | 132 | <artifactId>netty-tcnative</artifactId> |
| 133 | - <version>1.1.33.Fork17</version> | |
| 133 | + <version>1.1.33.Fork18</version> | |
| 134 | 134 | <classifier>${os.detected.classifier}</classifier> |
| 135 | 135 | <scope>test</scope> |
| 136 | 136 | </dependency> |
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +18 −5
| @@ -167,7 +167,7 @@ | ||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | if (isWindows()) { |
| 170 | - CCM_COMMAND = "cmd /c ccm.py"; | |
| 170 | + CCM_COMMAND = "powershell.exe -ExecutionPolicy Unrestricted ccm.py"; | |
| 171 | 171 | } else { |
| 172 | 172 | CCM_COMMAND = "ccm"; |
| 173 | 173 | } |
| @@ -193,7 +193,7 @@ | ||
| 193 | 193 | * |
| 194 | 194 | * @return <code>true</code> if the operating system is a Windows one, <code>false</code> otherwise. |
| 195 | 195 | */ |
| 196 | - private static boolean isWindows() { | |
| 196 | + public static boolean isWindows() { | |
| 197 | 197 | |
| 198 | 198 | String osName = System.getProperty("os.name"); |
| 199 | 199 | return osName != null && osName.startsWith("Windows"); |
| @@ -386,7 +386,11 @@ | ||
| 386 | 386 | if (logger.isDebugEnabled()) |
| 387 | 387 | logger.debug("Starting: {} - free memory: {} MB", this, TestUtils.getFreeMemoryMB()); |
| 388 | 388 | 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); | |
| 390 | 394 | } catch (CCMException e) { |
| 391 | 395 | logger.error("Could not start " + this, e); |
| 392 | 396 | logger.error("CCM output:\n{}", e.getOut()); |
| @@ -444,7 +448,11 @@ | ||
| 444 | 448 | public void start(int n) { |
| 445 | 449 | logger.debug(String.format("Starting: node %s (%s%s:%s) in %s", n, TestUtils.IP_PREFIX, n, binaryPort, this)); |
| 446 | 450 | 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); | |
| 448 | 456 | } catch (CCMException e) { |
| 449 | 457 | logger.error(String.format("Could not start node %s in %s", n, this), e); |
| 450 | 458 | logger.error("CCM output:\n{}", e.getOut()); |
| @@ -875,9 +883,14 @@ | ||
| 875 | 883 | |
| 876 | 884 | private String joinJvmArgs() { |
| 877 | 885 | StringBuilder allJvmArgs = new StringBuilder(""); |
| 886 | + String quote = isWindows() ? "\"" : ""; | |
| 878 | 887 | 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="); | |
| 880 | 892 | allJvmArgs.append(randomizePorts(jvmArg)); |
| 893 | + allJvmArgs.append(quote); | |
| 881 | 894 | } |
| 882 | 895 | return allJvmArgs.toString(); |
| 883 | 896 | } |
modified driver-core/src/test/java/com/datastax/driver/core/HostConnectionPoolTest.java +39 −19
| @@ -19,6 +19,7 @@ | ||
| 19 | 19 | import com.datastax.driver.core.exceptions.BusyConnectionException; |
| 20 | 20 | import com.datastax.driver.core.exceptions.ConnectionException; |
| 21 | 21 | import com.datastax.driver.core.policies.ConstantReconnectionPolicy; |
| 22 | +import com.google.common.base.Predicate; | |
| 22 | 23 | import com.google.common.util.concurrent.*; |
| 23 | 24 | import org.scassandra.cql.PrimitiveType; |
| 24 | 25 | import org.scassandra.http.client.PrimingRequest; |
| @@ -33,6 +34,7 @@ | ||
| 33 | 34 | import java.util.concurrent.atomic.AtomicReference; |
| 34 | 35 | |
| 35 | 36 | import static com.datastax.driver.core.Assertions.assertThat; |
| 37 | +import static com.datastax.driver.core.ConditionChecker.check; | |
| 36 | 38 | import static com.google.common.collect.Lists.newArrayList; |
| 37 | 39 | import static java.util.Collections.singletonList; |
| 38 | 40 | import static java.util.concurrent.TimeUnit.SECONDS; |
| @@ -49,6 +51,22 @@ | ||
| 49 | 51 | cluster.close(); |
| 50 | 52 | } |
| 51 | 53 | |
| 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 | + | |
| 52 | 70 | /** |
| 53 | 71 | * Sends 101 requests on pool, asserting that the connection used is in expectedConnections, except for the last request. |
| 54 | 72 | */ |
| @@ -157,7 +175,8 @@ | ||
| 157 | 175 | requests.addAll(fillConnectionToThreshold(pool, coreConnections)); |
| 158 | 176 | |
| 159 | 177 | // 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); | |
| 161 | 180 | |
| 162 | 181 | // Borrow more and ensure the connection returned is a non-core connection. |
| 163 | 182 | for (int i = 0; i < 100; i++) { |
| @@ -203,8 +222,8 @@ | ||
| 203 | 222 | requests.addAll(fillConnectionToThreshold(pool, singletonList(core))); |
| 204 | 223 | |
| 205 | 224 | // 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); | |
| 208 | 227 | } finally { |
| 209 | 228 | completeRequests(requests); |
| 210 | 229 | cluster.close(); |
| @@ -231,8 +250,8 @@ | ||
| 231 | 250 | |
| 232 | 251 | requests.addAll(fillConnectionToThreshold(pool, singletonList(connection1))); |
| 233 | 252 | |
| 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); | |
| 236 | 255 | Connection connection2 = pool.connections.get(1); |
| 237 | 256 | |
| 238 | 257 | assertThat(connection1.inFlight.get()).isEqualTo(101); |
| @@ -259,7 +278,8 @@ | ||
| 259 | 278 | |
| 260 | 279 | // Borrowing one more time should resurrect the trashed connection |
| 261 | 280 | 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); | |
| 263 | 283 | |
| 264 | 284 | assertThat(pool.connections).containsExactly(connection2, connection1); |
| 265 | 285 | assertThat(pool.trash).isEmpty(); |
| @@ -291,9 +311,9 @@ | ||
| 291 | 311 | |
| 292 | 312 | requests.addAll(fillConnectionToThreshold(pool, singletonList(connection1))); |
| 293 | 313 | |
| 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); | |
| 295 | 316 | reset(factory); |
| 296 | - assertThat(pool.connections).hasSize(2); | |
| 297 | 317 | Connection connection2 = pool.connections.get(1); |
| 298 | 318 | |
| 299 | 319 | assertThat(connection1.inFlight.get()).isEqualTo(101); |
| @@ -323,7 +343,8 @@ | ||
| 323 | 343 | // Fill the live connection to go over the threshold where a second one is needed |
| 324 | 344 | requests.addAll(fillConnectionToThreshold(pool, singletonList(connection2))); |
| 325 | 345 | 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); | |
| 327 | 348 | |
| 328 | 349 | // Borrow again to get the new connection |
| 329 | 350 | MockRequest request = MockRequest.send(pool); |
| @@ -358,7 +379,7 @@ | ||
| 358 | 379 | // Fill core connection enough to trigger creation of another one |
| 359 | 380 | requests.addAll(fillConnectionToThreshold(pool, singletonList(connection1))); |
| 360 | 381 | |
| 361 | - verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class)); | |
| 382 | + verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class)); | |
| 362 | 383 | assertThat(pool.connections).hasSize(2); |
| 363 | 384 | |
| 364 | 385 | // Return enough times to get back under the threshold where one connection is enough |
| @@ -408,7 +429,7 @@ | ||
| 408 | 429 | |
| 409 | 430 | requests.addAll(fillConnectionToThreshold(pool, singletonList(core))); |
| 410 | 431 | |
| 411 | - verify(factory, after(1000).times(1)).open(any(HostConnectionPool.class)); | |
| 432 | + verify(factory, after(2000).times(1)).open(any(HostConnectionPool.class)); | |
| 412 | 433 | assertThat(pool.connections).hasSize(2); |
| 413 | 434 | |
| 414 | 435 | // Grab the new non-core connection and replace it with a spy. |
| @@ -675,7 +696,7 @@ | ||
| 675 | 696 | } |
| 676 | 697 | |
| 677 | 698 | // 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)); | |
| 679 | 700 | assertThat(pool.connections).hasSize(2); |
| 680 | 701 | |
| 681 | 702 | // Reset factory mock as we'll be checking for new open() invokes later. |
| @@ -710,12 +731,13 @@ | ||
| 710 | 731 | |
| 711 | 732 | // After some time the a connection should attempt to be opened (but will fail). |
| 712 | 733 | verify(factory, timeout(readTimeout)).open(any(HostConnectionPool.class)); |
| 734 | + assertPoolSize(pool, 1); | |
| 713 | 735 | assertThat(pool.connections).hasSize(1); |
| 714 | 736 | |
| 715 | 737 | // Wait some reasonable amount of time for connection to reestablish then check pool size. |
| 716 | 738 | Uninterruptibles.sleepUninterruptibly(readTimeout * 2, TimeUnit.MILLISECONDS); |
| 717 | 739 | // Reconnecting failed since listening was enabled. |
| 718 | - assertThat(pool.connections).hasSize(1); | |
| 740 | + assertPoolSize(pool, 1); | |
| 719 | 741 | |
| 720 | 742 | // Re enable listening then wait for reconnect. |
| 721 | 743 | currentClient.enableListener(); |
| @@ -792,8 +814,7 @@ | ||
| 792 | 814 | requests.add(MockRequest.send(pool)); |
| 793 | 815 | verify(factory, timeout(readTimeout)).open(any(HostConnectionPool.class)); |
| 794 | 816 | reset(factory); |
| 795 | - Uninterruptibles.sleepUninterruptibly(readTimeout, TimeUnit.MILLISECONDS); | |
| 796 | - assertThat(pool.connections).hasSize(i); | |
| 817 | + assertPoolSize(pool, i); | |
| 797 | 818 | } |
| 798 | 819 | } finally { |
| 799 | 820 | completeRequests(requests); |
| @@ -896,8 +917,7 @@ | ||
| 896 | 917 | |
| 897 | 918 | // Should create up to core connections. |
| 898 | 919 | 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); | |
| 901 | 921 | } finally { |
| 902 | 922 | cluster.close(); |
| 903 | 923 | } |
| @@ -959,10 +979,10 @@ | ||
| 959 | 979 | } |
| 960 | 980 | |
| 961 | 981 | /** |
| 962 | - * <p/> | |
| 982 | + * <p> | |
| 963 | 983 | * This test uses a table named "Java349" with 1000 column and performs asynchronously 100k insertions. While the |
| 964 | 984 | * insertions are being executed, the number of opened connection is monitored. |
| 965 | - * <p/> | |
| 985 | + * <p> | |
| 966 | 986 | * If at anytime, the number of opened connections is negative, this test will fail. |
| 967 | 987 | * |
| 968 | 988 | * @jira_ticket JAVA-349 |
modified driver-core/src/test/java/com/datastax/driver/core/ProtocolV1Test.java +8 −0
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | 18 | import com.datastax.driver.core.exceptions.UnsupportedFeatureException; |
| 19 | +import org.testng.SkipException; | |
| 19 | 20 | import org.testng.annotations.Test; |
| 20 | 21 | |
| 21 | 22 | import static com.datastax.driver.core.ProtocolVersion.V1; |
| @@ -33,6 +34,13 @@ | ||
| 33 | 34 | .withProtocolVersion(V1); |
| 34 | 35 | } |
| 35 | 36 | |
| 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 | + | |
| 36 | 44 | /** |
| 37 | 45 | * Validates that a simple query with no variables is correctly executed. |
| 38 | 46 | * @jira_ticket JAVA-1132 |
modified driver-core/src/test/java/com/datastax/driver/core/ReadTimeoutTest.java +1 −1
| @@ -55,7 +55,7 @@ | ||
| 55 | 55 | |
| 56 | 56 | @Test(groups = "short") |
| 57 | 57 | public void should_use_statement_timeout_if_overridden() { |
| 58 | - Statement statement = new SimpleStatement(query).setReadTimeoutMillis(200); | |
| 58 | + Statement statement = new SimpleStatement(query).setReadTimeoutMillis(10000); | |
| 59 | 59 | session.execute(statement); |
| 60 | 60 | } |
| 61 | 61 |
modified driver-core/src/test/java/com/datastax/driver/core/SessionLeakTest.java +1 −1
| @@ -34,7 +34,7 @@ | ||
| 34 | 34 | |
| 35 | 35 | SocketChannelMonitor channelMonitor; |
| 36 | 36 | |
| 37 | - @Test(groups = "short") | |
| 37 | + @Test(groups = "long") | |
| 38 | 38 | public void connectionLeakTest() throws Exception { |
| 39 | 39 | // Checking for JAVA-342 |
| 40 | 40 | channelMonitor = new SocketChannelMonitor(); |
modified driver-core/src/test/java/com/datastax/driver/core/SpeculativeExecutionIntegrationTest.java +25 −12
| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | import org.mockito.Mockito; |
| 21 | 21 | import org.testng.annotations.Test; |
| 22 | 22 | |
| 23 | -import static org.assertj.core.api.Assertions.assertThat; | |
| 23 | +import static org.assertj.core.api.Assertions.fail; | |
| 24 | 24 | import static org.mockito.Mockito.times; |
| 25 | 25 | |
| 26 | 26 | /** |
| @@ -41,8 +41,7 @@ | ||
| 41 | 41 | timestampGenerator = Mockito.spy(ServerSideTimestampGenerator.INSTANCE); |
| 42 | 42 | return Cluster.builder() |
| 43 | 43 | .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 | |
| 46 | 45 | .withSpeculativeExecutionPolicy(new ConstantSpeculativeExecutionPolicy(1, 2)); |
| 47 | 46 | } |
| 48 | 47 | |
| @@ -58,16 +57,30 @@ | ||
| 58 | 57 | public void should_use_same_default_timestamp_for_all_executions() { |
| 59 | 58 | Metrics.Errors errors = cluster().getMetrics().getErrorMetrics(); |
| 60 | 59 | |
| 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 | + } | |
| 67 | 80 | } |
| 68 | - session().execute(batch); | |
| 69 | 81 | |
| 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 | + } | |
| 72 | 85 | } |
| 73 | 86 | } |
modified driver-core/src/test/java/com/datastax/driver/core/SpeculativeExecutionTest.java +1 −0
| @@ -123,6 +123,7 @@ | ||
| 123 | 123 | ResultSet rs = session.execute(statement); |
| 124 | 124 | Row row = rs.one(); |
| 125 | 125 | |
| 126 | + assertThat(row).isNotNull(); | |
| 126 | 127 | assertThat(row.getString("result")).isEqualTo("result1"); |
| 127 | 128 | assertThat(errors.getSpeculativeExecutions().getCount()).isEqualTo(execStartCount); |
| 128 | 129 | assertThat(errors.getRetriesOnReadTimeout().getCount()).isEqualTo(retriesStartCount + 1); |
modified manual/ssl/README.md +1 −1
| @@ -154,7 +154,7 @@ | ||
| 154 | 154 | |
| 155 | 155 | There are known runtime incompatibilities between newer versions of |
| 156 | 156 | 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. | |
| 158 | 158 | |
| 159 | 159 | Using netty-tcnative requires JDK 1.7 or above and requires the presence of |
| 160 | 160 | OpenSSL on the system. It will not fall back to the JDK implementation. |
modified pom.xml +1 −1
| @@ -66,7 +66,7 @@ | ||
| 66 | 66 | <assertj.version>1.7.0</assertj.version> |
| 67 | 67 | <mockito.version>1.10.8</mockito.version> |
| 68 | 68 | <commons-exec.version>1.3</commons-exec.version> |
| 69 | - <scassandra.version>1.0.3</scassandra.version> | |
| 69 | + <scassandra.version>1.0.9</scassandra.version> | |
| 70 | 70 | <main.basedir>${project.basedir}</main.basedir> |
| 71 | 71 | <ipprefix>127.0.1.</ipprefix> |
| 72 | 72 | <test.groups>unit</test.groups> |