nk1506 commented on code in PR #9282: URL: https://github.com/apache/iceberg/pull/9282#discussion_r1423846032
########## hive-metastore/src/test/java/org/apache/iceberg/hive/TestCachedClientPool.java: ########## @@ -28,30 +28,46 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.security.UserGroupInformation; +import org.apache.iceberg.CatalogProperties; import org.apache.iceberg.CatalogUtil; import org.apache.iceberg.exceptions.ValidationException; import org.apache.iceberg.hive.CachedClientPool.Key; import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class TestCachedClientPool extends HiveMetastoreTest { +public class TestCachedClientPool { + private static final long EVICTION_INTERVAL = TimeUnit.SECONDS.toMillis(10); + private static final String DB_NAME = "hivedb"; + + @RegisterExtension + private static final HiveMetastoreExtension HIVE_METASTORE_EXTENSION = + new HiveMetastoreExtension(DB_NAME, Collections.emptyMap()); @Test public void testClientPoolCleaner() throws InterruptedException { - CachedClientPool clientPool = new CachedClientPool(hiveConf, Collections.emptyMap()); + CachedClientPool clientPool = + new CachedClientPool( + HIVE_METASTORE_EXTENSION.hiveConf(), + ImmutableMap.of( + CatalogProperties.CLIENT_POOL_CACHE_EVICTION_INTERVAL_MS, + String.valueOf(EVICTION_INTERVAL))); HiveClientPool clientPool1 = clientPool.clientPool(); assertThat(clientPool1) .isSameAs( CachedClientPool.clientPoolCache() - .getIfPresent(CachedClientPool.extractKey(null, hiveConf))); + .getIfPresent( + CachedClientPool.extractKey(null, HIVE_METASTORE_EXTENSION.hiveConf()))); TimeUnit.MILLISECONDS.sleep(EVICTION_INTERVAL - TimeUnit.SECONDS.toMillis(2)); HiveClientPool clientPool2 = clientPool.clientPool(); assertThat(clientPool2).isSameAs(clientPool1); TimeUnit.MILLISECONDS.sleep(EVICTION_INTERVAL + TimeUnit.SECONDS.toMillis(5)); assertThat( CachedClientPool.clientPoolCache() - .getIfPresent(CachedClientPool.extractKey(null, hiveConf))) + .getIfPresent( + CachedClientPool.extractKey(null, HIVE_METASTORE_EXTENSION.hiveConf()))) Review Comment: At other test `hiveConf` was being used at multiple places, that's the reason I created a local variable. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org