@Test
  public void testConnectionTimeout() throws Exception {
    Configuration newConf = new Configuration(conf);
    MetastoreConf.setTimeVar(newConf, ConfVars.CLIENT_CONNECTION_TIMEOUT, 1000,
            TimeUnit.MILLISECONDS);
    // fake host to mock connection time out
    MetastoreConf.setVar(newConf, ConfVars.THRIFT_URIS, "thrift://" + IPStackUtils.transformToIPv6("1.1.1.1", port));
    MetastoreConf.setLongVar(newConf, ConfVars.THRIFT_CONNECTION_RETRIES, 1);

    Future<Void> future = Executors.newSingleThreadExecutor().submit(() -> {
      try(HiveMetaStoreClient c = new HiveMetaStoreClient(newConf)) {
        Assert.fail("should throw connection timeout exception.");
      } catch (MetaException e) {
        Assert.assertTrue("unexpected Exception", e.getMessage().contains("Connect timed out"));
      }
      return null;
    });
    future.get(5, TimeUnit.SECONDS);
  }
Test handler proxy used to simulate a long-running create_database() method
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreTimeout.java