hudi-cli/src/test/java/org/apache/hudi/cli/integ/ITTestCommitsCommand.java
/**
   * Test case of 'commit rollback' command.
   */
Test case of 'commit rollback' command.
Test case of ' commit rollback ' command .
@Test
  public void testRollbackCommit() throws IOException {
    String commitTime1 = "100";
    String commitTime2 = "101";
    String commitTime3 = "102";
    HoodieTestDataGenerator.writePartitionMetadata(fs, HoodieTestDataGenerator.DEFAULT_PARTITION_PATHS, tablePath);
    HoodieTestUtils.createCommitFiles(tablePath, commitTime1, commitTime2, commitTime3);
    for (String commitTime : Arrays.asList(commitTime1, commitTime2, commitTime3)) {
      HoodieTestUtils.createDataFile(tablePath, HoodieTestDataGenerator.DEFAULT_FIRST_PARTITION_PATH, commitTime, "file-1");
      HoodieTestUtils.createDataFile(tablePath, HoodieTestDataGenerator.DEFAULT_SECOND_PARTITION_PATH, commitTime, "file-2");
      HoodieTestUtils.createDataFile(tablePath, HoodieTestDataGenerator.DEFAULT_THIRD_PARTITION_PATH, commitTime, "file-3");
    }
    CommandResult cr = getShell().executeCommand(String.format("commit rollback --commit %s --sparkMaster %s --sparkMemory %s",
        commitTime3, "local", "4G"));
    assertTrue(cr.isSuccess());
    metaClient = HoodieTableMetaClient.reload(HoodieCLI.getTableMetaClient());
    HoodieActiveTimeline rollbackTimeline = new RollbacksCommand.RollbackTimeline(metaClient);
    assertEquals(1, rollbackTimeline.getRollbackTimeline().countInstants(), "There should have 1 rollback instant.");
    HoodieActiveTimeline timeline = metaClient.reloadActiveTimeline();
    assertEquals(2, timeline.getCommitsTimeline().countInstants(), "There should have 2 instants.");
  }
@ Test public void testRollbackCommit ( ) throws IOException { String commitTime1 = "100" ; String commitTime2 = "101" ; String commitTime3 = "102" ; HoodieTestDataGenerator . writePartitionMetadata ( fs , HoodieTestDataGenerator . DEFAULT_PARTITION_PATHS , tablePath ) ; HoodieTestUtils . createCommitFiles ( tablePath , commitTime1 , commitTime2 , commitTime3 ) ; for ( String commitTime : Arrays . asList ( commitTime1 , commitTime2 , commitTime3 ) ) { HoodieTestUtils . createDataFile ( tablePath , HoodieTestDataGenerator . DEFAULT_FIRST_PARTITION_PATH , commitTime , "file-1" ) ; HoodieTestUtils . createDataFile ( tablePath , HoodieTestDataGenerator . DEFAULT_SECOND_PARTITION_PATH , commitTime , "file-2" ) ; HoodieTestUtils . createDataFile ( tablePath , HoodieTestDataGenerator . DEFAULT_THIRD_PARTITION_PATH , commitTime , "file-3" ) ; } CommandResult cr = getShell ( ) . executeCommand ( String . format ( "commit rollback --commit %s --sparkMaster %s --sparkMemory %s" , commitTime3 , "local" , "4G" ) ) ; assertTrue ( cr . isSuccess ( ) ) ; metaClient = HoodieTableMetaClient . reload ( HoodieCLI . getTableMetaClient ( ) ) ; HoodieActiveTimeline rollbackTimeline = new RollbacksCommand . RollbackTimeline ( metaClient ) ; assertEquals ( 1 , rollbackTimeline . getRollbackTimeline ( ) . countInstants ( ) , "There should have 1 rollback instant." ) ; HoodieActiveTimeline timeline = metaClient . reloadActiveTimeline ( ) ; assertEquals ( 2 , timeline . getCommitsTimeline ( ) . countInstants ( ) , "There should have 2 instants." ) ; }
Test case of 'commit rollback' command.
Test case of ' commit rollback ' command .
//Create some commits files and parquet files // three commit files // generate commit files for commits