コード例 #1
0
  private void testPrimingUnavailable(
      UnavailableConfig unavailableConfig, Consistency statementCL, Consistency expectedCL) {
    String query = "select * from people";
    PrimingRequest prime =
        PrimingRequest.queryBuilder()
            .withQuery(query)
            .withResult(unavailable)
            .withConfig(unavailableConfig)
            .build();
    primingClient.prime(prime);

    CassandraResult cassandraResult = cassandra().executeSimpleStatement(query, statementCL.name());

    CassandraResult.ResponseStatus status = cassandraResult.status();
    assertEquals(unavailable, status.getResult());
    assertEquals(expectedCL.name(), ((CassandraResult.UnavailableStatus) status).getConsistency());
    assertEquals(4, ((CassandraResult.UnavailableStatus) status).getRequiredAcknowledgements());
    assertEquals(3, ((CassandraResult.UnavailableStatus) status).getAlive());
  }
コード例 #2
0
  private void testPrimingWriteTimeout(
      WriteTimeoutConfig writeTimeoutConfig, Consistency statementCL, Consistency expectedCL) {
    String query = "select * from people";
    PrimingRequest prime =
        PrimingRequest.queryBuilder()
            .withQuery(query)
            .withResult(write_request_timeout)
            .withConfig(writeTimeoutConfig)
            .build();
    primingClient.prime(prime);

    CassandraResult cassandraResult = cassandra().executeSimpleStatement(query, statementCL.name());

    CassandraResult.ResponseStatus status = cassandraResult.status();
    assertEquals(write_request_timeout, status.getResult());
    assertEquals(expectedCL.name(), ((CassandraResult.WriteTimeoutStatus) status).getConsistency());
    assertEquals(2, ((CassandraResult.WriteTimeoutStatus) status).getReceivedAcknowledgements());
    assertEquals(3, ((CassandraResult.WriteTimeoutStatus) status).getRequiredAcknowledgements());
    assertEquals(BATCH_LOG, ((CassandraResult.WriteTimeoutStatus) status).getWriteTypePrime());
  }
コード例 #3
0
  private CassandraResult assertErrorMessageStatus(
      Result result, Config config, String expectedMsg, Result expectedResult) {
    String query = "select * from people";
    String consistency = "LOCAL_ONE";
    PrimingRequest prime =
        PrimingRequest.queryBuilder()
            .withQuery(query)
            .withResult(result)
            .withConfig(config)
            .build();
    primingClient.prime(prime);

    CassandraResult cassandraResult = cassandra().executeSimpleStatement(query, consistency);

    CassandraResult.ResponseStatus status = cassandraResult.status();
    assertEquals(expectedResult, status.getResult());
    String actualErrorMessage = ((CassandraResult.ErrorMessageStatus) status).getMessage();
    assertTrue(
        "Expected error message to contain: " + expectedMsg + " Got: " + actualErrorMessage,
        actualErrorMessage.contains(expectedMsg));
    return cassandraResult;
  }