@Test(timeout = 30000)
public void testGetSafeModeTip() throws Exception {

  bmSafeMode.activate(BLOCK_TOTAL);
  String tip = bmSafeMode.getSafeModeTip();
  assertTrue(tip.contains(
      String.format(
          "The reported blocks %d needs additional %d blocks to reach the " +
              "threshold %.4f of total blocks %d.%n",
          0, BLOCK_THRESHOLD, THRESHOLD, BLOCK_TOTAL)));
  assertTrue(tip.contains(
      "The number of live datanodes is not calculated " +
          "since reported blocks hasn't reached the threshold."));
  assertTrue(tip.contains("Safe mode will be turned off automatically once " +
      "the thresholds have been reached."));
  // safe blocks are enough
  setBlockSafe(BLOCK_THRESHOLD);
  bmSafeMode.checkSafeMode();
  tip = bmSafeMode.getSafeModeTip();
  assertTrue(tip.contains(
      String.format("The reported blocks %d has reached the threshold"
              + " %.4f of total blocks %d. ",
          getblockSafe(), THRESHOLD, BLOCK_TOTAL)));
  assertTrue(tip.contains(
      String.format("The number of live datanodes %d has reached the " +
          "minimum number %d. ", dn.getNumLiveDataNodes(), DATANODE_NUM)));
  assertTrue(tip.contains("In safe mode extension. Safe mode will be turned" +
      " off automatically in"));
  waitForExtensionPeriod();
  tip = bmSafeMode.getSafeModeTip();
  assertTrue(tip.contains(
      String.format("The reported blocks %d has reached the threshold"
              + " %.4f of total blocks %d. ",
          getblockSafe(), THRESHOLD, BLOCK_TOTAL)));
  assertTrue(tip.contains(
      String.format("The number of live datanodes %d has reached the " +
          "minimum number %d. ", dn.getNumLiveDataNodes(), DATANODE_NUM)));
  assertTrue(tip.contains("Safe mode will be turned off automatically soon"));
}