yuqi1129 commented on code in PR #3975:
URL: https://github.com/apache/gravitino/pull/3975#discussion_r1665227948


##########
catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/TestHadoopCatalogOperations.java:
##########
@@ -118,28 +130,66 @@ public PropertiesMetadata topicPropertiesMetadata() 
throws UnsupportedOperationE
   @BeforeAll
   public static void setUp() {
     Config config = Mockito.mock(Config.class);
-    Mockito.when(config.get(ENTITY_STORE)).thenReturn("kv");
-    
Mockito.when(config.get(ENTITY_KV_STORE)).thenReturn(DEFAULT_ENTITY_KV_STORE);
-    Mockito.when(config.get(Configs.ENTITY_SERDE)).thenReturn("proto");
-    
Mockito.when(config.get(ENTITY_KV_ROCKSDB_BACKEND_PATH)).thenReturn(ROCKS_DB_STORE_PATH);
-
-    Assertions.assertEquals(ROCKS_DB_STORE_PATH, 
config.get(ENTITY_KV_ROCKSDB_BACKEND_PATH));
-    
Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);
-    Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 
1000L);
+    when(config.get(ENTITY_STORE)).thenReturn(RELATIONAL_ENTITY_STORE);
+    
when(config.get(ENTITY_RELATIONAL_STORE)).thenReturn(DEFAULT_ENTITY_RELATIONAL_STORE);
+    
when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_PATH)).thenReturn(STORE_PATH);
+
+    // The following properties are used to create the JDBC connection; they 
are just for test, in
+    // the real world,
+    // they will be set automatically by the configuration file if you set 
ENTITY_RELATIONAL_STORE
+    // as EMBEDDED_ENTITY_RELATIONAL_STORE.
+    when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_URL))
+        .thenReturn(String.format("jdbc:h2:%s;DB_CLOSE_DELAY=-1;MODE=MYSQL", 
STORE_PATH));
+    
when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_USER)).thenReturn("gravitino");
+    
when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_PASSWORD)).thenReturn("gravitino");
+    
when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_DRIVER)).thenReturn("org.h2.Driver");
+
+    File f = FileUtils.getFile(STORE_PATH);
+    f.deleteOnExit();
+
+    when(config.get(VERSION_RETENTION_COUNT)).thenReturn(1L);
+    when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);
+    when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);
+    when(config.get(ENTITY_SERDE)).thenReturn("proto");
 
     store = EntityStoreFactory.createEntityStore(config);
     store.initialize(config);
-    store.setSerDe(EntitySerDeFactory.createEntitySerDe(config));
     idGenerator = new RandomIdGenerator();
+
+    // Mock
+    MetalakeMetaService metalakeMetaService = 
MetalakeMetaService.getInstance();
+    MetalakeMetaService spyMetaservice = Mockito.spy(metalakeMetaService);
+    doReturn(1L).when(spyMetaservice).getMetalakeIdByName(Mockito.anyString());
+
+    CatalogMetaService catalogMetaService = CatalogMetaService.getInstance();
+    CatalogMetaService spyCatalogMetaService = Mockito.spy(catalogMetaService);
+    doReturn(1L)
+        .when(spyCatalogMetaService)
+        .getCatalogIdByMetalakeIdAndName(Mockito.anyLong(), 
Mockito.anyString());
+
+    MockedStatic<MetalakeMetaService> metalakeMetaServiceMockedStatic =
+        Mockito.mockStatic(MetalakeMetaService.class);
+    MockedStatic<CatalogMetaService> catalogMetaServiceMockedStatic =
+        Mockito.mockStatic(CatalogMetaService.class);
+
+    metalakeMetaServiceMockedStatic
+        .when(MetalakeMetaService::getInstance)
+        .thenReturn(spyMetaservice);
+    catalogMetaServiceMockedStatic
+        .when(CatalogMetaService::getInstance)
+        .thenReturn(spyCatalogMetaService);
   }
 
   @AfterAll
   public static void tearDown() throws IOException {
     store.close();
-    FileUtils.deleteDirectory(FileUtils.getFile(ROCKS_DB_STORE_PATH));
     new Path(TEST_ROOT_PATH)
         .getFileSystem(new Configuration())
         .delete(new Path(TEST_ROOT_PATH), true);
+
+    File f = FileUtils.getFile(H2_file);
+    System.gc();

Review Comment:
   This is for testing the removal process, I have removed the code. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to