@BeforeClass
  public static void setup() throws Exception {
    MiniHS2.cleanupLocalDir();
    zkServer = new TestingServer();

    // Create one MiniHS2 with miniMRCluster and one with Local FS only
    HiveConf hiveConf1 = loadConf();
    HiveConf hiveConf2 = new HiveConf();

    setSDConfigs(hiveConf1);
    setSDConfigs(hiveConf2);

    miniHS2server1 = new MiniHS2.Builder().withConf(hiveConf1).withMiniMR().build();
    miniHS2server2 = new MiniHS2.Builder().withConf(hiveConf2).cleanupLocalDirOnStartup(false).build();

    Class.forName(MiniHS2.getJdbcDriverName());
    String instanceId1 = UUID.randomUUID().toString();
    miniHS2server1.start(getConfOverlay(instanceId1));
    miniHS2directUrl1 =
        "jdbc:hive2://" + miniHS2server1.getHost() + ":" + miniHS2server1.getBinaryPort() + "/" + DB_NAME;
    String instanceId2 = UUID.randomUUID().toString();
    miniHS2server2.start(getConfOverlay(instanceId2));
    miniHS2directUrl2 =
        "jdbc:hive2://" + miniHS2server2.getHost() + ":" + miniHS2server2.getBinaryPort() + "/" + DB_NAME;

    String dataFileDir = hiveConf1.get("test.data.files").replace('\\', '/').replace("c:", "");
    kvDataFilePath = new Path(dataFileDir, "kv1.txt");

    setupDb();
  }
Test JDBC driver when two HS2 instance is running with service discovery enabled.
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithServiceDiscovery.java