pkumarsinha commented on a change in pull request #2529:
URL: https://github.com/apache/hive/pull/2529#discussion_r680520961



##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
##########
@@ -592,7 +577,8 @@ public void testFailoverDuringDumpWithPreviousFailed() 
throws Throwable {
     fs.delete(dumpAckFile, false);
 
     dumpData = primary.run("use " + primaryDbName)
-            .run("insert into t2 partition(name='Carl') values(10)")
+            .run("create table t3 (id int)")
+            .run("insert into t3 values (2)")

Review comment:
       insert into existing table as well. The table which has already part of 
repl and assert that the change is not there

##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
##########
@@ -621,6 +607,72 @@ public void testFailoverDuringDumpWithPreviousFailed() 
throws Throwable {
     assertTrue(MetaStoreUtils.isTargetOfReplication(db));
     assertTrue(MetaStoreUtils.isDbBeingFailedOverAtEndpoint(db, 
MetaStoreUtils.FailoverEndpoint.TARGET));
     assertTrue(fs.exists(new Path(dumpPath, 
ReplAck.LOAD_ACKNOWLEDGEMENT.toString())));
+
+    primary.run("drop database if exists " + primaryDbName + " cascade");
+
+    WarehouseInstance.Tuple reverseDumpData = replica.run("use " + 
replicatedDbName)
+            .run("create table t3 (id int)")
+            .run("insert into t3 values (2)")
+            .dump(replicatedDbName, retainPrevDumpDir);

Review comment:
       Add a test where hive.repl.retain.prev.dump.dir=true with retain count 
being 1

##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
##########
@@ -621,6 +607,72 @@ public void testFailoverDuringDumpWithPreviousFailed() 
throws Throwable {
     assertTrue(MetaStoreUtils.isTargetOfReplication(db));
     assertTrue(MetaStoreUtils.isDbBeingFailedOverAtEndpoint(db, 
MetaStoreUtils.FailoverEndpoint.TARGET));
     assertTrue(fs.exists(new Path(dumpPath, 
ReplAck.LOAD_ACKNOWLEDGEMENT.toString())));
+
+    primary.run("drop database if exists " + primaryDbName + " cascade");
+
+    WarehouseInstance.Tuple reverseDumpData = replica.run("use " + 
replicatedDbName)
+            .run("create table t3 (id int)")
+            .run("insert into t3 values (2)")

Review comment:
       insert different value as the last attempted one. e.g 10 or anything 
other than 2

##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
##########
@@ -621,6 +607,72 @@ public void testFailoverDuringDumpWithPreviousFailed() 
throws Throwable {
     assertTrue(MetaStoreUtils.isTargetOfReplication(db));
     assertTrue(MetaStoreUtils.isDbBeingFailedOverAtEndpoint(db, 
MetaStoreUtils.FailoverEndpoint.TARGET));
     assertTrue(fs.exists(new Path(dumpPath, 
ReplAck.LOAD_ACKNOWLEDGEMENT.toString())));
+
+    primary.run("drop database if exists " + primaryDbName + " cascade");
+
+    WarehouseInstance.Tuple reverseDumpData = replica.run("use " + 
replicatedDbName)
+            .run("create table t3 (id int)")
+            .run("insert into t3 values (2)")
+            .dump(replicatedDbName, retainPrevDumpDir);
+    assertNotEquals(reverseDumpData.dumpLocation, dumpData.dumpLocation);
+    assertTrue(fs.exists(dumpPath));
+    assertTrue(fs.exists(new Path(dumpPath, 
ReplAck.FAILOVER_READY_MARKER.toString())));
+    dumpPath = new Path(reverseDumpData.dumpLocation, 
ReplUtils.REPL_HIVE_BASE_DIR);
+    dumpAckFile = new Path(dumpPath, DUMP_ACKNOWLEDGEMENT.toString());
+    assertTrue(fs.exists(dumpAckFile));
+    assertFalse(fs.exists(new Path(dumpPath, 
ReplAck.FAILOVER_READY_MARKER.toString())));
+    assertTrue(new DumpMetaData(dumpPath, conf).getDumpType() == 
DumpType.BOOTSTRAP);
+    db = replica.getDatabase(replicatedDbName);
+    assertTrue(MetaStoreUtils.isDbBeingFailedOverAtEndpoint(db, 
MetaStoreUtils.FailoverEndpoint.TARGET));
+    assertFalse(MetaStoreUtils.isTargetOfReplication(db));
+
+    fs.delete(dumpAckFile, false);
+    assertFalse(fs.exists(dumpAckFile));
+    dumpData = replica.dump(replicatedDbName, retainPrevDumpDir);
+    assertEquals(reverseDumpData.dumpLocation, dumpData.dumpLocation);
+    assertFalse(fs.exists(new Path(dumpPath, 
ReplAck.FAILOVER_READY_MARKER.toString())));
+    assertTrue(new DumpMetaData(dumpPath, conf).getDumpType() == 
DumpType.BOOTSTRAP);
+    assertTrue(fs.exists(dumpAckFile));
+    db = replica.getDatabase(replicatedDbName);
+    assertTrue(MetaStoreUtils.isDbBeingFailedOverAtEndpoint(db, 
MetaStoreUtils.FailoverEndpoint.TARGET));
+    assertFalse(MetaStoreUtils.isTargetOfReplication(db));
+
+    primary.load(primaryDbName, replicatedDbName)
+            .run("use " + primaryDbName)
+            .run("show tables")
+            .verifyResults(new String[]{"t1", "t2", "t3"})
+            .run("repl status " + primaryDbName)
+            .verifyResult(dumpData.lastReplicationId)
+            .run("select id from t1")
+            .verifyResults(new String[]{"1"})
+            .run("select rank from t2 order by rank")
+            .verifyResults(new String[]{"11"})
+            .run("select id from t3")
+            .verifyResults(new String[]{"2"});
+
+    assertTrue(fs.exists(new Path(dumpPath, LOAD_ACKNOWLEDGEMENT.toString())));
+
+    reverseDumpData = replica.run("insert into t3 values (3)")
+            .dump(replicatedDbName, retainPrevDumpDir);
+    dumpPath = new Path(reverseDumpData.dumpLocation, 
ReplUtils.REPL_HIVE_BASE_DIR);
+    dumpAckFile = new Path(dumpPath, DUMP_ACKNOWLEDGEMENT.toString());
+    
assertFalse(MetaStoreUtils.isDbBeingFailedOverAtEndpoint(replica.getDatabase(replicatedDbName),
+            MetaStoreUtils.FailoverEndpoint.TARGET));
+    fs.delete(dumpAckFile);
+    replica.run("ALTER DATABASE " + replicatedDbName + " SET DBPROPERTIES('" + 
ReplConst.REPL_FAILOVER_ENDPOINT + "'='"
+            + MetaStoreUtils.FailoverEndpoint.TARGET + "')");
+    
assertTrue(MetaStoreUtils.isDbBeingFailedOverAtEndpoint(replica.getDatabase(replicatedDbName),
+            MetaStoreUtils.FailoverEndpoint.TARGET));
+    assertFalse(fs.exists(dumpAckFile));
+    assertEquals(reverseDumpData.dumpLocation, replica.dump(replicatedDbName, 
retainPrevDumpDir).dumpLocation);
+    fs.exists(dumpAckFile);
+    
assertFalse(MetaStoreUtils.isDbBeingFailedOverAtEndpoint(replica.getDatabase(replicatedDbName),
+            MetaStoreUtils.FailoverEndpoint.TARGET));
+
+    primary.load(primaryDbName, replicatedDbName)
+            .run("select id from t3")
+            .verifyResults(new String[]{"2", "3"});;
+    assertTrue(fs.exists(new Path(dumpPath, LOAD_ACKNOWLEDGEMENT.toString())));

Review comment:
       Can you please handle different failure use case in different tests.




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