ndimiduk commented on a change in pull request #1141: HBASE-23808 [Flakey Test]
TestMasterShutdown#testMasterShutdownBefore…
URL: https://github.com/apache/hbase/pull/1141#discussion_r377778169
##########
File path:
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterShutdown.java
##########
@@ -128,41 +142,50 @@ public void
testMasterShutdownBeforeStartingAnyRegionServer() throws Exception {
conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
// Start the cluster
- final HBaseTestingUtility util = new HBaseTestingUtility(conf);
- util.startMiniDFSCluster(3);
- util.startMiniZKCluster();
- util.createRootDir();
- final LocalHBaseCluster cluster =
- new LocalHBaseCluster(conf, NUM_MASTERS, NUM_RS, HMaster.class,
- MiniHBaseCluster.MiniHBaseClusterRegionServer.class);
- final int MASTER_INDEX = 0;
- final MasterThread master = cluster.getMasters().get(MASTER_INDEX);
- master.start();
- LOG.info("Called master start on " + master.getName());
- Thread shutdownThread = new Thread("Shutdown-Thread") {
- @Override
- public void run() {
- LOG.info("Before call to shutdown master");
- try (Connection connection = createConnection(util); Admin admin =
connection.getAdmin()) {
- admin.shutdown();
- } catch (Exception e) {
- LOG.info("Error while calling Admin.shutdown, which is expected: " +
e.getMessage());
+ LocalHBaseCluster cluster = null;
+ try {
+ htu = new HBaseTestingUtility(conf);
+ htu.startMiniDFSCluster(3);
+ htu.startMiniZKCluster();
+ htu.createRootDir();
+ cluster = new LocalHBaseCluster(conf, NUM_MASTERS, NUM_RS, HMaster.class,
+ MiniHBaseCluster.MiniHBaseClusterRegionServer.class);
+ final int MASTER_INDEX = 0;
+ final MasterThread master = cluster.getMasters().get(MASTER_INDEX);
+ master.start();
+ LOG.info("Called master start on " + master.getName());
+ final LocalHBaseCluster finalCluster = cluster;
+ Thread shutdownThread = new Thread("Shutdown-Thread") {
+ @Override
+ public void run() {
+ LOG.info("Before call to shutdown master");
+ try (Connection connection = createConnection(htu); Admin admin =
connection.getAdmin()) {
+ admin.shutdown();
+ } catch (Exception e) {
+ LOG.info("Error while calling Admin.shutdown, which is expected: "
+ e.getMessage());
+ }
+ LOG.info("After call to shutdown master");
+ finalCluster.waitOnMaster(MASTER_INDEX);
}
- LOG.info("After call to shutdown master");
- cluster.waitOnMaster(MASTER_INDEX);
+ };
+ shutdownThread.start();
+ LOG.info("Called master join on " + master.getName());
+ master.join();
+ shutdownThread.join();
+
+ List<MasterThread> masterThreads = cluster.getMasters();
+ // make sure all the masters properly shutdown
+ assertEquals(0, masterThreads.size());
+ } finally {
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ if (htu != null) {
+ htu.shutdownMiniZKCluster();
Review comment:
_nod_
----------------------------------------------------------------
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