Apache9 commented on code in PR #7855:
URL: https://github.com/apache/hbase/pull/7855#discussion_r3425127318


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/metrics/TestMetricsTableRequests.java:
##########
@@ -119,15 +113,33 @@ public void testTableQueryMeterSwitch() {
         MetricsTableRequests.ENABLE_TABLE_QUERY_METER_METRICS_KEY_DEFAULT);
     assertTrue(enableTableQueryMeter);
     requests = new MetricsTableRequests(tn1, conf);
-    assertTrue(requests instanceof MetricsTableRequests,
-      "'requests' is actually " + requests.getClass());
 
     info = requests.getMetricRegistryInfo();
     registry = MetricRegistries.global().get(info);
     assertTrue(registry.isPresent());
     requests.updateTableReadQueryMeter(500L);
     read = registry.get().get("tableReadQueryPerSecond");
     assertTrue(read.isPresent());
-    assertEquals(((DropwizardMeter) read.get()).getCount(), 500);
+    assertEquals(500, ((DropwizardMeter) read.get()).getCount());
+  }
+
+  @Test
+  public void testSameRegistryInstanceRefCounting(TestInfo testInfo) {
+    TableName tn1 = 
TableName.valueOf(testInfo.getTestMethod().get().getName());
+
+    // create registry twice, should return same instance due to ref-counting
+    MetricsTableRequests requests1 = new MetricsTableRequests(tn1, new 
Configuration());
+    MetricsTableRequests requests2 = new MetricsTableRequests(tn1, new 
Configuration());
+
+    MetricRegistry metricRegistry1 = requests1.getMetricRegistry();
+    MetricRegistry metricRegistry2 = requests2.getMetricRegistry();
+    // verify ref-counting returns same instance
+    assertEquals(metricRegistry1, metricRegistry2);

Review Comment:
   Should use assertSame?



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

Reply via email to