Skip to content

Commit 3436ab9

Browse files
committed
HBASE-27534 Addendum fix test crash (#5011)
1 parent 3358db1 commit 3436ab9

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestTooLargeLog.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
import org.apache.hadoop.hbase.client.Scan;
3737
import org.apache.hadoop.hbase.client.ServerType;
3838
import org.apache.hadoop.hbase.client.Table;
39+
import org.apache.hadoop.hbase.regionserver.HRegionServer;
3940
import org.apache.hadoop.hbase.testclassification.MediumTests;
4041
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
4142
import org.apache.hadoop.hbase.util.Bytes;
43+
import org.junit.AfterClass;
4244
import org.junit.BeforeClass;
4345
import org.junit.ClassRule;
4446
import org.junit.Rule;
@@ -61,27 +63,42 @@ public class TestTooLargeLog {
6163

6264
@BeforeClass
6365
public static void setUpBeforeClass() throws Exception {
66+
// Slow log needs to be enabled initially to spin up the SlowLogQueueService
6467
TEST_UTIL.getConfiguration().setBoolean(HConstants.SLOW_LOG_BUFFER_ENABLED_KEY, true);
65-
TEST_UTIL.getConfiguration().setInt("hbase.ipc.warn.response.size", 100);
68+
TEST_UTIL.getConfiguration().setInt("hbase.ipc.warn.response.size",
69+
HConstants.DEFAULT_BLOCKSIZE / 2);
6670
TEST_UTIL.startMiniCluster(1);
6771
ADMIN = TEST_UTIL.getAdmin();
6872
}
6973

74+
@AfterClass
75+
public static void afterClass() throws Exception {
76+
TEST_UTIL.shutdownMiniCluster();
77+
}
78+
7079
/**
7180
* Tests that we can trigger based on blocks scanned, and also that we properly pass the block
7281
* bytes scanned value through to the client.
7382
*/
7483
@Test
75-
public void testLogLargeBlockBytesScanned() throws IOException, InterruptedException {
84+
public void testLogLargeBlockBytesScanned() throws IOException {
85+
// Turn off slow log buffer for initial loadTable, because we were seeing core dump
86+
// issues coming from that slow log entry. We will re-enable below.
87+
HRegionServer regionServer = TEST_UTIL.getHBaseCluster().getRegionServer(0);
88+
regionServer.getConfiguration().setBoolean(HConstants.SLOW_LOG_BUFFER_ENABLED_KEY, false);
89+
regionServer.updateConfiguration();
90+
7691
byte[] family = Bytes.toBytes("0");
7792
Table table = TEST_UTIL.createTable(TableName.valueOf("testLogLargeBlockBytesScanned"), family);
7893
TEST_UTIL.loadTable(table, family);
7994
TEST_UTIL.flush(table.getName());
8095

81-
Set<ServerName> server =
82-
Collections.singleton(TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName());
96+
Set<ServerName> server = Collections.singleton(regionServer.getServerName());
8397
Admin admin = TEST_UTIL.getAdmin();
84-
admin.clearSlowLogResponses(server);
98+
99+
// Turn on slow log so we capture large scan below
100+
regionServer.getConfiguration().setBoolean(HConstants.SLOW_LOG_BUFFER_ENABLED_KEY, true);
101+
regionServer.updateConfiguration();
85102

86103
Scan scan = new Scan();
87104
scan.setCaching(1);
@@ -90,13 +107,12 @@ public void testLogLargeBlockBytesScanned() throws IOException, InterruptedExcep
90107
scanner.next();
91108
}
92109

93-
List<LogEntry> entries =
94-
admin.getLogEntries(server, "LARGE_LOG", ServerType.REGION_SERVER, 1, Collections.emptyMap());
110+
List<LogEntry> entries = admin.getLogEntries(server, "LARGE_LOG", ServerType.REGION_SERVER, 100,
111+
Collections.emptyMap());
95112

96113
assertEquals(1, entries.size());
97114

98115
OnlineLogRecord record = (OnlineLogRecord) entries.get(0);
99-
System.out.println(record.toJsonPrettyPrint());
100116

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

0 commit comments

Comments
 (0)