aasha commented on a change in pull request #1593:
URL: https://github.com/apache/hive/pull/1593#discussion_r519578373
##########
File path:
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
##########
@@ -2162,6 +2164,149 @@ public void testConfiguredDeleteOfPrevDumpDir() throws
IOException {
verifySetupSteps = verifySetupOriginal;
}
+ @Test
+ public void testReplConfiguredCleanupOfNotificationEvents() throws Exception
{
+
+ boolean verifySetupOriginal = verifySetupSteps;
+ verifySetupSteps = true;
+ final int CLEANER_TTL_SECONDS = 1;
+ final int CLEANER_INTERVAL_SECONDS = 1;
+ String nameOfTest = testName.getMethodName();
+ String dbName = createDB(nameOfTest, driver);
+ String replDbName = dbName + "_dupe";
+
+ run("CREATE TABLE " + dbName + ".unptned(a string) STORED AS TEXTFILE",
driver);
+ run("CREATE TABLE " + dbName + ".ptned(a string) partitioned by (b int)
STORED AS TEXTFILE", driver);
+
+ //bootstrap
+ bootstrapLoadAndVerify(dbName, replDbName);
+
+ String[] unptnData = new String[] {"eleven", "twelve"};
+ String[] ptnData1 = new String[] {"thirteen", "fourteen", "fifteen"};
+ String[] ptnData2 = new String[] {"fifteen", "sixteen", "seventeen"};
+ String[] empty = new String[] {};
+
+ String unptnLocn = new Path(TEST_PATH, nameOfTest +
"_unptn").toUri().getPath();
+ String ptnLocn1 = new Path(TEST_PATH, nameOfTest +
"_ptn1").toUri().getPath();
+ String ptnLocn2 = new Path(TEST_PATH, nameOfTest +
"_ptn2").toUri().getPath();
+
+ createTestDataFile(unptnLocn, unptnData);
+ createTestDataFile(ptnLocn1, ptnData1);
+ createTestDataFile(ptnLocn2, ptnData2);
+
+ run("LOAD DATA LOCAL INPATH '" + unptnLocn + "' OVERWRITE INTO TABLE " +
dbName + ".unptned", driver);
+ verifySetup("SELECT * from " + dbName + ".unptned", unptnData, driver);
+ run("CREATE TABLE " + dbName + ".unptned_late LIKE " + dbName +
".unptned", driver);
+ run("INSERT INTO TABLE " + dbName + ".unptned_late SELECT * FROM " +
dbName + ".unptned", driver);
+ verifySetup("SELECT * from " + dbName + ".unptned_late", unptnData,
driver);
+
+ // CM was enabled during setup, REPL_EVENT_DB_LISTENER_TTL should be used,
set the other one to a low value
+ MetastoreConf.setTimeVar(hconf,
MetastoreConf.ConfVars.EVENT_DB_LISTENER_TTL, CLEANER_TTL_SECONDS,
TimeUnit.SECONDS);
+ MetastoreConf.setTimeVar(hconf,
MetastoreConf.ConfVars.EVENT_DB_LISTENER_CLEAN_INTERVAL,
CLEANER_INTERVAL_SECONDS, TimeUnit.SECONDS);
+ DbNotificationListener.resetCleaner(hconf);
+
+ //sleep to ensure correct conf(REPL_EVENT_DB_LISTENER_TTL) is used
+ try {
+ Thread.sleep(CLEANER_INTERVAL_SECONDS * 1000 * 10);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ //verify events get replicated
+ Tuple incrDump = replDumpDb(dbName);
+ loadAndVerify(replDbName, dbName, incrDump.lastReplId);
+ verifyRun("SELECT * from " + replDbName + ".unptned", unptnData,
driverMirror);
+ verifyRun("SELECT * from " + replDbName + ".unptned_late", unptnData,
driverMirror);
+
+
+ // For next run, CM is enabled, set REPL_EVENT_DB_LISTENER_TTL to low
value for events to get deleted
+ MetastoreConf.setTimeVar(hconf,
MetastoreConf.ConfVars.EVENT_DB_LISTENER_TTL, CLEANER_TTL_SECONDS * 60 * 60,
TimeUnit.SECONDS);
+ MetastoreConf.setTimeVar(hconf,
MetastoreConf.ConfVars.REPL_EVENT_DB_LISTENER_TTL, CLEANER_TTL_SECONDS ,
TimeUnit.SECONDS);
+ MetastoreConf.setTimeVar(hconf,
MetastoreConf.ConfVars.EVENT_DB_LISTENER_CLEAN_INTERVAL,
CLEANER_INTERVAL_SECONDS, TimeUnit.SECONDS);
Review comment:
this can be removed
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]