the-other-tim-brown commented on code in PR #13098:
URL: https://github.com/apache/hudi/pull/13098#discussion_r2033918587


##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/io/TestHoodieTimelineArchiver.java:
##########
@@ -742,6 +745,48 @@ public void testReadArchivedCompactionPlan() throws 
Exception {
     }
   }
 
+  @Test
+  public void testDowngradeArchivedTimeline() throws Exception {
+    HoodieWriteConfig writeConfig = initTestTableAndGetWriteConfig(true, 1, 2, 
5, HoodieTableType.COPY_ON_WRITE);
+
+    // do ingestion and trigger archive actions here.
+    Map<String, Integer> cleanStats = new HashMap<>();
+    cleanStats.put("p1", 1);
+    cleanStats.put("p2", 2);
+    for (int i = 1; i < 15; i += 2) {
+      if (i == 3) {
+        testTable.doRollback(String.format("%08d", 1), String.format("%08d", 
3));
+      } else if (i == 5) {
+        testTable.doCluster(String.format("%08d", i), Collections.emptyMap(), 
Arrays.asList("p1", "p2"), 20);
+      } else if (i == 7) {
+        testTable.doCompaction(String.format("%08d", i), Arrays.asList("p1", 
"p2"));
+      } else {
+        testTable.doWriteOperation(String.format("%08d", i), 
WriteOperationType.UPSERT, i == 1 ? Arrays.asList("p1", "p2") : 
Collections.emptyList(), Arrays.asList("p1", "p2"), 2);
+        testTable.doClean(String.format("%08d", i + 1), cleanStats, 
Collections.emptyMap());
+      }
+    }
+    archiveAndGetCommitsList(writeConfig);
+    // loading archived timeline instants
+    HoodieArchivedTimeline archivedTimeLine = metaClient.getArchivedTimeline();
+    archivedTimeLine.loadCompletedInstantDetailsInMemory();
+
+    // Downgrade to table version 6
+    new UpgradeDowngrade(metaClient, writeConfig, context, 
SparkUpgradeDowngradeHelper.getInstance())
+        .run(HoodieTableVersion.SIX, null);
+    metaClient = HoodieTableMetaClient.reload(metaClient);
+    HoodieTimeline downgradedArchivedTimeline = 
metaClient.getArchivedTimeline();
+    metaClient.getArchivedTimeline().loadCompletedInstantDetailsInMemory();
+    // verify that commits till 11th instant are all archived
+    for (int i = 1; i < 13; i += 2) {

Review Comment:
   why +=2 here?



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