@BeforeClass
  public static void beforeTest() throws Exception   {
    MiniHS2.cleanupLocalDir();
    hiveConf = new HiveConf();
    hiveConf.setBoolVar(ConfVars.HIVE_SERVER2_SUPPORT_DYNAMIC_SERVICE_DISCOVERY, true);
    hiveConf.setIntVar(ConfVars.HIVE_ZOOKEEPER_CONNECTION_MAX_RETRIES, 0);
    hiveConf.setTimeVar(ConfVars.HIVE_ZOOKEEPER_CONNECTION_BASESLEEPTIME, 0, TimeUnit.MILLISECONDS);
    // Disable killquery, this way only HS2 start will fail, not the SessionManager service
    hiveConf.setBoolVar(ConfVars.HIVE_ZOOKEEPER_KILLQUERY_ENABLE, false);
    miniHS2 = new MiniHS2(hiveConf);
    Map<String, String> confOverlay = new HashMap<String, String>();
    try {
      miniHS2.start(confOverlay);
    } catch (Exception ex) {
      LOG.warn("Zookeeper is not set up intentionally, so the error is expected (unless it's not related to ZK): " + ex);
      miniHS2.setStarted(true);
    }
  }
TestMiniHS2StateWithNoZookeeper.
This tests HS2 shutdown is not triggered by CloseSession operation 
while HS2 has never been registered with ZooKeeper.
itests/hive-unit/src/test/java/org/apache/hive/service/cli/thrift/TestMiniHS2StateWithNoZookeeper.java