dcapwell commented on a change in pull request #1146:
URL: https://github.com/apache/cassandra/pull/1146#discussion_r693094970



##########
File path: 
test/distributed/org/apache/cassandra/distributed/test/FailingResponseDoesNotLogTest.java
##########
@@ -0,0 +1,154 @@
+package org.apache.cassandra.distributed.test;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.cql3.BatchQueryOptions;
+import org.apache.cassandra.cql3.CQLStatement;
+import org.apache.cassandra.cql3.QueryHandler;
+import org.apache.cassandra.cql3.QueryOptions;
+import org.apache.cassandra.cql3.statements.BatchStatement;
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.Feature;
+import org.apache.cassandra.distributed.api.LogAction;
+import org.apache.cassandra.distributed.api.LogResult;
+import org.apache.cassandra.exceptions.RequestExecutionException;
+import org.apache.cassandra.exceptions.RequestValidationException;
+import org.apache.cassandra.service.ClientState;
+import org.apache.cassandra.service.QueryState;
+import org.apache.cassandra.transport.SimpleClient;
+import org.apache.cassandra.transport.messages.ResultMessage;
+import org.apache.cassandra.utils.MD5Digest;
+import org.assertj.core.api.Assertions;
+
+/**
+ * This class is rather impelemntation specific.  It is possible that changes 
made will cause this tests to fail,
+ * so updating to the latest logic is fine.
+ *
+ * This class makes sure we do not do logging/update metrics for client from a 
specific set of ip domains, so as long
+ * as we still do not log/update metrics, then the test is doing the right 
thing.
+ */
+public class FailingResponseDoesNotLogTest extends TestBaseImpl
+{
+    @BeforeClass
+    public static void beforeClassTopLevel() // need to make sure not to 
conflict with TestBaseImpl.beforeClass
+    {
+
+        DatabaseDescriptor.clientInitialization();
+    }
+
+    @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("Excluding client 
errors from");
+            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");
+        }
+    }
+
+    @Test
+    public void protocolError() throws IOException

Review comment:
       I think I was refactoring then saw that the new test was the same as 
`org.apache.cassandra.distributed.test.UnableToParseClientMessageFromBlockedSubnetTest#badMessageCausesProtocolExceptionFromExcludeList`,
 so moved the checks there... will delete.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to