nsivabalan commented on code in PR #12568:
URL: https://github.com/apache/hudi/pull/12568#discussion_r1945256015


##########
hudi-client/hudi-client-common/src/test/java/org/apache/hudi/table/action/rollback/TestMarkerBasedRollbackStrategy.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.hudi.table.action.rollback;
+
+import org.apache.hudi.avro.model.HoodieRollbackRequest;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.engine.HoodieLocalEngineContext;
+import org.apache.hudi.common.model.IOType;
+import org.apache.hudi.common.table.HoodieTableVersion;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.storage.StoragePath;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static 
org.apache.hudi.common.testutils.FileCreateUtils.createLogFileMarker;
+import static 
org.apache.hudi.common.testutils.FileCreateUtils.createMarkerFile;
+import static 
org.apache.hudi.common.testutils.HoodieTestUtils.INSTANT_GENERATOR;
+import static 
org.apache.hudi.table.action.rollback.TestRollbackUtils.assertRollbackRequestListEquals;
+
+class TestMarkerBasedRollbackStrategy extends TestBaseRollbackHelper {
+  private static final int ROLLBACK_LOG_VERSION = 10;
+
+  @Override
+  @BeforeEach
+  void setup() throws IOException {
+    super.setup();
+  }
+
+  @ParameterizedTest
+  @ValueSource(strings = {"SIX", "EIGHT"})
+  void 
testGetRollbackRequestsWithMultipleLogFilesInOneFileGroup(HoodieTableVersion 
tableVersion) throws IOException {
+    prepareMetaClient(tableVersion);
+    HoodieEngineContext context = new 
HoodieLocalEngineContext(storage.getConf());
+    String rollbackInstantTime = "003";
+    String instantToRollbackTs = "002";
+    String baseInstantTimeOfLogFiles = "001";
+    String partition1 = "partition1";
+    String partition2 = "partition2";
+    String baseFileId1 = UUID.randomUUID().toString();
+    String baseFileId2 = UUID.randomUUID().toString();
+    String baseFileId3 = UUID.randomUUID().toString();
+    String logFileId1 = UUID.randomUUID().toString();
+    String logFileId2 = UUID.randomUUID().toString();
+    // Base files to roll back
+    StoragePath baseFilePath1 = createBaseFileAndMarkerToRollback(partition1, 
baseFileId1, instantToRollbackTs);
+    StoragePath baseFilePath2 = createBaseFileAndMarkerToRollback(partition2, 
baseFileId2, instantToRollbackTs);
+    StoragePath baseFilePath3 = createBaseFileAndMarkerToRollback(partition2, 
baseFileId3, instantToRollbackTs);
+    // Log files to roll back
+    Map<String, Long> logFilesToRollback1 = createLogFilesAndMarkersToRollback(
+        partition2, logFileId1, baseInstantTimeOfLogFiles, 
instantToRollbackTs, IntStream.of(1));
+    // Multiple rollback requests of log files belonging to the same file group
+    Map<String, Long> logFilesToRollback2 = IntStream.range(1, 
ROLLBACK_LOG_VERSION).boxed()
+        .flatMap(version -> createLogFilesAndMarkersToRollback(
+            partition2, logFileId2, baseInstantTimeOfLogFiles, 
instantToRollbackTs, IntStream.of(version))
+            .entrySet().stream())
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+    HoodieInstant instantToRollback = INSTANT_GENERATOR.createNewInstant(

Review Comment:
   sample instant generation



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

Reply via email to