HBASE-23956 Use less resources running tests (#1266)

Addendum: Two more tests that had issues because parent cut
down the number of default RegionServers launched.
This commit is contained in:
stack 2020-03-11 21:00:35 -07:00
parent f4c576582b
commit 20658c5139
2 changed files with 18 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/** /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
@ -20,12 +20,11 @@ package org.apache.hadoop.hbase.replication;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Result;
@ -45,7 +44,6 @@ import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters; import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList; import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
/** /**
@ -62,7 +60,7 @@ public class TestReplicationChangingPeerRegionservers extends TestReplicationBas
private static final Logger LOG = private static final Logger LOG =
LoggerFactory.getLogger(TestReplicationChangingPeerRegionservers.class); LoggerFactory.getLogger(TestReplicationChangingPeerRegionservers.class);
@Parameter(0) @SuppressWarnings("checkstyle:VisibilityModifier") @Parameter(0)
public boolean serialPeer; public boolean serialPeer;
@Parameter(1) @Parameter(1)
@ -124,6 +122,13 @@ public class TestReplicationChangingPeerRegionservers extends TestReplicationBas
public void testChangingNumberOfPeerRegionServers() throws IOException, InterruptedException { public void testChangingNumberOfPeerRegionServers() throws IOException, InterruptedException {
LOG.info("testSimplePutDelete"); LOG.info("testSimplePutDelete");
MiniHBaseCluster peerCluster = UTIL2.getMiniHBaseCluster(); MiniHBaseCluster peerCluster = UTIL2.getMiniHBaseCluster();
// This test wants two RS's up. We only run one generally so add one.
peerCluster.startRegionServer();
Waiter.waitFor(peerCluster.getConfiguration(), 30000, new Waiter.Predicate<Exception>() {
@Override public boolean evaluate() throws Exception {
return peerCluster.getLiveRegionServerThreads().size() > 1;
}
});
int numRS = peerCluster.getRegionServerThreads().size(); int numRS = peerCluster.getRegionServerThreads().size();
doPutTest(Bytes.toBytes(1)); doPutTest(Bytes.toBytes(1));

View File

@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.ClusterMetrics.Option;
import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.ServerMetrics; import org.apache.hadoop.hbase.ServerMetrics;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.HRegionServer;
@ -59,6 +60,13 @@ public class TestReplicationStatus extends TestReplicationBase {
*/ */
@Test @Test
public void testReplicationStatus() throws Exception { public void testReplicationStatus() throws Exception {
// This test wants two RS's up. We only run one generally so add one.
UTIL1.getMiniHBaseCluster().startRegionServer();
Waiter.waitFor(UTIL1.getConfiguration(), 30000, new Waiter.Predicate<Exception>() {
@Override public boolean evaluate() throws Exception {
return UTIL1.getMiniHBaseCluster().getLiveRegionServerThreads().size() > 1;
}
});
Admin hbaseAdmin = UTIL1.getAdmin(); Admin hbaseAdmin = UTIL1.getAdmin();
// disable peer <= WHY? I DON'T GET THIS DISABLE BUT TEST FAILS W/O IT. // disable peer <= WHY? I DON'T GET THIS DISABLE BUT TEST FAILS W/O IT.
hbaseAdmin.disableReplicationPeer(PEER_ID2); hbaseAdmin.disableReplicationPeer(PEER_ID2);