HBASE-19821 TestCleanerChore#testOnConfigurationChange() requires at least 4 processors to get passed

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
lixiang 2018-01-18 04:41:05 +00:00 committed by tedyu
parent 25621c6ea2
commit a2d9a17851
1 changed files with 12 additions and 3 deletions

View File

@ -356,13 +356,22 @@ public class TestCleanerChore {
@Test @Test
public void testOnConfigurationChange() throws Exception { public void testOnConfigurationChange() throws Exception {
int availableProcessorNum = Runtime.getRuntime().availableProcessors();
if (availableProcessorNum == 1) { // no need to run this test
return;
}
// have at least 2 available processors/cores
int initPoolSize = availableProcessorNum / 2;
int changedPoolSize = availableProcessorNum;
Stoppable stop = new StoppableImplementation(); Stoppable stop = new StoppableImplementation();
Configuration conf = UTIL.getConfiguration(); Configuration conf = UTIL.getConfiguration();
Path testDir = UTIL.getDataTestDir(); Path testDir = UTIL.getDataTestDir();
FileSystem fs = UTIL.getTestFileSystem(); FileSystem fs = UTIL.getTestFileSystem();
String confKey = "hbase.test.cleaner.delegates"; String confKey = "hbase.test.cleaner.delegates";
conf.set(confKey, AlwaysDelete.class.getName()); conf.set(confKey, AlwaysDelete.class.getName());
conf.set(CleanerChore.CHORE_POOL_SIZE, "2"); conf.set(CleanerChore.CHORE_POOL_SIZE, String.valueOf(initPoolSize));
AllValidPaths chore = new AllValidPaths("test-file-cleaner", stop, conf, fs, testDir, confKey); AllValidPaths chore = new AllValidPaths("test-file-cleaner", stop, conf, fs, testDir, confKey);
chore.setEnabled(true); chore.setEnabled(true);
// Create subdirs under testDir // Create subdirs under testDir
@ -381,9 +390,9 @@ public class TestCleanerChore {
t.setDaemon(true); t.setDaemon(true);
t.start(); t.start();
// Change size of chore's pool // Change size of chore's pool
conf.set(CleanerChore.CHORE_POOL_SIZE, "4"); conf.set(CleanerChore.CHORE_POOL_SIZE, String.valueOf(changedPoolSize));
chore.onConfigurationChange(conf); chore.onConfigurationChange(conf);
assertEquals(4, chore.getChorePoolSize()); assertEquals(changedPoolSize, chore.getChorePoolSize());
// Stop chore // Stop chore
t.join(); t.join();
} }