haizhou-zhao commented on code in PR #11093:
URL: https://github.com/apache/iceberg/pull/11093#discussion_r1797440072


##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/TestBaseWithCatalog.java:
##########
@@ -59,18 +71,55 @@ protected static Object[][] parameters() {
   }
 
   @BeforeAll
-  public static void createWarehouse() throws IOException {
+  public static void setUpAll() throws IOException {
     TestBaseWithCatalog.warehouse = File.createTempFile("warehouse", null);
     assertThat(warehouse.delete()).isTrue();
+    startRESTServer();
   }
 
   @AfterAll
-  public static void dropWarehouse() throws IOException {
+  public static void tearDownAll() throws IOException {
     if (warehouse != null && warehouse.exists()) {
       Path warehousePath = new Path(warehouse.getAbsolutePath());
       FileSystem fs = warehousePath.getFileSystem(hiveConf);
       assertThat(fs.delete(warehousePath, true)).as("Failed to delete " + 
warehousePath).isTrue();
     }
+    stopRESTServer();
+  }
+
+  private static void startRESTServer() {
+    try {
+      restServer = new RESTCatalogServer();
+      // prevent using already-in-use port when testing
+      System.setProperty("rest.port", 
String.valueOf(MetaStoreUtils.findFreePort()));
+      System.setProperty(CatalogProperties.WAREHOUSE_LOCATION, 
warehouse.getAbsolutePath());
+      // In-memory sqlite database by default is private to the connection 
that created it.
+      // If more than 1 jdbc connection backed by in-memory sqlite is created 
behind one
+      // JdbcCatalog, then different jdbc connections could provide different 
views of table
+      // status even belonging to the same catalog. Reference:
+      // https://www.sqlite.org/inmemorydb.html
+      System.setProperty(CatalogProperties.CLIENT_POOL_SIZE, "1");
+      restServer.start(false);
+      restCatalog = RCKUtils.initCatalogClient();
+      System.clearProperty("rest.port");
+      System.clearProperty(CatalogProperties.WAREHOUSE_LOCATION);
+      System.clearProperty(CatalogProperties.CLIENT_POOL_SIZE);
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  private static void stopRESTServer() {

Review Comment:
   Done



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