bharathv commented on a change in pull request #1141: HBASE-23808 [Flakey Test]
TestMasterShutdown#testMasterShutdownBefore…
URL: https://github.com/apache/hbase/pull/1141#discussion_r376196608
##########
File path:
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterShutdown.java
##########
@@ -66,43 +78,45 @@ public void testMasterShutdown() throws Exception {
Configuration conf = HBaseConfiguration.create();
// Start the cluster
- HBaseTestingUtility htu = new HBaseTestingUtility(conf);
- StartMiniClusterOption option = StartMiniClusterOption.builder()
-
.numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build();
- htu.startMiniCluster(option);
- MiniHBaseCluster cluster = htu.getHBaseCluster();
-
- // get all the master threads
- List<MasterThread> masterThreads = cluster.getMasterThreads();
-
- // wait for each to come online
- for (MasterThread mt : masterThreads) {
- assertTrue(mt.isAlive());
- }
-
- // find the active master
- HMaster active = null;
- for (int i = 0; i < masterThreads.size(); i++) {
- if (masterThreads.get(i).getMaster().isActiveMaster()) {
- active = masterThreads.get(i).getMaster();
- break;
+ try {
+ htu = new HBaseTestingUtility(conf);
+ StartMiniClusterOption option = StartMiniClusterOption.builder()
+ .numMasters(NUM_MASTERS)
+ .numRegionServers(NUM_RS)
+ .numDataNodes(NUM_RS)
+ .build();
+ final MiniHBaseCluster cluster = htu.startMiniCluster(option);
+
+ // wait for all master thread to spawn and start their run loop.
+ final long thirtySeconds = TimeUnit.SECONDS.toMillis(30);
+ final long oneSecond = TimeUnit.SECONDS.toMillis(1);
+ assertNotEquals(-1, htu.waitFor(thirtySeconds, oneSecond, () -> {
+ final List<MasterThread> masterThreads = cluster.getMasterThreads();
+ return CollectionUtils.isNotEmpty(masterThreads)
Review comment:
nit: Can probably be simplified to masterThreads != null &&
masterThreads.size() >=3...
because the second check automatically means isNotEmpty().
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services