nastra commented on code in PR #9282:
URL: https://github.com/apache/iceberg/pull/9282#discussion_r1423668858


##########
hive-metastore/src/test/java/org/apache/iceberg/hive/TestCachedClientPool.java:
##########
@@ -28,30 +28,49 @@
 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 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());
+    CatalogUtil.loadCatalog(
+        HiveCatalog.class.getName(),
+        CatalogUtil.ICEBERG_CATALOG_TYPE_HIVE,
+        ImmutableMap.of(
+            CatalogProperties.CLIENT_POOL_CACHE_EVICTION_INTERVAL_MS,
+            String.valueOf(TimeUnit.SECONDS.toMillis(10))),
+        HIVE_METASTORE_EXTENSION.hiveConf());
+    CachedClientPool clientPool =
+        new CachedClientPool(HIVE_METASTORE_EXTENSION.hiveConf(), 
Collections.emptyMap());
     HiveClientPool clientPool1 = clientPool.clientPool();
     assertThat(clientPool1)
         .isSameAs(
             CachedClientPool.clientPoolCache()
-                .getIfPresent(CachedClientPool.extractKey(null, hiveConf)));
-    TimeUnit.MILLISECONDS.sleep(EVICTION_INTERVAL - 
TimeUnit.SECONDS.toMillis(2));
+                .getIfPresent(
+                    CachedClientPool.extractKey(null, 
HIVE_METASTORE_EXTENSION.hiveConf())));
+    TimeUnit.MILLISECONDS.sleep(TimeUnit.SECONDS.toMillis(10) - 
TimeUnit.SECONDS.toMillis(2));
     HiveClientPool clientPool2 = clientPool.clientPool();
     assertThat(clientPool2).isSameAs(clientPool1);
-    TimeUnit.MILLISECONDS.sleep(EVICTION_INTERVAL + 
TimeUnit.SECONDS.toMillis(5));
+    TimeUnit.MILLISECONDS.sleep(TimeUnit.SECONDS.toMillis(10) + 
TimeUnit.SECONDS.toMillis(5));

Review Comment:
   ah sorry, I didn't realize that `EVICTION_INTERVAL` is being used in 
multiple places. In that case it makes sense to add a constant



-- 
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

Reply via email to