Search in sources :

Example 1 with LogResult

use of org.apache.cassandra.distributed.api.LogResult in project cassandra by apache.

the class FailingResponseDoesNotLogTest method dispatcherErrorDoesNotLock.

@Test
public void dispatcherErrorDoesNotLock() throws IOException {
    System.setProperty("cassandra.custom_query_handler_class", AlwaysRejectErrorQueryHandler.class.getName());
    try (Cluster cluster = Cluster.build(1).withConfig(c -> c.with(Feature.NATIVE_PROTOCOL, Feature.GOSSIP).set("client_error_reporting_exclusions", ImmutableMap.of("subnets", Collections.singletonList("127.0.0.1")))).start()) {
        try (SimpleClient client = SimpleClient.builder("127.0.0.1", 9042).build().connect(false)) {
            client.execute("SELECT * FROM system.peers", ConsistencyLevel.ONE);
            Assert.fail("Query should have failed");
        } catch (Exception e) {
        // ignore; expected
        }
        // logs happen before client response; so grep is enough
        LogAction logs = cluster.get(1).logs();
        LogResult<List<String>> matches = logs.grep("address contained in client_error_reporting_exclusions");
        Assertions.assertThat(matches.getResult()).hasSize(1);
        matches = logs.grep("Unexpected exception during request");
        Assertions.assertThat(matches.getResult()).isEmpty();
    } finally {
        System.clearProperty("cassandra.custom_query_handler_class");
    }
}
Also used : BeforeClass(org.junit.BeforeClass) LogAction(org.apache.cassandra.distributed.api.LogAction) BatchStatement(org.apache.cassandra.cql3.statements.BatchStatement) CQLStatement(org.apache.cassandra.cql3.CQLStatement) QueryHandler(org.apache.cassandra.cql3.QueryHandler) ByteBuffer(java.nio.ByteBuffer) RequestExecutionException(org.apache.cassandra.exceptions.RequestExecutionException) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) DatabaseDescriptor(org.apache.cassandra.config.DatabaseDescriptor) BatchQueryOptions(org.apache.cassandra.cql3.BatchQueryOptions) RequestValidationException(org.apache.cassandra.exceptions.RequestValidationException) ResultMessage(org.apache.cassandra.transport.messages.ResultMessage) ConsistencyLevel(org.apache.cassandra.db.ConsistencyLevel) Feature(org.apache.cassandra.distributed.api.Feature) ImmutableMap(com.google.common.collect.ImmutableMap) QueryState(org.apache.cassandra.service.QueryState) MD5Digest(org.apache.cassandra.utils.MD5Digest) ClientState(org.apache.cassandra.service.ClientState) IOException(java.io.IOException) Test(org.junit.Test) List(java.util.List) SimpleClient(org.apache.cassandra.transport.SimpleClient) Cluster(org.apache.cassandra.distributed.Cluster) Assert(org.junit.Assert) Collections(java.util.Collections) QueryOptions(org.apache.cassandra.cql3.QueryOptions) LogResult(org.apache.cassandra.distributed.api.LogResult) LogAction(org.apache.cassandra.distributed.api.LogAction) Cluster(org.apache.cassandra.distributed.Cluster) SimpleClient(org.apache.cassandra.transport.SimpleClient) List(java.util.List) RequestExecutionException(org.apache.cassandra.exceptions.RequestExecutionException) RequestValidationException(org.apache.cassandra.exceptions.RequestValidationException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)1 BatchQueryOptions (org.apache.cassandra.cql3.BatchQueryOptions)1 CQLStatement (org.apache.cassandra.cql3.CQLStatement)1 QueryHandler (org.apache.cassandra.cql3.QueryHandler)1 QueryOptions (org.apache.cassandra.cql3.QueryOptions)1 BatchStatement (org.apache.cassandra.cql3.statements.BatchStatement)1 ConsistencyLevel (org.apache.cassandra.db.ConsistencyLevel)1 Cluster (org.apache.cassandra.distributed.Cluster)1 Feature (org.apache.cassandra.distributed.api.Feature)1 LogAction (org.apache.cassandra.distributed.api.LogAction)1 LogResult (org.apache.cassandra.distributed.api.LogResult)1 RequestExecutionException (org.apache.cassandra.exceptions.RequestExecutionException)1 RequestValidationException (org.apache.cassandra.exceptions.RequestValidationException)1 ClientState (org.apache.cassandra.service.ClientState)1