/** * Ensures that when handling a read timeout with {@link DowngradingConsistencyRetryPolicy} that a * retry is reattempted if data was not retrieved, but enough replicas were alive to handle the * request. * * @test_category retry_policy */ @Test(groups = "short") public void should_retry_once_if_not_data_was_retrieved_and_enough_replicas_alive() { simulateError(1, read_request_timeout, new ReadTimeoutConfig(1, 1, false)); try { query(); fail("expected an ReadTimeoutException"); } catch (ReadTimeoutException e) { /*expected*/ } assertOnReadTimeoutWasCalled(2); assertThat(errors.getRetries().getCount()).isEqualTo(1); assertThat(errors.getReadTimeouts().getCount()).isEqualTo(2); assertThat(errors.getRetriesOnReadTimeout().getCount()).isEqualTo(1); assertQueried(1, 2); assertQueried(2, 0); assertQueried(3, 0); }
/** * Ensures that when handling a read timeout with {@link DowngradingConsistencyRetryPolicy} that a * retry is reattempted with a {@link ConsistencyLevel} that matches min(received * acknowledgements, THREE) and is only retried once. * * @param received The number of received acknowledgements to use in read timeout. * @param expectedDowngradedCL The consistency level that is expected to be used on the retry. * @test_category retry_policy */ @Test(groups = "short", dataProvider = "consistencyLevels") public void should_retry_once_on_same_host_with_reduced_consistency_level_on_read_timeout( int received, ConsistencyLevel expectedDowngradedCL) { simulateError(1, read_request_timeout, new ReadTimeoutConfig(received, received + 1, true)); try { query(); fail("expected an ReadTimeoutException"); } catch (ReadTimeoutException e) { assertThat(e.getConsistencyLevel()).isEqualTo(expectedDowngradedCL); } assertOnReadTimeoutWasCalled(2); assertThat(errors.getRetries().getCount()).isEqualTo(1); assertThat(errors.getReadTimeouts().getCount()).isEqualTo(2); assertThat(errors.getRetriesOnReadTimeout().getCount()).isEqualTo(1); assertQueried(1, 2); assertQueried(2, 0); assertQueried(3, 0); }
/** * Ensures that when handling a read timeout with {@link DowngradingConsistencyRetryPolicy} that a * retry is reattempted with {@link ConsistencyLevel#ONE} if the consistency level on the * statement executed is {@link ConsistencyLevel#EACH_QUORUM}, even if the number of known alive * replicas was 0. * * @jira_ticket JAVA-1005 * @test_category retry_policy */ @Test(groups = "short") public void should_retry_once_on_same_host_from_each_quorum_to_one() { simulateError(1, read_request_timeout, new ReadTimeoutConfig(0, 3, false)); try { queryWithCL(ConsistencyLevel.EACH_QUORUM); } catch (ReadTimeoutException e) { assertThat(e.getConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE); } assertOnReadTimeoutWasCalled(2); assertThat(errors.getRetries().getCount()).isEqualTo(1); assertThat(errors.getReadTimeouts().getCount()).isEqualTo(2); assertThat(errors.getRetriesOnReadTimeout().getCount()).isEqualTo(1); assertQueried(1, 2); assertQueried(2, 0); assertQueried(3, 0); }
/** * Ensures that when handling a read timeout with {@link DowngradingConsistencyRetryPolicy} that a * retry is reattempted with {@link ConsistencyLevel#ONE} if the consistency level on the * statement executed is {@link ConsistencyLevel#EACH_QUORUM}, even if the number of known alive * replicas was 0. * * @jira_ticket JAVA-1005 * @test_category retry_policy */ @Test(groups = "short") public void should_retry_once_on_same_host_from_each_quorum_to_one() { simulateError(1, read_request_timeout, new ReadTimeoutConfig(0, 3, false)); try { queryWithCL(ConsistencyLevel.EACH_QUORUM); } catch (ReadTimeoutException e) { assertThat(e.getConsistencyLevel()).isEqualTo(ConsistencyLevel.ONE); } assertOnReadTimeoutWasCalled(2); assertThat(errors.getRetries().getCount()).isEqualTo(1); assertThat(errors.getReadTimeouts().getCount()).isEqualTo(2); assertThat(errors.getRetriesOnReadTimeout().getCount()).isEqualTo(1); assertQueried(1, 2); assertQueried(2, 0); assertQueried(3, 0); }
/** * Ensures that when handling a read timeout with {@link DowngradingConsistencyRetryPolicy} that a * retry is reattempted if data was not retrieved, but enough replicas were alive to handle the * request. * * @test_category retry_policy */ @Test(groups = "short") public void should_retry_once_if_not_data_was_retrieved_and_enough_replicas_alive() { simulateError(1, read_request_timeout, new ReadTimeoutConfig(1, 1, false)); try { query(); fail("expected an ReadTimeoutException"); } catch (ReadTimeoutException e) { /*expected*/ } assertOnReadTimeoutWasCalled(2); assertThat(errors.getRetries().getCount()).isEqualTo(1); assertThat(errors.getReadTimeouts().getCount()).isEqualTo(2); assertThat(errors.getRetriesOnReadTimeout().getCount()).isEqualTo(1); assertQueried(1, 2); assertQueried(2, 0); assertQueried(3, 0); }
/** * Ensures that when handling a read timeout with {@link DowngradingConsistencyRetryPolicy} that a * retry is reattempted with a {@link ConsistencyLevel} that matches min(received * acknowledgements, THREE) and is only retried once. * * @param received The number of received acknowledgements to use in read timeout. * @param expectedDowngradedCL The consistency level that is expected to be used on the retry. * @test_category retry_policy */ @Test(groups = "short", dataProvider = "consistencyLevels") public void should_retry_once_on_same_host_with_reduced_consistency_level_on_read_timeout( int received, ConsistencyLevel expectedDowngradedCL) { simulateError(1, read_request_timeout, new ReadTimeoutConfig(received, received + 1, true)); try { query(); fail("expected an ReadTimeoutException"); } catch (ReadTimeoutException e) { assertThat(e.getConsistencyLevel()).isEqualTo(expectedDowngradedCL); } assertOnReadTimeoutWasCalled(2); assertThat(errors.getRetries().getCount()).isEqualTo(1); assertThat(errors.getReadTimeouts().getCount()).isEqualTo(2); assertThat(errors.getRetriesOnReadTimeout().getCount()).isEqualTo(1); assertQueried(1, 2); assertQueried(2, 0); assertQueried(3, 0); }