Skip to content

Commit

Permalink
HBASE-27534 Addendum fix test crash (apache#5011)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbeaudreault authored Feb 7, 2023
1 parent 198a3b7 commit 1a9e465
Showing 1 changed file with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.ServerType;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
Expand All @@ -61,27 +63,42 @@ public class TestTooLargeLog {

@BeforeClass
public static void setUpBeforeClass() throws Exception {
// Slow log needs to be enabled initially to spin up the SlowLogQueueService
TEST_UTIL.getConfiguration().setBoolean(HConstants.SLOW_LOG_BUFFER_ENABLED_KEY, true);
TEST_UTIL.getConfiguration().setInt("hbase.ipc.warn.response.size", 100);
TEST_UTIL.getConfiguration().setInt("hbase.ipc.warn.response.size",
HConstants.DEFAULT_BLOCKSIZE / 2);
TEST_UTIL.startMiniCluster(1);
ADMIN = TEST_UTIL.getAdmin();
}

@AfterClass
public static void afterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}

/**
* Tests that we can trigger based on blocks scanned, and also that we properly pass the block
* bytes scanned value through to the client.
*/
@Test
public void testLogLargeBlockBytesScanned() throws IOException, InterruptedException {
public void testLogLargeBlockBytesScanned() throws IOException {
// Turn off slow log buffer for initial loadTable, because we were seeing core dump
// issues coming from that slow log entry. We will re-enable below.
HRegionServer regionServer = TEST_UTIL.getHBaseCluster().getRegionServer(0);
regionServer.getConfiguration().setBoolean(HConstants.SLOW_LOG_BUFFER_ENABLED_KEY, false);
regionServer.updateConfiguration();

byte[] family = Bytes.toBytes("0");
Table table = TEST_UTIL.createTable(TableName.valueOf("testLogLargeBlockBytesScanned"), family);
TEST_UTIL.loadTable(table, family);
TEST_UTIL.flush(table.getName());

Set<ServerName> server =
Collections.singleton(TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName());
Set<ServerName> server = Collections.singleton(regionServer.getServerName());
Admin admin = TEST_UTIL.getAdmin();
admin.clearSlowLogResponses(server);

// Turn on slow log so we capture large scan below
regionServer.getConfiguration().setBoolean(HConstants.SLOW_LOG_BUFFER_ENABLED_KEY, true);
regionServer.updateConfiguration();

Scan scan = new Scan();
scan.setCaching(1);
Expand All @@ -90,13 +107,12 @@ public void testLogLargeBlockBytesScanned() throws IOException, InterruptedExcep
scanner.next();
}

List<LogEntry> entries =
admin.getLogEntries(server, "LARGE_LOG", ServerType.REGION_SERVER, 1, Collections.emptyMap());
List<LogEntry> entries = admin.getLogEntries(server, "LARGE_LOG", ServerType.REGION_SERVER, 100,
Collections.emptyMap());

assertEquals(1, entries.size());

OnlineLogRecord record = (OnlineLogRecord) entries.get(0);
System.out.println(record.toJsonPrettyPrint());

assertTrue("expected " + record.getBlockBytesScanned() + " to be >= 100",
record.getBlockBytesScanned() >= 100);
Expand Down

0 comments on commit 1a9e465

Please sign in to comment.