abstractdog commented on code in PR #3556:
URL: https://github.com/apache/hive/pull/3556#discussion_r963615677


##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java:
##########
@@ -3306,22 +3314,38 @@ public void testJDOPersistanceManagerCleanup() throws 
Exception {
       return;
     }
 
-    int numObjectsBeforeClose =  getJDOPersistanceManagerCacheSize();
+    int numObjectsBeforeUse = getJDOPersistanceManagerCacheSize();
     HiveMetaStoreClient closingClient = new HiveMetaStoreClient(conf);
     closingClient.getAllDatabases();
     closingClient.close();
-    Thread.sleep(5 * 1000); // give HMS time to handle close request
-    int numObjectsAfterClose =  getJDOPersistanceManagerCacheSize();
-    assertTrue(numObjectsBeforeClose == numObjectsAfterClose);
 
+    MetastoreTestUtils.waitForAssertion("Checking pm cachesize after client 
close", new Runnable() {
+      @Override
+      public void run() {
+        int numObjectsAfterClose = getJDOPersistanceManagerCacheSize();
+        assertTrue(String.format("numObjectsBeforeUse: %d != 
numObjectsAfterClose: %d", numObjectsBeforeUse,
+            numObjectsAfterClose), numObjectsBeforeUse == 
numObjectsAfterClose);
+      }
+    }, 500, 30000);
+
+    int numObjectsAfterClose = getJDOPersistanceManagerCacheSize();
     HiveMetaStoreClient nonClosingClient = new HiveMetaStoreClient(conf);
     nonClosingClient.getAllDatabases();
     // Drop connection without calling close. HMS thread deleteContext
     // will trigger cleanup
     nonClosingClient.getTTransport().close();
-    Thread.sleep(5 * 1000);
-    int numObjectsAfterDroppedConnection =  
getJDOPersistanceManagerCacheSize();
-    assertTrue(numObjectsAfterClose == numObjectsAfterDroppedConnection);
+
+    MetastoreTestUtils.waitForAssertion("Checking pm cachesize after transport 
close", new Runnable() {
+      @Override
+      public void run() {
+        int numObjectsAfterDroppedConnection = 
getJDOPersistanceManagerCacheSize();
+        assertTrue(String.format("numObjectsAfterClose: %d != 
numObjectsAfterDroppedConnection: %d",
+            numObjectsAfterClose, numObjectsAfterDroppedConnection),
+            numObjectsAfterClose == numObjectsAfterDroppedConnection);
+      }
+    }, 500, 30000);

Review Comment:
   ack



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to