-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-5032] Add archive to cli #7076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5ad7698
current progress
575ec89
Merge branch 'apache:master' into add_archive_to_cli
jonvex dd10eb8
latest changes
48afc1d
working now
defcf17
reverted wrong changes
23f04f9
got rid of debugging prints
116b090
got rid of commented line
82cc735
disabled metadata table
a2d3672
removed unused import
565b83f
added enableMetadata option
ccdb305
redid the command matching how the others used jsc
d4f5107
changed commitsRetained to commitsRetainedByCleaner
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestArchiveCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * 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.cli.commands; | ||
|
|
||
| import org.apache.hudi.cli.HoodieCLI; | ||
| import org.apache.hudi.cli.functional.CLIFunctionalTestHarness; | ||
| import org.apache.hudi.cli.testutils.HoodieTestCommitMetadataGenerator; | ||
| import org.apache.hudi.cli.testutils.ShellEvaluationResultUtil; | ||
| import org.apache.hudi.common.table.HoodieTableMetaClient; | ||
|
|
||
| import org.junit.jupiter.api.Tag; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.shell.Shell; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| @Tag("functional") | ||
| @SpringBootTest(properties = {"spring.shell.interactive.enabled=false", "spring.shell.command.script.enabled=false"}) | ||
| public class TestArchiveCommand extends CLIFunctionalTestHarness { | ||
|
|
||
| @Autowired | ||
| private Shell shell; | ||
|
|
||
| @Test | ||
| public void testArchiving() throws Exception { | ||
| HoodieCLI.conf = hadoopConf(); | ||
|
|
||
| // Create table and connect | ||
| String tableName = tableName(); | ||
| String tablePath = tablePath(tableName); | ||
|
|
||
| new TableCommand().createTable( | ||
| tablePath, tableName, | ||
| "COPY_ON_WRITE", "", 1, "org.apache.hudi.common.model.HoodieAvroPayload"); | ||
|
|
||
| HoodieTableMetaClient metaClient = HoodieCLI.getTableMetaClient(); | ||
|
|
||
| // Create six commits | ||
| for (int i = 100; i < 106; i++) { | ||
| String timestamp = String.valueOf(i); | ||
| HoodieTestCommitMetadataGenerator.createCommitFileWithMetadata(tablePath,timestamp, hadoopConf()); | ||
| } | ||
|
|
||
| Object cmdResult = shell.evaluate(() -> "trigger archival --minCommits 2 --maxCommits 3 --commitsRetained 1"); | ||
| assertTrue(ShellEvaluationResultUtil.isSuccess(cmdResult)); | ||
| metaClient = HoodieTableMetaClient.reload(metaClient); | ||
|
|
||
| //get instants in the active timeline only returns the latest state of the commit | ||
| //therefore we expect 2 instants because minCommits is 2 | ||
| assertEquals(2, metaClient.getActiveTimeline().getInstants().count()); | ||
|
|
||
| //get instants in the archived timeline returns all instants in the commit | ||
| //therefore we expect 12 instants because 6 commits - 2 commits in active timeline = 4 in archived | ||
| //since each commit is completed, there are 3 instances per commit (requested, inflight, completed) | ||
| //and 3 instances per commit * 4 commits = 12 instances | ||
| assertEquals(12, metaClient.getArchivedTimeline().getInstants().count()); | ||
| } | ||
|
|
||
| } | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.