[HUDI-4177] Fix hudi-cli rollback with rollbackUsingMarkers method call (#5734)
* Fix hudi-cli rollback with rollbackUsingMarkers method call * Add test for hudi-cli rollbackUsingMarkers Co-authored-by: Shawn Chang <yxchang@amazon.com>
This commit is contained in:
@@ -451,7 +451,7 @@ public class SparkMain {
|
||||
}
|
||||
|
||||
private static int rollback(JavaSparkContext jsc, String instantTime, String basePath, Boolean rollbackUsingMarkers) throws Exception {
|
||||
SparkRDDWriteClient client = createHoodieClient(jsc, basePath, rollbackUsingMarkers);
|
||||
SparkRDDWriteClient client = createHoodieClient(jsc, basePath, rollbackUsingMarkers, false);
|
||||
if (client.rollback(instantTime)) {
|
||||
LOG.info(String.format("The commit \"%s\" rolled back.", instantTime));
|
||||
return 0;
|
||||
|
||||
@@ -125,5 +125,22 @@ public class ITTestCommitsCommand extends HoodieCLIIntegrationTestBase {
|
||||
|
||||
HoodieActiveTimeline timeline2 = metaClient.reloadActiveTimeline();
|
||||
assertEquals(1, timeline2.getCommitsTimeline().countInstants(), "There should have 1 instants.");
|
||||
|
||||
// rollback with rollbackUsingMarkers==false
|
||||
CommandResult cr3 = getShell().executeCommand(
|
||||
String.format("commit rollback --commit %s --rollbackUsingMarkers false --sparkMaster %s --sparkMemory %s",
|
||||
"100", "local", "4G"));
|
||||
|
||||
assertAll("Command run failed",
|
||||
() -> assertTrue(cr3.isSuccess()),
|
||||
() -> assertEquals("Commit 100 rolled back", cr3.getResult().toString()));
|
||||
|
||||
metaClient = HoodieTableMetaClient.reload(HoodieCLI.getTableMetaClient());
|
||||
|
||||
HoodieActiveTimeline rollbackTimeline3 = new RollbacksCommand.RollbackTimeline(metaClient);
|
||||
assertEquals(3, rollbackTimeline3.getRollbackTimeline().countInstants(), "There should have 3 rollback instant.");
|
||||
|
||||
HoodieActiveTimeline timeline3 = metaClient.reloadActiveTimeline();
|
||||
assertEquals(0, timeline3.getCommitsTimeline().countInstants(), "There should have 0 instants.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user