This is an automated email from the ASF dual-hosted git repository.

zabetak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new a18ac1242d2 HIVE-28949: TestDbNotificationListener#createDatabase 
fails intermittently due to different createTime (#5811)
a18ac1242d2 is described below

commit a18ac1242d270153c3e807d00d7da076d878db97
Author: Stamatis Zampetakis <[email protected]>
AuthorDate: Mon May 19 13:52:00 2025 +0200

    HIVE-28949: TestDbNotificationListener#createDatabase fails intermittently 
due to different createTime (#5811)
    
    The test is problematic cause it sets explicitly the creation time and it 
expects the same to be returned in the notification message. However, the HMS 
always overrides the createTime (expected behavior according to tests added by 
HIVE-21077) field during the creation of the database so the initial value is 
lost. Slight delays (more than 1 second) between the initialization of the test 
and the creation of the database are causing the test to fail. The test is more 
likely to fail in CI [...]
---
 .../hive/hcatalog/listener/TestDbNotificationListener.java  | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git 
a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
 
b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
index de37e9f2701..ae588d8b93f 100644
--- 
a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
+++ 
b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
@@ -344,7 +344,6 @@ public void createDatabase() throws Exception {
     String dbDescription = "no description";
     Database db = new Database(dbName, dbDescription, dbLocationUri, 
emptyParameters);
     db.setOwnerName("test_user");
-    db.setCreateTime(startTime);
     msClient.createDatabase(db);
 
     // Read notification from metastore
@@ -362,7 +361,7 @@ public void createDatabase() throws Exception {
     // Parse the message field
     CreateDatabaseMessage createDbMsg = 
md.getCreateDatabaseMessage(event.getMessage());
     assertEquals(dbName, createDbMsg.getDB());
-    assertEquals(db, createDbMsg.getDatabaseObject());
+    assertEqualsSansTime(db, createDbMsg.getDatabaseObject());
 
     // Verify the eventID was passed to the non-transactional listener
     
MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.CREATE_DATABASE, 
firstEventId + 1);
@@ -1680,6 +1679,16 @@ public void sqlInsertPartition() throws Exception {
     testEventCounts(defaultDbName, firstEventId, firstEventId + 100, 50, 31);
   }
 
+  /**
+   * Asserts that two database objects are equals ignoring the creation time. 
If not an {@link AssertionError} is thrown.
+   * The creation time of the database is overridden internally by the HMS 
server thus not predictable.
+   */
+  private static void assertEqualsSansTime(Database expected, Database actual) 
{
+    Database copy = expected.deepCopy();
+    copy.setCreateTime(actual.getCreateTime());
+    assertEquals(copy, actual);
+  }
+
   private void verifyInsert(NotificationEvent event, String dbName, String 
tblName) throws Exception {
     // Parse the message field
     InsertMessage insertMsg = md.getInsertMessage(event.getMessage());

Reply via email to