You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/04/06 15:38:43 UTC

[GitHub] [incubator-hudi] hddong opened a new pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

hddong opened a new pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490
 
 
   ## *Tips*
   - *Thank you very much for contributing to Apache Hudi.*
   - *Please review https://hudi.apache.org/contributing.html before opening a pull request.*
   
   ## What is the purpose of the pull request
   
   *Add unit test for FileSystemViewCommand*
   
   ## Brief change log
   
   *(for example:)*
     - *Add unit test for FileSystemViewCommand*
   
   ## Verify this pull request
   
   This pull request is a trivial rework / code cleanup without any test coverage.
   
   ## Committer checklist
   
    - [ ] Has a corresponding JIRA in PR title & commit
    
    - [ ] Commit message is descriptive of the change
    
    - [ ] CI is green
   
    - [ ] Necessary doc changes done or have another open PR
          
    - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] hddong commented on issue #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
hddong commented on issue #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#issuecomment-610298123
 
 
   @yanghua @vinothchandar please have a review.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r405987783
 
 

 ##########
 File path: hudi-cli/src/main/java/org/apache/hudi/cli/HoodieTableHeaderConfig.java
 ##########
 @@ -0,0 +1,56 @@
+/*
+ * 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;
+
+/**
+ * Config for table header.
+ */
+public class HoodieTableHeaderConfig {
 
 Review comment:
   Actually, I am thinking if the keyword `Config` is a good one. It seems this class only defines some config keys or say table header field names? So what about renaming it to `HoodieTableHeaderFields` or `HoodieTableHeaderConfigKeys`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r405983225
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,245 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.shell.core.CommandResult;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.Stream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test class for {@link FileSystemViewCommand}.
+ */
+public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
+  private String tablePath;
+  private String partitionPath;
+  private SyncableFileSystemView fsView;
+
+  private static String TEST_WRITE_TOKEN = "1-0-1";
+
+  @Before
+  public void init() throws IOException {
+    HoodieCLI.conf = jsc.hadoopConfiguration();
+
+    // Create table and connect
+    String tableName = "test_table";
+    tablePath = basePath + File.separator + tableName;
+    new TableCommand().createTable(
+        tablePath, tableName,
+        "COPY_ON_WRITE", "", 1, "org.apache.hudi.common.model.HoodieAvroPayload");
+
+    metaClient = HoodieCLI.getTableMetaClient();
+
+    partitionPath = HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH;
+    String fullPartitionPath = tablePath + "/" + partitionPath;
+    new File(fullPartitionPath).mkdirs();
+
+    // Generate 2 commits
+    String commitTime1 = "1";
+    String commitTime2 = "2";
+
+    String fileId1 = UUID.randomUUID().toString();
+
+    // Write date files and log file
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime1, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime1, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime2, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime2, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+
+    // Write commit files
+    new File(tablePath + "/.hoodie/" + commitTime1 + ".commit").createNewFile();
+    new File(tablePath + "/.hoodie/" + commitTime2 + ".commit").createNewFile();
+
+    // Reload meta client and create fsView
+    metaClient = HoodieTableMetaClient.reload(metaClient);
+
+    fsView = new HoodieTableFileSystemView(metaClient, metaClient.getActiveTimeline(), true);
+  }
+
+  /**
+   * Test case for 'show fsview all'.
+   */
+  @Test
+  public void testShowCommits() {
+    // Test default show fsview all
+    CommandResult cr = getShell().executeCommand("show fsview all");
 
 Review comment:
   OK, sounds reasonable.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r405371789
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,245 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.shell.core.CommandResult;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.Stream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test class for {@link FileSystemViewCommand}.
+ */
+public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
+  private String tablePath;
 
 Review comment:
   Can we convert this field into a local variable?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r405375896
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,245 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.shell.core.CommandResult;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.Stream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test class for {@link FileSystemViewCommand}.
+ */
+public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
+  private String tablePath;
+  private String partitionPath;
+  private SyncableFileSystemView fsView;
+
+  private static String TEST_WRITE_TOKEN = "1-0-1";
+
+  @Before
+  public void init() throws IOException {
+    HoodieCLI.conf = jsc.hadoopConfiguration();
+
+    // Create table and connect
+    String tableName = "test_table";
+    tablePath = basePath + File.separator + tableName;
+    new TableCommand().createTable(
+        tablePath, tableName,
+        "COPY_ON_WRITE", "", 1, "org.apache.hudi.common.model.HoodieAvroPayload");
+
+    metaClient = HoodieCLI.getTableMetaClient();
+
+    partitionPath = HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH;
+    String fullPartitionPath = tablePath + "/" + partitionPath;
+    new File(fullPartitionPath).mkdirs();
+
+    // Generate 2 commits
+    String commitTime1 = "1";
+    String commitTime2 = "2";
+
+    String fileId1 = UUID.randomUUID().toString();
+
+    // Write date files and log file
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime1, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime1, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime2, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime2, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+
+    // Write commit files
+    new File(tablePath + "/.hoodie/" + commitTime1 + ".commit").createNewFile();
+    new File(tablePath + "/.hoodie/" + commitTime2 + ".commit").createNewFile();
+
+    // Reload meta client and create fsView
+    metaClient = HoodieTableMetaClient.reload(metaClient);
+
+    fsView = new HoodieTableFileSystemView(metaClient, metaClient.getActiveTimeline(), true);
+  }
+
+  /**
+   * Test case for 'show fsview all'.
+   */
+  @Test
+  public void testShowCommits() {
+    // Test default show fsview all
+    CommandResult cr = getShell().executeCommand("show fsview all");
 
 Review comment:
   ditto

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] smarthi commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
smarthi commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r404454081
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,244 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+import org.junit.Before;
 
 Review comment:
   Line Break 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r405986687
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,255 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.HoodieTableHeaderConfig;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.shell.core.CommandResult;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.Stream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test class for {@link FileSystemViewCommand}.
+ */
+public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
+  private String partitionPath;
+  private SyncableFileSystemView fsView;
+
+  @Before
+  public void init() throws IOException {
+    HoodieCLI.conf = jsc.hadoopConfiguration();
+
+    // Create table and connect
+    String tableName = "test_table";
+    String tablePath = basePath + File.separator + tableName;
+    new TableCommand().createTable(
+        tablePath, tableName,
+        "COPY_ON_WRITE", "", 1, "org.apache.hudi.common.model.HoodieAvroPayload");
+
+    metaClient = HoodieCLI.getTableMetaClient();
+
+    partitionPath = HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH;
+    String fullPartitionPath = tablePath + "/" + partitionPath;
+    new File(fullPartitionPath).mkdirs();
+
+    // Generate 2 commits
+    String commitTime1 = "1";
+    String commitTime2 = "2";
+
+    String fileId1 = UUID.randomUUID().toString();
+
+    // Write date files and log file
+    String testWriteToken = "1-0-1";
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime1, testWriteToken, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime1, 0, testWriteToken))
+        .createNewFile();
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime2, testWriteToken, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime2, 0, testWriteToken))
+        .createNewFile();
+
+    // Write commit files
+    new File(tablePath + "/.hoodie/" + commitTime1 + ".commit").createNewFile();
+    new File(tablePath + "/.hoodie/" + commitTime2 + ".commit").createNewFile();
+
+    // Reload meta client and create fsView
+    metaClient = HoodieTableMetaClient.reload(metaClient);
+
+    fsView = new HoodieTableFileSystemView(metaClient, metaClient.getActiveTimeline(), true);
+  }
+
+  /**
+   * Test case for 'show fsview all'.
+   */
+  @Test
+  public void testShowCommits() {
+    // Test default show fsview all
+    CommandResult cr = getShell().executeCommand("show fsview all");
+    assertTrue(cr.isSuccess());
+
+    // Get all file groups
+    Stream<HoodieFileGroup> fileGroups = fsView.getAllFileGroups(partitionPath);
+
+    List<Comparable[]> rows = new ArrayList<>();
+    fileGroups.forEach(fg -> fg.getAllFileSlices().forEach(fs -> {
+      int idx = 0;
+      // For base file only Views, do not display any delta-file related columns
+      Comparable[] row = new Comparable[8];
+      row[idx++] = fg.getPartitionPath();
+      row[idx++] = fg.getFileGroupId().getFileId();
+      row[idx++] = fs.getBaseInstantTime();
+      row[idx++] = fs.getBaseFile().isPresent() ? fs.getBaseFile().get().getPath() : "";
+      row[idx++] = fs.getBaseFile().isPresent() ? fs.getBaseFile().get().getFileSize() : -1;
+      row[idx++] = fs.getLogFiles().count();
+      row[idx++] = fs.getLogFiles().mapToLong(HoodieLogFile::getFileSize).sum();
+      row[idx++] = fs.getLogFiles().collect(Collectors.toList()).toString();
+      rows.add(row);
+    }));
+
+    Function<Object, String> converterFunction =
+        entry -> NumericUtils.humanReadableByteCount((Double.parseDouble(entry.toString())));
+    Map<String, Function<Object, String>> fieldNameToConverterMap = new HashMap<>();
+    fieldNameToConverterMap.put(HoodieTableHeaderConfig.HEADER_TOTAL_DELTA_FILE_SIZE, converterFunction);
+    fieldNameToConverterMap.put(HoodieTableHeaderConfig.HEADER_DATA_FILE_SIZE, converterFunction);
+
+    TableHeader header = new TableHeader().addTableHeaderField(HoodieTableHeaderConfig.HEADER_PARTITION)
+        .addTableHeaderField(HoodieTableHeaderConfig.HEADER_FILE_ID)
+        .addTableHeaderField(HoodieTableHeaderConfig.HEADER_BASE_INSTANT)
+        .addTableHeaderField(HoodieTableHeaderConfig.HEADER_DATA_FILE)
+        .addTableHeaderField(HoodieTableHeaderConfig.HEADER_DATA_FILE_SIZE)
+        .addTableHeaderField(HoodieTableHeaderConfig.HEADER_NUM_DELTA_FILES)
+        .addTableHeaderField(HoodieTableHeaderConfig.HEADER_TOTAL_DELTA_FILE_SIZE)
+        .addTableHeaderField(HoodieTableHeaderConfig.HEADER_DELTA_FILES);
+    String expected = HoodiePrintHelper.print(header, fieldNameToConverterMap, "", false, -1, false, rows);
+    assertEquals(expected, cr.getResult().toString());
+
+    // Test command with options, baseFileOnly and maxInstant is 2
+    cr = getShell().executeCommand("show fsview all --baseFileOnly true --maxInstant 2");
 
 Review comment:
   Can we break this command into a new test case? I always suggest one test method verify one thing. Additionally, this method seems a bit long.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r405372064
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,245 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.shell.core.CommandResult;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.Stream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test class for {@link FileSystemViewCommand}.
+ */
+public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
+  private String tablePath;
+  private String partitionPath;
+  private SyncableFileSystemView fsView;
+
+  private static String TEST_WRITE_TOKEN = "1-0-1";
 
 Review comment:
   ditto

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] hddong commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
hddong commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r405921464
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,245 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.shell.core.CommandResult;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.Stream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test class for {@link FileSystemViewCommand}.
+ */
+public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
+  private String tablePath;
+  private String partitionPath;
+  private SyncableFileSystemView fsView;
+
+  private static String TEST_WRITE_TOKEN = "1-0-1";
+
+  @Before
+  public void init() throws IOException {
+    HoodieCLI.conf = jsc.hadoopConfiguration();
+
+    // Create table and connect
+    String tableName = "test_table";
+    tablePath = basePath + File.separator + tableName;
+    new TableCommand().createTable(
+        tablePath, tableName,
+        "COPY_ON_WRITE", "", 1, "org.apache.hudi.common.model.HoodieAvroPayload");
+
+    metaClient = HoodieCLI.getTableMetaClient();
+
+    partitionPath = HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH;
+    String fullPartitionPath = tablePath + "/" + partitionPath;
+    new File(fullPartitionPath).mkdirs();
+
+    // Generate 2 commits
+    String commitTime1 = "1";
+    String commitTime2 = "2";
+
+    String fileId1 = UUID.randomUUID().toString();
+
+    // Write date files and log file
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime1, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime1, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime2, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime2, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+
+    // Write commit files
+    new File(tablePath + "/.hoodie/" + commitTime1 + ".commit").createNewFile();
+    new File(tablePath + "/.hoodie/" + commitTime2 + ".commit").createNewFile();
+
+    // Reload meta client and create fsView
+    metaClient = HoodieTableMetaClient.reload(metaClient);
+
+    fsView = new HoodieTableFileSystemView(metaClient, metaClient.getActiveTimeline(), true);
+  }
+
+  /**
+   * Test case for 'show fsview all'.
+   */
+  @Test
+  public void testShowCommits() {
+    // Test default show fsview all
+    CommandResult cr = getShell().executeCommand("show fsview all");
 
 Review comment:
   > ditto
   
   @yanghua IMO, it is better to reuse title string like `Total Delta File Size`. Command string (`show fsview all`) maybe better to keep it the way it is, here and in `FileSystemViewCommand`, easier and clearer to known which command to run.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] codecov-io commented on issue #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#issuecomment-610166379
 
 
   # [Codecov](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=h1) Report
   > Merging [#1490](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-hudi/commit/c146ca90fdd102f2bda90a2b15f6aef56414f9f4&el=desc) will **increase** coverage by `3.92%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-hudi/pull/1490/graphs/tree.svg?width=650&height=150&src=pr&token=VTTXabwbs2)](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1490      +/-   ##
   ============================================
   + Coverage     67.64%   71.57%   +3.92%     
     Complexity      261      261              
   ============================================
     Files           348      336      -12     
     Lines         16672    15744     -928     
     Branches       1694     1610      -84     
   ============================================
   - Hits          11278    11268      -10     
   + Misses         4653     3755     -898     
   + Partials        741      721      -20     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...ache/hudi/common/fs/inline/InMemoryFileSystem.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL2ZzL2lubGluZS9Jbk1lbW9yeUZpbGVTeXN0ZW0uamF2YQ==) | `79.31% <0.00%> (-10.35%)` | `0.00% <0.00%> (ø%)` | |
   | [.../org/apache/hudi/table/HoodieMergeOnReadTable.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvSG9vZGllTWVyZ2VPblJlYWRUYWJsZS5qYXZh) | `83.12% <0.00%> (-2.50%)` | `0.00% <0.00%> (ø%)` | |
   | [...i/utilities/deltastreamer/HoodieDeltaStreamer.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL2RlbHRhc3RyZWFtZXIvSG9vZGllRGVsdGFTdHJlYW1lci5qYXZh) | `78.60% <0.00%> (-1.60%)` | `8.00% <0.00%> (ø%)` | |
   | [...in/java/org/apache/hudi/metrics/HoodieMetrics.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvbWV0cmljcy9Ib29kaWVNZXRyaWNzLmphdmE=) | `86.53% <0.00%> (-0.97%)` | `0.00% <0.00%> (ø%)` | |
   | [.../org/apache/hudi/table/HoodieCopyOnWriteTable.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvSG9vZGllQ29weU9uV3JpdGVUYWJsZS5qYXZh) | `89.28% <0.00%> (-0.66%)` | `0.00% <0.00%> (ø%)` | |
   | [...java/org/apache/hudi/client/HoodieWriteClient.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY2xpZW50L0hvb2RpZVdyaXRlQ2xpZW50LmphdmE=) | `69.23% <0.00%> (-0.55%)` | `0.00% <0.00%> (ø%)` | |
   | [.../apache/hudi/client/AbstractHoodieWriteClient.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY2xpZW50L0Fic3RyYWN0SG9vZGllV3JpdGVDbGllbnQuamF2YQ==) | `74.15% <0.00%> (-0.29%)` | `0.00% <0.00%> (ø%)` | |
   | [...n/java/org/apache/hudi/common/model/HoodieKey.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL0hvb2RpZUtleS5qYXZh) | `88.88% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...java/org/apache/hudi/common/util/CleanerUtils.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL3V0aWwvQ2xlYW5lclV0aWxzLmphdmE=) | `95.65% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...ache/hudi/utilities/HoodieCompactionAdminTool.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL0hvb2RpZUNvbXBhY3Rpb25BZG1pblRvb2wuamF2YQ==) | | | |
   | ... and [40 more](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=footer). Last update [c146ca9...1fd2d8b](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] codecov-io edited a comment on issue #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#issuecomment-610166379
 
 
   # [Codecov](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=h1) Report
   > Merging [#1490](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-hudi/commit/c146ca90fdd102f2bda90a2b15f6aef56414f9f4&el=desc) will **increase** coverage by `3.99%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-hudi/pull/1490/graphs/tree.svg?width=650&height=150&src=pr&token=VTTXabwbs2)](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1490      +/-   ##
   ============================================
   + Coverage     67.64%   71.64%   +3.99%     
   - Complexity      261      288      +27     
   ============================================
     Files           348      338      -10     
     Lines         16672    15931     -741     
     Branches       1694     1625      -69     
   ============================================
   + Hits          11278    11413     +135     
   + Misses         4653     3785     -868     
   + Partials        741      733       -8     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [.../org/apache/hudi/table/HoodieMergeOnReadTable.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvSG9vZGllTWVyZ2VPblJlYWRUYWJsZS5qYXZh) | `83.12% <0.00%> (-2.50%)` | `0.00% <0.00%> (ø%)` | |
   | [...i/utilities/deltastreamer/HoodieDeltaStreamer.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL2RlbHRhc3RyZWFtZXIvSG9vZGllRGVsdGFTdHJlYW1lci5qYXZh) | `78.77% <0.00%> (-1.43%)` | `10.00% <0.00%> (+2.00%)` | :arrow_down: |
   | [...in/java/org/apache/hudi/metrics/HoodieMetrics.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvbWV0cmljcy9Ib29kaWVNZXRyaWNzLmphdmE=) | `86.53% <0.00%> (-0.97%)` | `0.00% <0.00%> (ø%)` | |
   | [.../org/apache/hudi/table/HoodieCopyOnWriteTable.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvSG9vZGllQ29weU9uV3JpdGVUYWJsZS5qYXZh) | `89.28% <0.00%> (-0.66%)` | `0.00% <0.00%> (ø%)` | |
   | [...java/org/apache/hudi/client/HoodieWriteClient.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY2xpZW50L0hvb2RpZVdyaXRlQ2xpZW50LmphdmE=) | `69.23% <0.00%> (-0.55%)` | `0.00% <0.00%> (ø%)` | |
   | [.../apache/hudi/client/AbstractHoodieWriteClient.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY2xpZW50L0Fic3RyYWN0SG9vZGllV3JpdGVDbGllbnQuamF2YQ==) | `74.15% <0.00%> (-0.29%)` | `0.00% <0.00%> (ø%)` | |
   | [...apache/hudi/utilities/deltastreamer/DeltaSync.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL2RlbHRhc3RyZWFtZXIvRGVsdGFTeW5jLmphdmE=) | `71.85% <0.00%> (-0.15%)` | `38.00% <0.00%> (ø%)` | |
   | [...n/java/org/apache/hudi/common/model/HoodieKey.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL0hvb2RpZUtleS5qYXZh) | `88.88% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...java/org/apache/hudi/common/util/CleanerUtils.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL3V0aWwvQ2xlYW5lclV0aWxzLmphdmE=) | `95.65% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [.../java/org/apache/hudi/utilities/HoodieCleaner.java](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL0hvb2RpZUNsZWFuZXIuamF2YQ==) | | | |
   | ... and [42 more](https://codecov.io/gh/apache/incubator-hudi/pull/1490/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=footer). Last update [c146ca9...32ef3e7](https://codecov.io/gh/apache/incubator-hudi/pull/1490?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] hddong commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
hddong commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r405921464
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,245 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.shell.core.CommandResult;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.Stream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test class for {@link FileSystemViewCommand}.
+ */
+public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
+  private String tablePath;
+  private String partitionPath;
+  private SyncableFileSystemView fsView;
+
+  private static String TEST_WRITE_TOKEN = "1-0-1";
+
+  @Before
+  public void init() throws IOException {
+    HoodieCLI.conf = jsc.hadoopConfiguration();
+
+    // Create table and connect
+    String tableName = "test_table";
+    tablePath = basePath + File.separator + tableName;
+    new TableCommand().createTable(
+        tablePath, tableName,
+        "COPY_ON_WRITE", "", 1, "org.apache.hudi.common.model.HoodieAvroPayload");
+
+    metaClient = HoodieCLI.getTableMetaClient();
+
+    partitionPath = HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH;
+    String fullPartitionPath = tablePath + "/" + partitionPath;
+    new File(fullPartitionPath).mkdirs();
+
+    // Generate 2 commits
+    String commitTime1 = "1";
+    String commitTime2 = "2";
+
+    String fileId1 = UUID.randomUUID().toString();
+
+    // Write date files and log file
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime1, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime1, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime2, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime2, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+
+    // Write commit files
+    new File(tablePath + "/.hoodie/" + commitTime1 + ".commit").createNewFile();
+    new File(tablePath + "/.hoodie/" + commitTime2 + ".commit").createNewFile();
+
+    // Reload meta client and create fsView
+    metaClient = HoodieTableMetaClient.reload(metaClient);
+
+    fsView = new HoodieTableFileSystemView(metaClient, metaClient.getActiveTimeline(), true);
+  }
+
+  /**
+   * Test case for 'show fsview all'.
+   */
+  @Test
+  public void testShowCommits() {
+    // Test default show fsview all
+    CommandResult cr = getShell().executeCommand("show fsview all");
 
 Review comment:
   > ditto
   
   @yanghua IMO, it is better to reuse title string like `Total Delta File Size`. Command string (`show fsview all`) maybe better to keep it the way it is, here and in `FileSystemViewCommand`, easier and clearer to known which command to run. wdyt

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] hddong commented on issue #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
hddong commented on issue #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#issuecomment-611445641
 
 
   @yanghua Thanks for your review, had address them.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r405375308
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,245 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.shell.core.CommandResult;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.Stream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test class for {@link FileSystemViewCommand}.
+ */
+public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
+  private String tablePath;
+  private String partitionPath;
+  private SyncableFileSystemView fsView;
+
+  private static String TEST_WRITE_TOKEN = "1-0-1";
+
+  @Before
+  public void init() throws IOException {
+    HoodieCLI.conf = jsc.hadoopConfiguration();
+
+    // Create table and connect
+    String tableName = "test_table";
+    tablePath = basePath + File.separator + tableName;
+    new TableCommand().createTable(
+        tablePath, tableName,
+        "COPY_ON_WRITE", "", 1, "org.apache.hudi.common.model.HoodieAvroPayload");
+
+    metaClient = HoodieCLI.getTableMetaClient();
+
+    partitionPath = HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH;
+    String fullPartitionPath = tablePath + "/" + partitionPath;
+    new File(fullPartitionPath).mkdirs();
+
+    // Generate 2 commits
+    String commitTime1 = "1";
+    String commitTime2 = "2";
+
+    String fileId1 = UUID.randomUUID().toString();
+
+    // Write date files and log file
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime1, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime1, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+    new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime2, TEST_WRITE_TOKEN, fileId1))
+        .createNewFile();
+    new File(fullPartitionPath + "/"
+        + FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime2, 0, TEST_WRITE_TOKEN))
+        .createNewFile();
+
+    // Write commit files
+    new File(tablePath + "/.hoodie/" + commitTime1 + ".commit").createNewFile();
+    new File(tablePath + "/.hoodie/" + commitTime2 + ".commit").createNewFile();
+
+    // Reload meta client and create fsView
+    metaClient = HoodieTableMetaClient.reload(metaClient);
+
+    fsView = new HoodieTableFileSystemView(metaClient, metaClient.getActiveTimeline(), true);
+  }
+
+  /**
+   * Test case for 'show fsview all'.
+   */
+  @Test
+  public void testShowCommits() {
+    // Test default show fsview all
+    CommandResult cr = getShell().executeCommand("show fsview all");
+    assertTrue(cr.isSuccess());
+
+    // Get all file groups
+    Stream<HoodieFileGroup> fileGroups = fsView.getAllFileGroups(partitionPath);
+
+    List<Comparable[]> rows = new ArrayList<>();
+    fileGroups.forEach(fg -> fg.getAllFileSlices().forEach(fs -> {
+      int idx = 0;
+      // For base file only Views, do not display any delta-file related columns
+      Comparable[] row = new Comparable[8];
+      row[idx++] = fg.getPartitionPath();
+      row[idx++] = fg.getFileGroupId().getFileId();
+      row[idx++] = fs.getBaseInstantTime();
+      row[idx++] = fs.getBaseFile().isPresent() ? fs.getBaseFile().get().getPath() : "";
+      row[idx++] = fs.getBaseFile().isPresent() ? fs.getBaseFile().get().getFileSize() : -1;
+      row[idx++] = fs.getLogFiles().count();
+      row[idx++] = fs.getLogFiles().mapToLong(HoodieLogFile::getFileSize).sum();
+      row[idx++] = fs.getLogFiles().collect(Collectors.toList()).toString();
+      rows.add(row);
+    }));
+
+    Function<Object, String> converterFunction =
+        entry -> NumericUtils.humanReadableByteCount((Double.parseDouble(entry.toString())));
+    Map<String, Function<Object, String>> fieldNameToConverterMap = new HashMap<>();
+    fieldNameToConverterMap.put("Total Delta File Size", converterFunction);
 
 Review comment:
   These string literals are the same as `FileSystemViewCommand`. We can define them as constant fields and reuse them 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] hddong commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
hddong commented on a change in pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490#discussion_r404549829
 
 

 ##########
 File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
 ##########
 @@ -0,0 +1,244 @@
+/*
+ * 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.AbstractShellIntegrationTest;
+import org.apache.hudi.cli.HoodieCLI;
+import org.apache.hudi.cli.HoodiePrintHelper;
+import org.apache.hudi.cli.TableHeader;
+import org.apache.hudi.cli.common.HoodieTestCommitMetadataGenerator;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieFileGroup;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.table.view.SyncableFileSystemView;
+import org.apache.hudi.common.util.NumericUtils;
+import org.junit.Before;
 
 Review comment:
   > Line Break here
   
   Thanks, had add it.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] yanghua merged pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand

Posted by GitBox <gi...@apache.org>.
yanghua merged pull request #1490: [HUDI-700]Add unit test for FileSystemViewCommand
URL: https://github.com/apache/incubator-hudi/pull/1490
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services