kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | d8dc678d72c1c4da70180c96fe6d8e93b93d491f395f471f160ae5e110eaddba |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2016-03-15 10:56 -05:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2016-04-01 17:57 +02:00 |
| Parents | 1316e514ed91 |
13 files changed
modified driver-core/src/test/java/com/datastax/driver/core/QueryLoggerErrorsTest.java +3 −3
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | import com.datastax.driver.core.exceptions.*; |
| 19 | 19 | import org.apache.log4j.Level; |
| 20 | 20 | import org.apache.log4j.Logger; |
| 21 | -import org.scassandra.http.client.PrimingRequest; | |
| 21 | +import org.scassandra.http.client.Result; | |
| 22 | 22 | import org.testng.annotations.AfterMethod; |
| 23 | 23 | import org.testng.annotations.BeforeMethod; |
| 24 | 24 | import org.testng.annotations.DataProvider; |
| @@ -29,9 +29,9 @@ | ||
| 29 | 29 | import static org.apache.log4j.Level.INFO; |
| 30 | 30 | import static org.assertj.core.api.Assertions.assertThat; |
| 31 | 31 | import static org.assertj.core.api.Assertions.fail; |
| 32 | -import static org.scassandra.http.client.PrimingRequest.Result.*; | |
| 33 | 32 | import static org.scassandra.http.client.PrimingRequest.queryBuilder; |
| 34 | 33 | import static org.scassandra.http.client.PrimingRequest.then; |
| 34 | +import static org.scassandra.http.client.Result.*; | |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Tests for {@link QueryLogger} using Scassandra. |
| @@ -158,7 +158,7 @@ | ||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | @Test(groups = "short", dataProvider = "errors") |
| 161 | - public void should_log_exception_from_the_given_result(PrimingRequest.Result result, Class<? extends Exception> expectedException, Class<? extends Exception> loggedException) throws Exception { | |
| 161 | + public void should_log_exception_from_the_given_result(Result result, Class<? extends Exception> expectedException, Class<? extends Exception> loggedException) throws Exception { | |
| 162 | 162 | // given |
| 163 | 163 | error.setLevel(DEBUG); |
| 164 | 164 | queryLogger = builder().build(); |
modified driver-core/src/test/java/com/datastax/driver/core/SpeculativeExecutionTest.java +5 −3
| @@ -21,7 +21,9 @@ | ||
| 21 | 21 | import com.datastax.driver.core.policies.SpeculativeExecutionPolicy; |
| 22 | 22 | import com.google.common.collect.ImmutableList; |
| 23 | 23 | import com.google.common.collect.ImmutableMap; |
| 24 | +import org.scassandra.http.client.Consistency; | |
| 24 | 25 | import org.scassandra.http.client.PrimingRequest; |
| 26 | +import org.scassandra.http.client.Result; | |
| 25 | 27 | import org.testng.annotations.AfterMethod; |
| 26 | 28 | import org.testng.annotations.BeforeMethod; |
| 27 | 29 | import org.testng.annotations.Test; |
| @@ -101,14 +103,14 @@ | ||
| 101 | 103 | // will retry once on this node: |
| 102 | 104 | scassandras.node(1).primingClient().prime(PrimingRequest.queryBuilder() |
| 103 | 105 | .withQuery("mock query") |
| 104 | - .withConsistency(PrimingRequest.Consistency.TWO) | |
| 105 | - .withResult(PrimingRequest.Result.read_request_timeout) | |
| 106 | + .withConsistency(Consistency.TWO) | |
| 107 | + .withResult(Result.read_request_timeout) | |
| 106 | 108 | .build() |
| 107 | 109 | ); |
| 108 | 110 | |
| 109 | 111 | scassandras.node(1).primingClient().prime(PrimingRequest.queryBuilder() |
| 110 | 112 | .withQuery("mock query") |
| 111 | - .withConsistency(PrimingRequest.Consistency.ONE) | |
| 113 | + .withConsistency(Consistency.ONE) | |
| 112 | 114 | .withRows(row("result", "result1")) |
| 113 | 115 | .build() |
| 114 | 116 | ); |
modified driver-core/src/test/java/com/datastax/driver/core/exceptions/ExceptionsScassandraTest.java +3 −2
| @@ -21,6 +21,7 @@ | ||
| 21 | 21 | import com.google.common.collect.ImmutableMap; |
| 22 | 22 | import org.scassandra.Scassandra; |
| 23 | 23 | import org.scassandra.http.client.PrimingRequest; |
| 24 | +import org.scassandra.http.client.Result; | |
| 24 | 25 | import org.testng.annotations.*; |
| 25 | 26 | |
| 26 | 27 | import java.util.List; |
| @@ -29,7 +30,7 @@ | ||
| 29 | 30 | import static com.datastax.driver.core.ConsistencyLevel.LOCAL_ONE; |
| 30 | 31 | import static org.assertj.core.api.Assertions.assertThat; |
| 31 | 32 | import static org.assertj.core.api.Assertions.fail; |
| 32 | -import static org.scassandra.http.client.PrimingRequest.Result.*; | |
| 33 | +import static org.scassandra.http.client.Result.*; | |
| 33 | 34 | |
| 34 | 35 | public class ExceptionsScassandraTest { |
| 35 | 36 | |
| @@ -111,7 +112,7 @@ | ||
| 111 | 112 | } |
| 112 | 113 | } |
| 113 | 114 | |
| 114 | - protected void simulateError(int hostNumber, PrimingRequest.Result result) { | |
| 115 | + protected void simulateError(int hostNumber, Result result) { | |
| 115 | 116 | scassandras.node(hostNumber).primingClient().prime(PrimingRequest.queryBuilder() |
| 116 | 117 | .withQuery("mock query") |
| 117 | 118 | .withResult(result) |
modified driver-core/src/test/java/com/datastax/driver/core/policies/AbstractRetryPolicyIntegrationTest.java +5 −4
| @@ -27,6 +27,7 @@ | ||
| 27 | 27 | import org.scassandra.http.client.Config; |
| 28 | 28 | import org.scassandra.http.client.PrimingRequest; |
| 29 | 29 | import org.scassandra.http.client.PrimingRequest.PrimingRequestBuilder; |
| 30 | +import org.scassandra.http.client.Result; | |
| 30 | 31 | import org.testng.annotations.AfterMethod; |
| 31 | 32 | import org.testng.annotations.BeforeMethod; |
| 32 | 33 | import org.testng.annotations.DataProvider; |
| @@ -38,8 +39,8 @@ | ||
| 38 | 39 | import static org.assertj.core.api.Assertions.assertThat; |
| 39 | 40 | import static org.mockito.Matchers.*; |
| 40 | 41 | import static org.mockito.Mockito.times; |
| 41 | -import static org.scassandra.http.client.PrimingRequest.Result.overloaded; | |
| 42 | -import static org.scassandra.http.client.PrimingRequest.Result.server_error; | |
| 42 | +import static org.scassandra.http.client.Result.overloaded; | |
| 43 | +import static org.scassandra.http.client.Result.server_error; | |
| 43 | 44 | |
| 44 | 45 | /** |
| 45 | 46 | * Base class for retry policy integration tests. |
| @@ -105,11 +106,11 @@ | ||
| 105 | 106 | } |
| 106 | 107 | } |
| 107 | 108 | |
| 108 | - protected void simulateError(int hostNumber, PrimingRequest.Result result) { | |
| 109 | + protected void simulateError(int hostNumber, Result result) { | |
| 109 | 110 | simulateError(hostNumber, result, null); |
| 110 | 111 | } |
| 111 | 112 | |
| 112 | - protected void simulateError(int hostNumber, PrimingRequest.Result result, Config config) { | |
| 113 | + protected void simulateError(int hostNumber, Result result, Config config) { | |
| 113 | 114 | PrimingRequestBuilder builder = PrimingRequest.queryBuilder() |
| 114 | 115 | .withQuery("mock query") |
| 115 | 116 | .withResult(result); |
deleted driver-core/src/test/java/com/datastax/driver/core/policies/CASRetryPolicyIntegrationTest.java +0 −108
| @@ -1,108 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | - * | |
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | - * you may not use this file except in compliance with the License. | |
| 6 | - * You may obtain a copy of the License at | |
| 7 | - * | |
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | - * | |
| 10 | - * Unless required by applicable law or agreed to in writing, software | |
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | - * See the License for the specific language governing permissions and | |
| 14 | - * limitations under the License. | |
| 15 | - */ | |
| 16 | -package com.datastax.driver.core.policies; | |
| 17 | - | |
| 18 | -import com.datastax.driver.core.*; | |
| 19 | -import com.datastax.driver.core.exceptions.NoHostAvailableException; | |
| 20 | -import com.datastax.driver.core.exceptions.UnavailableException; | |
| 21 | -import com.datastax.driver.core.utils.CassandraVersion; | |
| 22 | -import org.testng.annotations.Test; | |
| 23 | - | |
| 24 | -import static com.datastax.driver.core.Assertions.assertThat; | |
| 25 | -import static com.datastax.driver.core.ConsistencyLevel.ANY; | |
| 26 | -import static com.datastax.driver.core.ConsistencyLevel.SERIAL; | |
| 27 | -import static com.datastax.driver.core.CreateCCM.TestMode.PER_METHOD; | |
| 28 | -import static org.assertj.core.api.Assertions.fail; | |
| 29 | -import static org.mockito.Matchers.eq; | |
| 30 | -import static org.mockito.Mockito.*; | |
| 31 | - | |
| 32 | -/** | |
| 33 | - * Tests for retry policies in combination with lightweight transactions. | |
| 34 | - * <p/> | |
| 35 | - * Note: we can't extend {@link AbstractRetryPolicyIntegrationTest} here, because we are | |
| 36 | - * testing LWT statements and Scassandra doesn't support priming consistency levels yet. | |
| 37 | - * | |
| 38 | - * @jira_ticket JAVA-764 | |
| 39 | - */ | |
| 40 | -@CCMConfig( | |
| 41 | - numberOfNodes = 3, | |
| 42 | - dirtiesContext = true, | |
| 43 | - createCluster = false | |
| 44 | -) | |
| 45 | -@CreateCCM(PER_METHOD) | |
| 46 | -@CassandraVersion(major = 2.0) | |
| 47 | -public class CASRetryPolicyIntegrationTest extends CCMTestsSupport { | |
| 48 | - | |
| 49 | - @Test(groups = "long") | |
| 50 | - public void should_rethrow_on_unavailable_with_default_policy_if_CAS() { | |
| 51 | - testLWT(spy(DefaultRetryPolicy.INSTANCE)); | |
| 52 | - } | |
| 53 | - | |
| 54 | - @Test(groups = "long") | |
| 55 | - public void should_rethrow_on_unavailable_with_downgrading_policy_if_CAS() { | |
| 56 | - testLWT(spy(DowngradingConsistencyRetryPolicy.INSTANCE)); | |
| 57 | - } | |
| 58 | - | |
| 59 | - private void testLWT(RetryPolicy retryPolicy) { | |
| 60 | - | |
| 61 | - Cluster cluster = register(Cluster.builder() | |
| 62 | - .addContactPoints(getContactPoints().get(0)) | |
| 63 | - .withPort(ccm().getBinaryPort()) | |
| 64 | - .withSocketOptions(new SocketOptions().setReadTimeoutMillis(120000)) | |
| 65 | - .withRetryPolicy(retryPolicy) | |
| 66 | - .build()); | |
| 67 | - | |
| 68 | - Session session = cluster.connect(); | |
| 69 | - | |
| 70 | - String ks = TestUtils.generateIdentifier("ks_"); | |
| 71 | - session.execute(String.format("CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}", ks)); | |
| 72 | - useKeyspace(session, ks); | |
| 73 | - session.execute("CREATE TABLE IF NOT EXISTS foo (k int primary key, c int)"); | |
| 74 | - | |
| 75 | - session.execute("INSERT INTO foo(k, c) VALUES (0, 0)"); | |
| 76 | - | |
| 77 | - ccm().stop(1); | |
| 78 | - ccm().waitForDown(1); | |
| 79 | - TestUtils.waitForDown(ccm().addressOfNode(1).getHostName(), cluster); | |
| 80 | - | |
| 81 | - ccm().stop(2); | |
| 82 | - ccm().waitForDown(2); | |
| 83 | - TestUtils.waitForDown(ccm().addressOfNode(2).getHostName(), cluster); | |
| 84 | - | |
| 85 | - Statement s = new SimpleStatement("UPDATE foo SET c = 1 WHERE k = 0 IF c = 0") | |
| 86 | - // the following will cause the paxos phase to fail | |
| 87 | - // given the number of available replicas (1) | |
| 88 | - .setConsistencyLevel(ANY) | |
| 89 | - .setSerialConsistencyLevel(SERIAL); | |
| 90 | - | |
| 91 | - try { | |
| 92 | - session.execute(s); | |
| 93 | - // Expect a NHAE since a retry should have been attempted on unavailable error with CL SERIAL. | |
| 94 | - fail("Expected NoHostAvailableException"); | |
| 95 | - } catch (NoHostAvailableException e) { | |
| 96 | - Throwable error = e.getErrors().values().iterator().next(); | |
| 97 | - assertThat(error).isInstanceOf(UnavailableException.class); | |
| 98 | - UnavailableException unavailable = (UnavailableException) error; | |
| 99 | - assertThat(unavailable.getConsistencyLevel()).isEqualTo(SERIAL); | |
| 100 | - assertThat(unavailable.getRequiredReplicas()).isEqualTo(2); | |
| 101 | - assertThat(unavailable.getAliveReplicas()).isEqualTo(1); | |
| 102 | - } | |
| 103 | - | |
| 104 | - verify(retryPolicy, times(1)).onUnavailable( | |
| 105 | - eq(s), eq(SERIAL), eq(2), eq(1), eq(0)); | |
| 106 | - } | |
| 107 | - | |
| 108 | -} |
modified driver-core/src/test/java/com/datastax/driver/core/policies/CustomRetryPolicyIntegrationTest.java +4 −4
| @@ -23,13 +23,13 @@ | ||
| 23 | 23 | import org.scassandra.http.client.ClosedConnectionConfig; |
| 24 | 24 | import org.scassandra.http.client.ClosedConnectionConfig.CloseType; |
| 25 | 25 | import org.scassandra.http.client.PrimingRequest; |
| 26 | +import org.scassandra.http.client.Result; | |
| 26 | 27 | import org.testng.annotations.Test; |
| 27 | 28 | |
| 28 | 29 | import static com.datastax.driver.core.Assertions.assertThat; |
| 29 | 30 | import static org.assertj.core.api.Fail.fail; |
| 30 | -import static org.scassandra.http.client.PrimingRequest.Result.read_request_timeout; | |
| 31 | -import static org.scassandra.http.client.PrimingRequest.Result.unavailable; | |
| 32 | 31 | import static org.scassandra.http.client.PrimingRequest.then; |
| 32 | +import static org.scassandra.http.client.Result.*; | |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Integration test with a custom implementation, to test retry and ignore decisions. |
| @@ -105,7 +105,7 @@ | ||
| 105 | 105 | |
| 106 | 106 | |
| 107 | 107 | @Test(groups = "short", dataProvider = "serverSideErrors") |
| 108 | - public void should_rethrow_on_server_side_error(PrimingRequest.Result error, Class<? extends DriverException> exception) { | |
| 108 | + public void should_rethrow_on_server_side_error(Result error, Class<? extends DriverException> exception) { | |
| 109 | 109 | simulateError(1, error); |
| 110 | 110 | try { |
| 111 | 111 | query(); |
| @@ -125,7 +125,7 @@ | ||
| 125 | 125 | |
| 126 | 126 | @Test(groups = "short", dataProvider = "connectionErrors") |
| 127 | 127 | public void should_rethrow_on_connection_error(CloseType closeType) { |
| 128 | - simulateError(1, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 128 | + simulateError(1, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 129 | 129 | try { |
| 130 | 130 | query(); |
| 131 | 131 | fail("expected a TransportException"); |
modified driver-core/src/test/java/com/datastax/driver/core/policies/DefaultRetryPolicyIntegrationTest.java +30 −5
| @@ -21,14 +21,18 @@ | ||
| 21 | 21 | import org.scassandra.Scassandra; |
| 22 | 22 | import org.scassandra.http.client.ClosedConnectionConfig; |
| 23 | 23 | import org.scassandra.http.client.PrimingRequest; |
| 24 | +import org.scassandra.http.client.Result; | |
| 25 | +import org.scassandra.http.client.UnavailableConfig; | |
| 26 | +import org.testng.Assert; | |
| 24 | 27 | import org.testng.annotations.Test; |
| 25 | 28 | |
| 26 | 29 | import java.util.Collections; |
| 27 | 30 | |
| 28 | 31 | import static org.assertj.core.api.Assertions.assertThat; |
| 29 | 32 | import static org.assertj.core.api.Assertions.fail; |
| 30 | -import static org.scassandra.http.client.PrimingRequest.Result.*; | |
| 33 | +import static org.scassandra.http.client.Consistency.LOCAL_SERIAL; | |
| 31 | 34 | import static org.scassandra.http.client.PrimingRequest.then; |
| 35 | +import static org.scassandra.http.client.Result.*; | |
| 32 | 36 | |
| 33 | 37 | public class DefaultRetryPolicyIntegrationTest extends AbstractRetryPolicyIntegrationTest { |
| 34 | 38 | public DefaultRetryPolicyIntegrationTest() { |
| @@ -202,7 +206,7 @@ | ||
| 202 | 206 | |
| 203 | 207 | |
| 204 | 208 | @Test(groups = "short", dataProvider = "serverSideErrors") |
| 205 | - public void should_try_next_host_on_server_side_error(PrimingRequest.Result error, Class<? extends DriverException> exception) { | |
| 209 | + public void should_try_next_host_on_server_side_error(Result error, Class<? extends DriverException> exception) { | |
| 206 | 210 | simulateError(1, error); |
| 207 | 211 | simulateError(2, error); |
| 208 | 212 | simulateError(3, error); |
| @@ -228,9 +232,9 @@ | ||
| 228 | 232 | |
| 229 | 233 | @Test(groups = "short", dataProvider = "connectionErrors") |
| 230 | 234 | public void should_try_next_host_on_connection_error(ClosedConnectionConfig.CloseType closeType) { |
| 231 | - simulateError(1, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 232 | - simulateError(2, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 233 | - simulateError(3, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 235 | + simulateError(1, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 236 | + simulateError(2, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 237 | + simulateError(3, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 234 | 238 | try { |
| 235 | 239 | query(); |
| 236 | 240 | Fail.fail("expected a NoHostAvailableException"); |
| @@ -250,4 +254,25 @@ | ||
| 250 | 254 | assertQueried(2, 1); |
| 251 | 255 | assertQueried(3, 1); |
| 252 | 256 | } |
| 257 | + | |
| 258 | + @Test(groups = "short") | |
| 259 | + public void should_rethrow_on_unavailable_if_CAS() { | |
| 260 | + simulateError(1, unavailable, new UnavailableConfig(1, 0, LOCAL_SERIAL)); | |
| 261 | + simulateError(2, unavailable, new UnavailableConfig(1, 0, LOCAL_SERIAL)); | |
| 262 | + | |
| 263 | + try { | |
| 264 | + query(); | |
| 265 | + Assert.fail("expected an UnavailableException"); | |
| 266 | + } catch (UnavailableException e) { | |
| 267 | + assertThat(e.getConsistencyLevel()).isEqualTo(ConsistencyLevel.LOCAL_SERIAL); | |
| 268 | + } | |
| 269 | + | |
| 270 | + assertOnUnavailableWasCalled(2); | |
| 271 | + assertThat(errors.getRetries().getCount()).isEqualTo(1); | |
| 272 | + assertThat(errors.getUnavailables().getCount()).isEqualTo(2); | |
| 273 | + assertThat(errors.getRetriesOnUnavailable().getCount()).isEqualTo(1); | |
| 274 | + assertQueried(1, 1); | |
| 275 | + assertQueried(2, 1); | |
| 276 | + assertQueried(3, 0); | |
| 277 | + } | |
| 253 | 278 | } |
modified driver-core/src/test/java/com/datastax/driver/core/policies/DowngradingConsistencyRetryPolicyIntegrationTest.java +27 −5
| @@ -26,8 +26,9 @@ | ||
| 26 | 26 | import org.testng.annotations.Test; |
| 27 | 27 | |
| 28 | 28 | import static org.assertj.core.api.Assertions.assertThat; |
| 29 | -import static org.scassandra.http.client.PrimingRequest.Result.*; | |
| 29 | +import static org.scassandra.http.client.Consistency.SERIAL; | |
| 30 | 30 | import static org.scassandra.http.client.PrimingRequest.then; |
| 31 | +import static org.scassandra.http.client.Result.*; | |
| 31 | 32 | import static org.scassandra.http.client.WriteTypePrime.UNLOGGED_BATCH; |
| 32 | 33 | import static org.testng.Assert.fail; |
| 33 | 34 | |
| @@ -384,7 +385,7 @@ | ||
| 384 | 385 | * @test_category retry_policy |
| 385 | 386 | */ |
| 386 | 387 | @Test(groups = "short", dataProvider = "serverSideErrors") |
| 387 | - public void should_try_next_host_on_server_side_error(PrimingRequest.Result error, Class<? extends DriverException> exception) { | |
| 388 | + public void should_try_next_host_on_server_side_error(Result error, Class<? extends DriverException> exception) { | |
| 388 | 389 | simulateError(1, error); |
| 389 | 390 | simulateError(2, error); |
| 390 | 391 | simulateError(3, error); |
| @@ -416,9 +417,9 @@ | ||
| 416 | 417 | */ |
| 417 | 418 | @Test(groups = "short", dataProvider = "connectionErrors") |
| 418 | 419 | public void should_try_next_host_on_connection_error(ClosedConnectionConfig.CloseType closeType) { |
| 419 | - simulateError(1, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 420 | - simulateError(2, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 421 | - simulateError(3, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 420 | + simulateError(1, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 421 | + simulateError(2, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 422 | + simulateError(3, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 422 | 423 | try { |
| 423 | 424 | query(); |
| 424 | 425 | Fail.fail("expected a TransportException"); |
| @@ -438,4 +439,25 @@ | ||
| 438 | 439 | assertQueried(2, 1); |
| 439 | 440 | assertQueried(3, 1); |
| 440 | 441 | } |
| 442 | + | |
| 443 | + @Test(groups = "short") | |
| 444 | + public void should_rethrow_on_unavailable_if_CAS() { | |
| 445 | + simulateError(1, unavailable, new UnavailableConfig(1, 0, SERIAL)); | |
| 446 | + simulateError(2, unavailable, new UnavailableConfig(1, 0, SERIAL)); | |
| 447 | + | |
| 448 | + try { | |
| 449 | + query(); | |
| 450 | + fail("expected an UnavailableException"); | |
| 451 | + } catch (UnavailableException e) { | |
| 452 | + assertThat(e.getConsistencyLevel()).isEqualTo(ConsistencyLevel.SERIAL); | |
| 453 | + } | |
| 454 | + | |
| 455 | + assertOnUnavailableWasCalled(2); | |
| 456 | + assertThat(errors.getRetries().getCount()).isEqualTo(1); | |
| 457 | + assertThat(errors.getUnavailables().getCount()).isEqualTo(2); | |
| 458 | + assertThat(errors.getRetriesOnUnavailable().getCount()).isEqualTo(1); | |
| 459 | + assertQueried(1, 1); | |
| 460 | + assertQueried(2, 1); | |
| 461 | + assertQueried(3, 0); | |
| 462 | + } | |
| 441 | 463 | } |
modified driver-core/src/test/java/com/datastax/driver/core/policies/FallthroughRetryPolicyIntegrationTest.java +6 −4
| @@ -19,13 +19,15 @@ | ||
| 19 | 19 | import com.datastax.driver.core.exceptions.*; |
| 20 | 20 | import org.assertj.core.api.Fail; |
| 21 | 21 | import org.scassandra.http.client.ClosedConnectionConfig; |
| 22 | +import org.scassandra.http.client.ClosedConnectionConfig.CloseType; | |
| 22 | 23 | import org.scassandra.http.client.PrimingRequest; |
| 24 | +import org.scassandra.http.client.Result; | |
| 23 | 25 | import org.testng.annotations.Test; |
| 24 | 26 | |
| 25 | 27 | import static org.assertj.core.api.Assertions.assertThat; |
| 26 | 28 | import static org.assertj.core.api.Assertions.fail; |
| 27 | -import static org.scassandra.http.client.PrimingRequest.Result.*; | |
| 28 | 29 | import static org.scassandra.http.client.PrimingRequest.then; |
| 30 | +import static org.scassandra.http.client.Result.*; | |
| 29 | 31 | |
| 30 | 32 | public class FallthroughRetryPolicyIntegrationTest extends AbstractRetryPolicyIntegrationTest { |
| 31 | 33 | public FallthroughRetryPolicyIntegrationTest() { |
| @@ -111,7 +113,7 @@ | ||
| 111 | 113 | |
| 112 | 114 | |
| 113 | 115 | @Test(groups = "short", dataProvider = "serverSideErrors") |
| 114 | - public void should_rethrow_on_server_side_error(PrimingRequest.Result error, Class<? extends DriverException> exception) { | |
| 116 | + public void should_rethrow_on_server_side_error(Result error, Class<? extends DriverException> exception) { | |
| 115 | 117 | simulateError(1, error); |
| 116 | 118 | try { |
| 117 | 119 | query(); |
| @@ -130,8 +132,8 @@ | ||
| 130 | 132 | |
| 131 | 133 | |
| 132 | 134 | @Test(groups = "short", dataProvider = "connectionErrors") |
| 133 | - public void should_rethrow_on_connection_error(ClosedConnectionConfig.CloseType closeType) { | |
| 134 | - simulateError(1, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 135 | + public void should_rethrow_on_connection_error(CloseType closeType) { | |
| 136 | + simulateError(1, Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 135 | 137 | try { |
| 136 | 138 | query(); |
| 137 | 139 | Fail.fail("expected a TransportException"); |
modified driver-core/src/test/java/com/datastax/driver/core/policies/IdempotenceAwareRetryPolicyIntegrationTest.java +11 −9
| @@ -20,13 +20,15 @@ | ||
| 20 | 20 | import org.assertj.core.api.Fail; |
| 21 | 21 | import org.scassandra.http.client.ClosedConnectionConfig; |
| 22 | 22 | import org.scassandra.http.client.PrimingRequest; |
| 23 | +import org.scassandra.http.client.Result; | |
| 23 | 24 | import org.testng.annotations.BeforeMethod; |
| 24 | 25 | import org.testng.annotations.Test; |
| 25 | 26 | |
| 26 | 27 | import static org.assertj.core.api.Assertions.assertThat; |
| 27 | 28 | import static org.assertj.core.api.Assertions.fail; |
| 28 | -import static org.scassandra.http.client.PrimingRequest.Result.write_request_timeout; | |
| 29 | 29 | import static org.scassandra.http.client.PrimingRequest.then; |
| 30 | +import static org.scassandra.http.client.Result.closed_connection; | |
| 31 | +import static org.scassandra.http.client.Result.write_request_timeout; | |
| 30 | 32 | |
| 31 | 33 | /** |
| 32 | 34 | * Integration test with an IdempotenceAwareRetryPolicy. |
| @@ -124,7 +126,7 @@ | ||
| 124 | 126 | |
| 125 | 127 | |
| 126 | 128 | @Test(groups = "short", dataProvider = "serverSideErrors") |
| 127 | - public void should_not_retry_on_server_error_if_statement_non_idempotent(PrimingRequest.Result error, Class<? extends DriverException> exception) { | |
| 129 | + public void should_not_retry_on_server_error_if_statement_non_idempotent(Result error, Class<? extends DriverException> exception) { | |
| 128 | 130 | simulateError(1, error); |
| 129 | 131 | try { |
| 130 | 132 | query(); |
| @@ -143,7 +145,7 @@ | ||
| 143 | 145 | |
| 144 | 146 | @SuppressWarnings("UnusedParameters") |
| 145 | 147 | @Test(groups = "short", dataProvider = "serverSideErrors") |
| 146 | - public void should_retry_on_server_error_if_statement_idempotent(PrimingRequest.Result error, Class<? extends DriverException> exception) { | |
| 148 | + public void should_retry_on_server_error_if_statement_idempotent(Result error, Class<? extends DriverException> exception) { | |
| 147 | 149 | simulateError(1, error); |
| 148 | 150 | simulateError(2, error); |
| 149 | 151 | simulateError(3, error); |
| @@ -169,9 +171,9 @@ | ||
| 169 | 171 | |
| 170 | 172 | @Test(groups = "short", dataProvider = "connectionErrors") |
| 171 | 173 | public void should_not_retry_on_connection_error_if_statement_non_idempotent(ClosedConnectionConfig.CloseType closeType) { |
| 172 | - simulateError(1, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 173 | - simulateError(2, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 174 | - simulateError(3, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 174 | + simulateError(1, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 175 | + simulateError(2, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 176 | + simulateError(3, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 175 | 177 | try { |
| 176 | 178 | query(); |
| 177 | 179 | Fail.fail("expected a TransportException"); |
| @@ -193,9 +195,9 @@ | ||
| 193 | 195 | |
| 194 | 196 | @Test(groups = "short", dataProvider = "connectionErrors") |
| 195 | 197 | public void should_retry_on_connection_error_if_statement_idempotent(ClosedConnectionConfig.CloseType closeType) { |
| 196 | - simulateError(1, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 197 | - simulateError(2, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 198 | - simulateError(3, PrimingRequest.Result.closed_connection, new ClosedConnectionConfig(closeType)); | |
| 198 | + simulateError(1, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 199 | + simulateError(2, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 200 | + simulateError(3, closed_connection, new ClosedConnectionConfig(closeType)); | |
| 199 | 201 | try { |
| 200 | 202 | session.execute(new SimpleStatement("mock query").setIdempotent(true)); |
| 201 | 203 | Fail.fail("expected a TransportException"); |
modified driver-core/src/test/java/com/datastax/driver/core/policies/LatencyAwarePolicyTest.java +2 −2
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | import static java.util.concurrent.TimeUnit.SECONDS; |
| 27 | 27 | import static org.assertj.core.api.Assertions.assertThat; |
| 28 | 28 | import static org.assertj.core.api.Assertions.fail; |
| 29 | -import static org.scassandra.http.client.PrimingRequest.Result.read_request_timeout; | |
| 30 | -import static org.scassandra.http.client.PrimingRequest.Result.unavailable; | |
| 31 | 29 | import static org.scassandra.http.client.PrimingRequest.queryBuilder; |
| 30 | +import static org.scassandra.http.client.Result.read_request_timeout; | |
| 31 | +import static org.scassandra.http.client.Result.unavailable; | |
| 32 | 32 | |
| 33 | 33 | public class LatencyAwarePolicyTest extends ScassandraTestBase { |
| 34 | 34 |
modified driver-core/src/test/java/com/datastax/driver/core/policies/LoggingRetryPolicyIntegrationTest.java +1 −1
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | import static com.datastax.driver.core.policies.RetryPolicy.RetryDecision.ignore; |
| 34 | 34 | import static com.datastax.driver.core.policies.RetryPolicy.RetryDecision.tryNextHost; |
| 35 | 35 | import static org.apache.log4j.Level.INFO; |
| 36 | -import static org.scassandra.http.client.PrimingRequest.Result.*; | |
| 36 | +import static org.scassandra.http.client.Result.*; | |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Integration tests with LoggingRetryPolicy. |
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>0.11.0</scassandra.version> | |
| 69 | + <scassandra.version>1.0.3</scassandra.version> | |
| 70 | 70 | <main.basedir>${project.basedir}</main.basedir> |
| 71 | 71 | <ipprefix>127.0.1.</ipprefix> |
| 72 | 72 | <test.groups>unit</test.groups> |