HBASE-19598 Fix TestAssignmentManagerMetrics flaky test
This commit is contained in:
parent
a513678a79
commit
033485dff3
|
@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.client.Put;
|
||||||
import org.apache.hadoop.hbase.client.Table;
|
import org.apache.hadoop.hbase.client.Table;
|
||||||
import org.apache.hadoop.hbase.client.TableDescriptor;
|
import org.apache.hadoop.hbase.client.TableDescriptor;
|
||||||
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
|
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
|
||||||
|
import org.apache.hadoop.hbase.master.assignment.AssignmentManager;
|
||||||
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
|
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
|
||||||
import org.apache.hadoop.hbase.testclassification.MasterTests;
|
import org.apache.hadoop.hbase.testclassification.MasterTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
|
@ -54,14 +55,13 @@ public class TestAssignmentManagerMetrics {
|
||||||
HBaseClassTestRule.forClass(TestAssignmentManagerMetrics.class);
|
HBaseClassTestRule.forClass(TestAssignmentManagerMetrics.class);
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TestAssignmentManagerMetrics.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TestAssignmentManagerMetrics.class);
|
||||||
private static final MetricsAssertHelper metricsHelper = CompatibilityFactory
|
private static final MetricsAssertHelper METRICS_HELPER = CompatibilityFactory
|
||||||
.getInstance(MetricsAssertHelper.class);
|
.getInstance(MetricsAssertHelper.class);
|
||||||
|
|
||||||
private static MiniHBaseCluster cluster;
|
private static MiniHBaseCluster CLUSTER;
|
||||||
private static HMaster master;
|
private static HMaster MASTER;
|
||||||
private static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
private static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
||||||
private static Configuration conf;
|
private static final int MSG_INTERVAL = 1000;
|
||||||
private static final int msgInterval = 1000;
|
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TestName name = new TestName();
|
public TestName name = new TestName();
|
||||||
|
@ -69,7 +69,7 @@ public class TestAssignmentManagerMetrics {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void startCluster() throws Exception {
|
public static void startCluster() throws Exception {
|
||||||
LOG.info("Starting cluster");
|
LOG.info("Starting cluster");
|
||||||
conf = TEST_UTIL.getConfiguration();
|
Configuration conf = TEST_UTIL.getConfiguration();
|
||||||
|
|
||||||
// Disable sanity check for coprocessor
|
// Disable sanity check for coprocessor
|
||||||
conf.setBoolean("hbase.table.sanity.checks", false);
|
conf.setBoolean("hbase.table.sanity.checks", false);
|
||||||
|
@ -78,7 +78,7 @@ public class TestAssignmentManagerMetrics {
|
||||||
conf.setInt(HConstants.METRICS_RIT_STUCK_WARNING_THRESHOLD, 20);
|
conf.setInt(HConstants.METRICS_RIT_STUCK_WARNING_THRESHOLD, 20);
|
||||||
|
|
||||||
// set msgInterval to 1 second
|
// set msgInterval to 1 second
|
||||||
conf.setInt("hbase.regionserver.msginterval", msgInterval);
|
conf.setInt("hbase.regionserver.msginterval", MSG_INTERVAL);
|
||||||
|
|
||||||
// set tablesOnMaster to none
|
// set tablesOnMaster to none
|
||||||
conf.set("hbase.balancer.tablesOnMaster", "none");
|
conf.set("hbase.balancer.tablesOnMaster", "none");
|
||||||
|
@ -87,10 +87,12 @@ public class TestAssignmentManagerMetrics {
|
||||||
conf.setInt("hbase.client.sync.wait.timeout.msec", 2500);
|
conf.setInt("hbase.client.sync.wait.timeout.msec", 2500);
|
||||||
conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
|
conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
|
||||||
conf.setInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, 2500);
|
conf.setInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, 2500);
|
||||||
|
// set a small interval for updating rit metrics
|
||||||
|
conf.setInt(AssignmentManager.RIT_CHORE_INTERVAL_MSEC_CONF_KEY, MSG_INTERVAL);
|
||||||
|
|
||||||
TEST_UTIL.startMiniCluster(1);
|
TEST_UTIL.startMiniCluster(1);
|
||||||
cluster = TEST_UTIL.getHBaseCluster();
|
CLUSTER = TEST_UTIL.getHBaseCluster();
|
||||||
master = cluster.getMaster();
|
MASTER = CLUSTER.getMaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -112,14 +114,14 @@ public class TestAssignmentManagerMetrics {
|
||||||
table.put(put);
|
table.put(put);
|
||||||
|
|
||||||
// Sleep 3 seconds, wait for doMetrics chore catching up
|
// Sleep 3 seconds, wait for doMetrics chore catching up
|
||||||
Thread.sleep(msgInterval * 3);
|
Thread.sleep(MSG_INTERVAL * 3);
|
||||||
|
|
||||||
// check the RIT is 0
|
// check the RIT is 0
|
||||||
MetricsAssignmentManagerSource amSource =
|
MetricsAssignmentManagerSource amSource =
|
||||||
master.getAssignmentManager().getAssignmentManagerMetrics().getMetricsProcSource();
|
MASTER.getAssignmentManager().getAssignmentManagerMetrics().getMetricsProcSource();
|
||||||
|
|
||||||
metricsHelper.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_NAME, 0, amSource);
|
METRICS_HELPER.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_NAME, 0, amSource);
|
||||||
metricsHelper.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_OVER_THRESHOLD_NAME, 0,
|
METRICS_HELPER.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_OVER_THRESHOLD_NAME, 0,
|
||||||
amSource);
|
amSource);
|
||||||
|
|
||||||
// alter table with a non-existing coprocessor
|
// alter table with a non-existing coprocessor
|
||||||
|
@ -139,9 +141,9 @@ public class TestAssignmentManagerMetrics {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep 3 seconds, wait for doMetrics chore catching up
|
// Sleep 3 seconds, wait for doMetrics chore catching up
|
||||||
Thread.sleep(msgInterval * 3);
|
Thread.sleep(MSG_INTERVAL * 3);
|
||||||
metricsHelper.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_NAME, 1, amSource);
|
METRICS_HELPER.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_NAME, 1, amSource);
|
||||||
metricsHelper.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_OVER_THRESHOLD_NAME, 1,
|
METRICS_HELPER.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_OVER_THRESHOLD_NAME, 1,
|
||||||
amSource);
|
amSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue