@Before
  public void setUp() throws Exception {
    conf = MetastoreConf.newMetastoreConf();


    System.setProperty(ConfVars.EVENT_LISTENERS.toString(), IpAddressListener.class.getName());
    MetaStoreTestUtils.setConfForStandloneMode(conf);
    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);

    msc = new HiveMetaStoreClient(conf);
  }
TestRemoteHiveMetaStoreIpAddress.

Test which checks that the remote Hive metastore stores the proper IP address using
IpAddressListener
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreIpAddress.java