Skip to content

Commit

Permalink
HBASE-25598 TestFromClientSide5.testScanMetrics is flaky (apache#2977)
Browse files Browse the repository at this point in the history
Signed-off-by: Duo Zhang <[email protected]>
  • Loading branch information
ddupg authored and wchevreuil committed Feb 24, 2021
1 parent a9b644d commit 6c27dfc
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ public void testScanMetrics() throws Exception {
numRecords++;
}

LOG.info("test data has " + numRecords + " records.");
LOG.info("test data has {} records.", numRecords);

// by default, scan metrics collection is turned off
assertNull(scanner.getScanMetrics());
Expand All @@ -983,8 +983,6 @@ public void testScanMetrics() throws Exception {
try (ResultScanner scanner = ht.getScanner(scan2)) {
for (Result result : scanner.next(numRecords - 1)) {
}
scanner.close();
// closing the scanner will set the metrics.
assertNotNull(scanner.getScanMetrics());
}

Expand All @@ -999,7 +997,7 @@ public void testScanMetrics() throws Exception {
}
ScanMetrics scanMetrics = scanner.getScanMetrics();
assertEquals("Did not access all the regions in the table", numOfRegions,
scanMetrics.countOfRegions.get());
scanMetrics.countOfRegions.get());
}

// check byte counters
Expand All @@ -1008,15 +1006,14 @@ public void testScanMetrics() throws Exception {
scan2.setCaching(1);
try (ResultScanner scanner = ht.getScanner(scan2)) {
int numBytes = 0;
for (Result result : scanner.next(1)) {
for (Result result : scanner) {
for (Cell cell : result.listCells()) {
numBytes += PrivateCellUtil.estimatedSerializedSizeOf(cell);
}
}
scanner.close();
ScanMetrics scanMetrics = scanner.getScanMetrics();
assertEquals("Did not count the result bytes", numBytes,
scanMetrics.countOfBytesInResults.get());
scanMetrics.countOfBytesInResults.get());
}

// check byte counters on a small scan
Expand All @@ -1026,15 +1023,14 @@ public void testScanMetrics() throws Exception {
scan2.setSmall(true);
try (ResultScanner scanner = ht.getScanner(scan2)) {
int numBytes = 0;
for (Result result : scanner.next(1)) {
for (Result result : scanner) {
for (Cell cell : result.listCells()) {
numBytes += PrivateCellUtil.estimatedSerializedSizeOf(cell);
}
}
scanner.close();
ScanMetrics scanMetrics = scanner.getScanMetrics();
assertEquals("Did not count the result bytes", numBytes,
scanMetrics.countOfBytesInResults.get());
scanMetrics.countOfBytesInResults.get());
}

// now, test that the metrics are still collected even if you don't call close, but do
Expand Down Expand Up @@ -1064,8 +1060,10 @@ public void testScanMetrics() throws Exception {
scannerWithClose.close();
ScanMetrics scanMetricsWithClose = scannerWithClose.getScanMetrics();
assertEquals("Did not access all the regions in the table", numOfRegions,
scanMetricsWithClose.countOfRegions.get());
scanMetricsWithClose.countOfRegions.get());
}
} finally {
TEST_UTIL.deleteTable(tableName);
}
}

Expand Down

0 comments on commit 6c27dfc

Please sign in to comment.