HBASE-27075 TestUpdateRSGroupConfiguration.testCustomOnlineConfigChangeInRSGroup is flaky (#4636)
Signed-off-by: Xin Sun <ddupgs@gmail.com>
This commit is contained in:
parent
75a05b5cd0
commit
31fc97edee
|
@ -24,6 +24,8 @@ import java.nio.file.Paths;
|
|||
import java.nio.file.StandardCopyOption;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtil;
|
||||
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Base class to test Configuration Update logic. It wraps up things needed to test configuration
|
||||
|
@ -31,6 +33,8 @@ import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
|
|||
* file.
|
||||
*/
|
||||
public abstract class AbstractTestUpdateConfiguration {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractTestUpdateConfiguration.class);
|
||||
|
||||
private static final String SERVER_CONFIG = "hbase-site.xml";
|
||||
private static final String OVERRIDE_SERVER_CONFIG = "override-hbase-site.xml";
|
||||
private static final String BACKUP_SERVER_CONFIG = "backup-hbase-site.xml";
|
||||
|
@ -90,7 +94,9 @@ public abstract class AbstractTestUpdateConfiguration {
|
|||
* using {@link #restoreHBaseSiteXML()}.
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void replaceHBaseSiteXML() throws IOException {
|
||||
protected final void replaceHBaseSiteXML() throws IOException {
|
||||
LOG.info("Replace hbase config {} with {}", configFileUnderTestDataDir,
|
||||
overrideConfigFileUnderTestDataDir);
|
||||
// make a backup of hbase-site.xml
|
||||
Files.copy(configFileUnderTestDataDir, backupConfigFileUnderTestDataDir,
|
||||
StandardCopyOption.REPLACE_EXISTING);
|
||||
|
@ -104,7 +110,9 @@ public abstract class AbstractTestUpdateConfiguration {
|
|||
* {@link #replaceHBaseSiteXML()}.
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void restoreHBaseSiteXML() throws IOException {
|
||||
protected final void restoreHBaseSiteXML() throws IOException {
|
||||
LOG.info("Restore hbase config {} with {}", configFileUnderTestDataDir,
|
||||
backupConfigFileUnderTestDataDir);
|
||||
// restore hbase-site.xml
|
||||
Files.copy(backupConfigFileUnderTestDataDir, configFileUnderTestDataDir,
|
||||
StandardCopyOption.REPLACE_EXISTING);
|
||||
|
|
|
@ -108,11 +108,11 @@ public abstract class TestRSGroupsBase extends AbstractTestUpdateConfiguration {
|
|||
conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, CPMasterObserver.class.getName());
|
||||
}
|
||||
|
||||
conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, NUM_SLAVES_BASE - 1);
|
||||
conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, NUM_SLAVES_BASE);
|
||||
conf.setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
|
||||
conf.setInt("hbase.rpc.timeout", 100000);
|
||||
|
||||
TEST_UTIL.startMiniCluster(NUM_SLAVES_BASE - 1);
|
||||
TEST_UTIL.startMiniCluster(NUM_SLAVES_BASE);
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
@ -303,9 +303,9 @@ public abstract class TestRSGroupsBase extends AbstractTestUpdateConfiguration {
|
|||
protected final void toggleQuotaCheckAndRestartMiniCluster(boolean enable) throws Exception {
|
||||
TEST_UTIL.shutdownMiniCluster();
|
||||
TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, enable);
|
||||
TEST_UTIL.startMiniCluster(NUM_SLAVES_BASE - 1);
|
||||
TEST_UTIL.startMiniCluster(NUM_SLAVES_BASE);
|
||||
TEST_UTIL.getConfiguration().setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART,
|
||||
NUM_SLAVES_BASE - 1);
|
||||
NUM_SLAVES_BASE);
|
||||
TEST_UTIL.getConfiguration().setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
|
||||
initialize();
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
package org.apache.hadoop.hbase.rsgroup;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.net.Address;
|
||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
import org.apache.hadoop.hbase.util.JVMClusterUtil;
|
||||
import org.junit.After;
|
||||
|
@ -35,6 +35,8 @@ import org.junit.experimental.categories.Category;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;
|
||||
|
||||
@Category({ MediumTests.class })
|
||||
public class TestUpdateRSGroupConfiguration extends TestRSGroupsBase {
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(TestUpdateRSGroupConfiguration.class);
|
||||
|
@ -67,24 +69,15 @@ public class TestUpdateRSGroupConfiguration extends TestRSGroupsBase {
|
|||
tearDownAfterMethod();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlineConfigChangeInRSGroup() throws Exception {
|
||||
addGroup(TEST_GROUP, 1);
|
||||
ADMIN.updateConfiguration(TEST_GROUP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonexistentRSGroup() throws Exception {
|
||||
try {
|
||||
ADMIN.updateConfiguration(TEST2_GROUP);
|
||||
fail("Group does not exist: test2");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// expected
|
||||
}
|
||||
assertThrows(IllegalArgumentException.class, () -> ADMIN.updateConfiguration(TEST2_GROUP));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomOnlineConfigChangeInRSGroup() throws Exception {
|
||||
RSGroupInfo testRSGroup = addGroup(TEST_GROUP, 1);
|
||||
RSGroupInfo test2RSGroup = addGroup(TEST2_GROUP, 1);
|
||||
// Check the default configuration of the RegionServers
|
||||
TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().forEach(thread -> {
|
||||
Configuration conf = thread.getRegionServer().getConfiguration();
|
||||
|
@ -92,28 +85,27 @@ public class TestUpdateRSGroupConfiguration extends TestRSGroupsBase {
|
|||
});
|
||||
|
||||
replaceHBaseSiteXML();
|
||||
RSGroupInfo testRSGroup = addGroup(TEST_GROUP, 1);
|
||||
RSGroupInfo test2RSGroup = addGroup(TEST2_GROUP, 1);
|
||||
ADMIN.updateConfiguration(TEST_GROUP);
|
||||
try {
|
||||
ADMIN.updateConfiguration(TEST_GROUP);
|
||||
|
||||
// Check the configuration of the RegionServer in test rsgroup, should be update
|
||||
Configuration regionServerConfiguration = TEST_UTIL.getMiniHBaseCluster()
|
||||
.getLiveRegionServerThreads().stream().map(JVMClusterUtil.RegionServerThread::getRegionServer)
|
||||
.filter(regionServer -> (regionServer.getServerName().getAddress()
|
||||
.equals(testRSGroup.getServers().iterator().next())))
|
||||
.collect(Collectors.toList()).get(0).getConfiguration();
|
||||
int custom = regionServerConfiguration.getInt("hbase.custom.config", 0);
|
||||
assertEquals(1000, custom);
|
||||
Address testServerAddr = Iterables.getOnlyElement(testRSGroup.getServers());
|
||||
LOG.info("Check hbase.custom.config for " + testServerAddr);
|
||||
Configuration testRsConf = TEST_UTIL.getMiniHBaseCluster().getLiveRegionServerThreads()
|
||||
.stream().map(JVMClusterUtil.RegionServerThread::getRegionServer)
|
||||
.filter(rs -> rs.getServerName().getAddress().equals(testServerAddr)).findFirst().get()
|
||||
.getConfiguration();
|
||||
assertEquals(1000, testRsConf.getInt("hbase.custom.config", 0));
|
||||
|
||||
// Check the configuration of the RegionServer in test2 rsgroup, should not be update
|
||||
regionServerConfiguration = TEST_UTIL.getMiniHBaseCluster().getLiveRegionServerThreads()
|
||||
.stream().map(JVMClusterUtil.RegionServerThread::getRegionServer)
|
||||
.filter(regionServer -> (regionServer.getServerName().getAddress()
|
||||
.equals(test2RSGroup.getServers().iterator().next())))
|
||||
.collect(Collectors.toList()).get(0).getConfiguration();
|
||||
custom = regionServerConfiguration.getInt("hbase.custom.config", 0);
|
||||
assertEquals(0, custom);
|
||||
|
||||
restoreHBaseSiteXML();
|
||||
Address test2ServerAddr = Iterables.getOnlyElement(test2RSGroup.getServers());
|
||||
LOG.info("Check hbase.custom.config for " + test2ServerAddr);
|
||||
// Check the configuration of the RegionServer in test2 rsgroup, should not be update
|
||||
Configuration test2RsConf = TEST_UTIL.getMiniHBaseCluster().getLiveRegionServerThreads()
|
||||
.stream().map(JVMClusterUtil.RegionServerThread::getRegionServer)
|
||||
.filter(rs -> rs.getServerName().getAddress().equals(test2ServerAddr)).findFirst().get()
|
||||
.getConfiguration();
|
||||
assertEquals(0, test2RsConf.getInt("hbase.custom.config", 0));
|
||||
} finally {
|
||||
restoreHBaseSiteXML();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue