You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2020/10/19 16:02:43 UTC

[GitHub] [cassandra] blerer commented on a change in pull request #769: Improve ClientRequestSizeMetrics test

blerer commented on a change in pull request #769:
URL: https://github.com/apache/cassandra/pull/769#discussion_r507871764



##########
File path: test/unit/org/apache/cassandra/metrics/ClientRequestSizeMetricsTest.java
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.metrics;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Histogram;
+import com.codahale.metrics.Snapshot;
+
+import org.apache.cassandra.cql3.CQLTester;
+import org.apache.cassandra.metrics.ClearableHistogram;
+import org.apache.cassandra.metrics.ClientRequestSizeMetrics;
+import org.apache.cassandra.metrics.DecayingEstimatedHistogramReservoir.EstimatedHistogramReservoirSnapshot;
+import org.apache.cassandra.metrics.DecayingEstimatedHistogramReservoir.Range;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Ensures we properly account for metrics tracked in the native protocol
+ */
+public class ClientRequestSizeMetricsTest extends CQLTester
+{
+    @BeforeClass
+    public static void setUp()
+    {
+        requireNetwork();
+    }
+
+    @Test
+    public void testReadAndWriteMetricsAreRecordedDuringNativeRequests() throws Throwable
+    {
+        // We want to ignore all the messages sent by the driver upon connection as well as
+        // the event sent upon schema updates
+        clearMetrics();
+
+        executeNet("SELECT * from system.peers");
+        assertThat(ClientRequestSizeMetrics.totalBytesRead.getCount()).isGreaterThan(0);
+        assertThat(ClientRequestSizeMetrics.totalBytesWritten.getCount()).isGreaterThan(0);
+
+        // The request fit in one single frame so we know the new number of received frames
+        assertEquals(1, ClientRequestSizeMetrics.bytesReceivedPerFrame.getCount());
+
+        long requestLength = ClientRequestSizeMetrics.totalBytesRead.getCount();

Review comment:
       Done :-)




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org