veghlaci05 commented on code in PR #4497:
URL: https://github.com/apache/hive/pull/4497#discussion_r1288495413


##########
itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationCleanup.java:
##########
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.hive.hcatalog.listener;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.TimeUnit;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.hadoop.hive.cli.CliSessionState;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
+import org.apache.hadoop.hive.metastore.IMetaStoreClient;
+import org.apache.hadoop.hive.metastore.IMetaStoreClient.NotificationFilter;
+import org.apache.hadoop.hive.metastore.api.NotificationEventRequest;
+import org.apache.hadoop.hive.metastore.api.NotificationEventResponse;
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.messaging.MessageDeserializer;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder;
+import org.apache.hadoop.hive.ql.DriverFactory;
+import org.apache.hadoop.hive.ql.IDriver;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hive.hcatalog.api.repl.ReplicationV1CompatRule;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static 
org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars.EVENT_DB_LISTENER_CLEAN_STARTUP_WAIT_INTERVAL;
+
+
+
+public class TestDbNotificationCleanup {
+    private static final Logger LOG = 
LoggerFactory.getLogger(TestDbNotificationCleanup.class
+            .getName());
+    private static final int EVENTS_TTL = 30;
+    private static final int CLEANUP_SLEEP_TIME = 10;
+    private static Map<String, String> emptyParameters = new HashMap<String, 
String>();
+    private static IMetaStoreClient msClient;
+    private static IDriver driver;
+    private static MessageDeserializer md;
+    private static HiveConf conf;
+
+    private long firstEventId;
+    private final String testTempDir = 
Paths.get(System.getProperty("java.io.tmpdir"), "testDbNotif").toString();
+
+    private static List<String> testsToSkipForReplV1BackwardCompatTesting =
+            new ArrayList<>(Arrays.asList("cleanupNotifs", 
"cleanupNotificationWithError","skipCleanedUpEvents"));
+    // Make sure we skip backward-compat checking for those tests that don't 
generate events
+
+    private static ReplicationV1CompatRule bcompat = null;
+
+    @Rule
+    public TestRule replV1BackwardCompatibleRule = bcompat;

Review Comment:
   This entire section is not required. you set all 3 tests to skip, and there 
is no more tests in this class. as a result the rule can be simply removed.



##########
itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java:
##########
@@ -211,6 +203,11 @@ public void onAlterTable (AlterTableEvent tableEvent) 
throws MetaException {
       pushEventId(EventType.ALTER_TABLE, tableEvent);
     }
 
+    @Override
+    public void onAlterDatabase(AlterDatabaseEvent dbEvent) throws 
MetaException {
+      pushEventId(EventType.ALTER_DATABASE, dbEvent);
+    }
+

Review Comment:
   Why is this introduced?



##########
itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java:
##########
@@ -1584,69 +1510,39 @@ public void sqlInsertPartition() throws Exception {
 
     event = rsp.getEvents().get(12);
     assertEquals(firstEventId + 13, event.getEventId());
-    assertEquals(EventType.ADD_PARTITION.toString(), event.getEventType());
+    assertEquals(EventType.INSERT.toString(), event.getEventType());
 
     event = rsp.getEvents().get(13);
     assertEquals(firstEventId + 14, event.getEventId());
-    assertEquals(EventType.INSERT.toString(), event.getEventType());
-    // Parse the message field
-    verifyInsert(event, null, tblName);
+    assertEquals(EventType.ALTER_PARTITION.toString(), event.getEventType());

Review Comment:
   I have the same question here: I don't understand why the event types 
changed in the test. Why those are necessary?



##########
itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java:
##########
@@ -251,18 +248,6 @@ public void onInsert(InsertEvent insertEvent) throws 
MetaException {
       pushEventId(EventType.INSERT, insertEvent);
     }
 
-    public void onOpenTxn(OpenTxnEvent openTxnEvent) throws MetaException {
-      pushEventId(EventType.OPEN_TXN, openTxnEvent);
-    }
-
-    public void onCommitTxn(CommitTxnEvent commitTxnEvent) throws 
MetaException {
-      pushEventId(EventType.COMMIT_TXN, commitTxnEvent);
-    }
-
-    public void onAbortTxn(AbortTxnEvent abortTxnEvent) throws MetaException {
-      pushEventId(EventType.ABORT_TXN, abortTxnEvent);
-    }
-

Review Comment:
   Why these are removed? I can see that the open commit abort tests are moved 
to a new class, but those tests are not using this Mock class.



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