HBASE-12653 Move TestRegionServerOnlineConfigChange & TestConfigurationManager to Junit4 tests (Ashish)
This commit is contained in:
parent
0354128780
commit
c42c36521d
|
@ -18,17 +18,19 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.conf;
|
package org.apache.hadoop.hbase.conf;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
@Category({SmallTests.class, ClientTests.class})
|
@Category({SmallTests.class, ClientTests.class})
|
||||||
public class TestConfigurationManager extends TestCase {
|
public class TestConfigurationManager {
|
||||||
public static final Log LOG = LogFactory.getLog(TestConfigurationManager.class);
|
public static final Log LOG = LogFactory.getLog(TestConfigurationManager.class);
|
||||||
|
|
||||||
class DummyConfigurationObserver implements ConfigurationObserver {
|
class DummyConfigurationObserver implements ConfigurationObserver {
|
||||||
|
@ -66,6 +68,7 @@ public class TestConfigurationManager extends TestCase {
|
||||||
* Test if observers get notified by the <code>ConfigurationManager</code>
|
* Test if observers get notified by the <code>ConfigurationManager</code>
|
||||||
* when the Configuration is reloaded.
|
* when the Configuration is reloaded.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testCheckIfObserversNotified() {
|
public void testCheckIfObserversNotified() {
|
||||||
Configuration conf = new Configuration();
|
Configuration conf = new Configuration();
|
||||||
ConfigurationManager cm = new ConfigurationManager();
|
ConfigurationManager cm = new ConfigurationManager();
|
||||||
|
@ -101,6 +104,7 @@ public class TestConfigurationManager extends TestCase {
|
||||||
/**
|
/**
|
||||||
* Test if out-of-scope observers are deregistered on GC.
|
* Test if out-of-scope observers are deregistered on GC.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testDeregisterOnOutOfScope() {
|
public void testDeregisterOnOutOfScope() {
|
||||||
Configuration conf = new Configuration();
|
Configuration conf = new Configuration();
|
||||||
ConfigurationManager cm = new ConfigurationManager();
|
ConfigurationManager cm = new ConfigurationManager();
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.regionserver;
|
package org.apache.hadoop.hbase.regionserver;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -30,6 +32,9 @@ import org.apache.hadoop.hbase.client.HTable;
|
||||||
import org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration;
|
import org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -41,25 +46,25 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Category({MediumTests.class})
|
@Category({MediumTests.class})
|
||||||
public class TestRegionServerOnlineConfigChange extends TestCase {
|
public class TestRegionServerOnlineConfigChange {
|
||||||
static final Log LOG =
|
private static final Log LOG =
|
||||||
LogFactory.getLog(TestRegionServerOnlineConfigChange.class.getName());
|
LogFactory.getLog(TestRegionServerOnlineConfigChange.class.getName());
|
||||||
HBaseTestingUtility hbaseTestingUtility = new HBaseTestingUtility();
|
private static HBaseTestingUtility hbaseTestingUtility = new HBaseTestingUtility();
|
||||||
Configuration conf = null;
|
private static Configuration conf = null;
|
||||||
|
|
||||||
HTable t1 = null;
|
private static HTable t1 = null;
|
||||||
HRegionServer rs1 = null;
|
private static HRegionServer rs1 = null;
|
||||||
byte[] r1name = null;
|
private static byte[] r1name = null;
|
||||||
HRegion r1 = null;
|
private static HRegion r1 = null;
|
||||||
|
|
||||||
final String table1Str = "table1";
|
private final static String table1Str = "table1";
|
||||||
final String columnFamily1Str = "columnFamily1";
|
private final static String columnFamily1Str = "columnFamily1";
|
||||||
final byte[] TABLE1 = Bytes.toBytes(table1Str);
|
private final static byte[] TABLE1 = Bytes.toBytes(table1Str);
|
||||||
final byte[] COLUMN_FAMILY1 = Bytes.toBytes(columnFamily1Str);
|
private final static byte[] COLUMN_FAMILY1 = Bytes.toBytes(columnFamily1Str);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@BeforeClass
|
||||||
public void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
conf = hbaseTestingUtility.getConfiguration();
|
conf = hbaseTestingUtility.getConfiguration();
|
||||||
hbaseTestingUtility.startMiniCluster(1,1);
|
hbaseTestingUtility.startMiniCluster(1,1);
|
||||||
t1 = hbaseTestingUtility.createTable(TABLE1, COLUMN_FAMILY1);
|
t1 = hbaseTestingUtility.createTable(TABLE1, COLUMN_FAMILY1);
|
||||||
|
@ -71,8 +76,8 @@ public class TestRegionServerOnlineConfigChange extends TestCase {
|
||||||
r1 = rs1.getRegion(r1name);
|
r1 = rs1.getRegion(r1name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@AfterClass
|
||||||
public void tearDown() throws Exception {
|
public static void tearDown() throws Exception {
|
||||||
hbaseTestingUtility.shutdownMiniCluster();
|
hbaseTestingUtility.shutdownMiniCluster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +85,7 @@ public class TestRegionServerOnlineConfigChange extends TestCase {
|
||||||
* Check if the number of compaction threads changes online
|
* Check if the number of compaction threads changes online
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testNumCompactionThreadsOnlineChange() throws IOException {
|
public void testNumCompactionThreadsOnlineChange() throws IOException {
|
||||||
assertTrue(rs1.compactSplitThread != null);
|
assertTrue(rs1.compactSplitThread != null);
|
||||||
int newNumSmallThreads =
|
int newNumSmallThreads =
|
||||||
|
@ -105,6 +111,7 @@ public class TestRegionServerOnlineConfigChange extends TestCase {
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testCompactionConfigurationOnlineChange() throws IOException {
|
public void testCompactionConfigurationOnlineChange() throws IOException {
|
||||||
String strPrefix = "hbase.hstore.compaction.";
|
String strPrefix = "hbase.hstore.compaction.";
|
||||||
Store s = r1.getStore(COLUMN_FAMILY1);
|
Store s = r1.getStore(COLUMN_FAMILY1);
|
||||||
|
|
Loading…
Reference in New Issue