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/05/29 09:01:46 UTC

[GitHub] [hudi] hddong opened a new pull request #1686: [HUDI-709]Add unit test for UtilsCommand

hddong opened a new pull request #1686:
URL: https://github.com/apache/hudi/pull/1686


   ## *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 UtilsCommand*
   
   ## Brief change log
   
   *(for example:)*
     - *Add unit test for UtilsCommand*
   
   ## 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



[GitHub] [hudi] yanghua commented on pull request #1686: [HUDI-709]Add unit test for UtilsCommand

Posted by GitBox <gi...@apache.org>.
yanghua commented on pull request #1686:
URL: https://github.com/apache/hudi/pull/1686#issuecomment-636570510


   Will review this one after merging PR #1689 


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



[GitHub] [hudi] codecov-commenter edited a comment on pull request #1686: [HUDI-709]Add unit test for UtilsCommand

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1686:
URL: https://github.com/apache/hudi/pull/1686#issuecomment-636298521


   # [Codecov](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=h1) Report
   > Merging [#1686](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=desc) into [master](https://codecov.io/gh/apache/hudi/commit/7fb1251c6ed769ea6877126957a03c5f95d42d8f&el=desc) will **increase** coverage by `0.01%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/hudi/pull/1686/graphs/tree.svg?width=650&height=150&src=pr&token=VTTXabwbs2)](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1686      +/-   ##
   ============================================
   + Coverage     18.19%   18.20%   +0.01%     
   - Complexity      856      857       +1     
   ============================================
     Files           348      348              
     Lines         15344    15344              
     Branches       1523     1523              
   ============================================
   + Hits           2792     2794       +2     
   + Misses        12195    12193       -2     
     Partials        357      357              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...apache/hudi/common/fs/HoodieWrapperFileSystem.java](https://codecov.io/gh/apache/hudi/pull/1686/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL2ZzL0hvb2RpZVdyYXBwZXJGaWxlU3lzdGVtLmphdmE=) | `22.69% <0.00%> (+0.70%)` | `29.00% <0.00%> (+1.00%)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/hudi/pull/1686?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/hudi/pull/1686?src=pr&el=footer). Last update [7fb1251...6e66206](https://codecov.io/gh/apache/hudi/pull/1686?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



[GitHub] [hudi] yanghua commented on a change in pull request #1686: [HUDI-709]Add unit test for UtilsCommand

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1686:
URL: https://github.com/apache/hudi/pull/1686#discussion_r439801930



##########
File path: hudi-cli/src/main/java/org/apache/hudi/cli/commands/UtilsCommand.java
##########
@@ -30,9 +31,15 @@
 public class UtilsCommand implements CommandMarker {
 
   @CliCommand(value = "utils loadClass", help = "Load a class")
-  public String loadClass(@CliOption(key = {"class"}, help = "Check mode") final String clazz) throws Exception {
-    Class klass = Class.forName(clazz);
-    return klass.getProtectionDomain().getCodeSource().getLocation().toExternalForm();
+  public String loadClass(@CliOption(key = {"class"}, help = "Check mode") final String clazz) {
+    if (StringUtils.isNullOrEmpty(clazz)) {
+      return "Class to be loaded can not null!";

Review comment:
       Shall we change to `can not be null!`?

##########
File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestUtilsCommand.java
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.table.HoodieTable;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.shell.core.CommandResult;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Test class for {@link org.apache.hudi.cli.commands.UtilsCommand}.
+ */
+public class TestUtilsCommand extends AbstractShellIntegrationTest {
+
+  /**
+   * Test case for success load class.
+   */
+  @Test
+  public void testLoadClass() {
+    String name = HoodieTable.class.getName();
+    CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name));
+    assertAll("Command run success",

Review comment:
       Use `ran` or `runs`?

##########
File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestUtilsCommand.java
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.table.HoodieTable;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.shell.core.CommandResult;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Test class for {@link org.apache.hudi.cli.commands.UtilsCommand}.
+ */
+public class TestUtilsCommand extends AbstractShellIntegrationTest {
+
+  /**
+   * Test case for success load class.
+   */
+  @Test
+  public void testLoadClass() {
+    String name = HoodieTable.class.getName();
+    CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name));
+    assertAll("Command run success",
+        () -> assertTrue(cr.isSuccess()),
+        () -> assertNotNull(cr.getResult().toString()),
+        () -> assertTrue(cr.getResult().toString().startsWith("file:")));
+  }
+
+  /**
+   * Test case for class not found.
+   */
+  @Test
+  public void testLoadClassNotFound() {
+    String name = "test.class.NotFound";
+    CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name));
+
+    assertAll("Command run success",

Review comment:
       ditto

##########
File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestUtilsCommand.java
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.table.HoodieTable;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.shell.core.CommandResult;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Test class for {@link org.apache.hudi.cli.commands.UtilsCommand}.
+ */
+public class TestUtilsCommand extends AbstractShellIntegrationTest {
+
+  /**
+   * Test case for success load class.
+   */
+  @Test
+  public void testLoadClass() {
+    String name = HoodieTable.class.getName();
+    CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name));
+    assertAll("Command run success",
+        () -> assertTrue(cr.isSuccess()),
+        () -> assertNotNull(cr.getResult().toString()),
+        () -> assertTrue(cr.getResult().toString().startsWith("file:")));
+  }
+
+  /**
+   * Test case for class not found.
+   */
+  @Test
+  public void testLoadClassNotFound() {
+    String name = "test.class.NotFound";
+    CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name));
+
+    assertAll("Command run success",
+        () -> assertTrue(cr.isSuccess()),
+        () -> assertNotNull(cr.getResult().toString()),
+        () -> assertEquals(cr.getResult().toString(), String.format("Class %s not found!", name)));
+  }
+
+  /**
+   * Test case for load null class.
+   */
+  @Test
+  public void testLoadClassNull() {
+    String name = "";
+    CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name));
+
+    assertAll("Command run success",
+        () -> assertTrue(cr.isSuccess()),
+        () -> assertNotNull(cr.getResult().toString()),
+        () -> assertEquals("Class to be loaded can not null!", cr.getResult().toString()));

Review comment:
       `can not null!` -> `can not be null!`?

##########
File path: hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestUtilsCommand.java
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.table.HoodieTable;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.shell.core.CommandResult;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Test class for {@link org.apache.hudi.cli.commands.UtilsCommand}.
+ */
+public class TestUtilsCommand extends AbstractShellIntegrationTest {
+
+  /**
+   * Test case for success load class.
+   */
+  @Test
+  public void testLoadClass() {
+    String name = HoodieTable.class.getName();
+    CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name));
+    assertAll("Command run success",
+        () -> assertTrue(cr.isSuccess()),
+        () -> assertNotNull(cr.getResult().toString()),
+        () -> assertTrue(cr.getResult().toString().startsWith("file:")));
+  }
+
+  /**
+   * Test case for class not found.
+   */
+  @Test
+  public void testLoadClassNotFound() {
+    String name = "test.class.NotFound";
+    CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name));
+
+    assertAll("Command run success",
+        () -> assertTrue(cr.isSuccess()),
+        () -> assertNotNull(cr.getResult().toString()),
+        () -> assertEquals(cr.getResult().toString(), String.format("Class %s not found!", name)));
+  }
+
+  /**
+   * Test case for load null class.
+   */
+  @Test
+  public void testLoadClassNull() {
+    String name = "";
+    CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name));
+
+    assertAll("Command run success",

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



[GitHub] [hudi] hddong commented on pull request #1686: [HUDI-709]Add unit test for UtilsCommand

Posted by GitBox <gi...@apache.org>.
hddong commented on pull request #1686:
URL: https://github.com/apache/hudi/pull/1686#issuecomment-636266927


   @xushiyan : Yes, thanks for your information.
   
   


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



[GitHub] [hudi] hddong commented on pull request #1686: [HUDI-709]Add unit test for UtilsCommand

Posted by GitBox <gi...@apache.org>.
hddong commented on pull request #1686:
URL: https://github.com/apache/hudi/pull/1686#issuecomment-645705798


   @yanghua : Had address them, please review again when free.


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



[GitHub] [hudi] yanghua merged pull request #1686: [HUDI-709]Add unit test for UtilsCommand

Posted by GitBox <gi...@apache.org>.
yanghua merged pull request #1686:
URL: https://github.com/apache/hudi/pull/1686


   


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



[GitHub] [hudi] codecov-commenter commented on pull request #1686: [HUDI-709]Add unit test for UtilsCommand

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #1686:
URL: https://github.com/apache/hudi/pull/1686#issuecomment-636298521


   # [Codecov](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=h1) Report
   > Merging [#1686](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=desc) into [master](https://codecov.io/gh/apache/hudi/commit/7fb1251c6ed769ea6877126957a03c5f95d42d8f&el=desc) will **increase** coverage by `0.01%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/hudi/pull/1686/graphs/tree.svg?width=650&height=150&src=pr&token=VTTXabwbs2)](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1686      +/-   ##
   ============================================
   + Coverage     18.19%   18.20%   +0.01%     
   - Complexity      856      857       +1     
   ============================================
     Files           348      348              
     Lines         15344    15344              
     Branches       1523     1523              
   ============================================
   + Hits           2792     2794       +2     
   + Misses        12195    12193       -2     
     Partials        357      357              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...apache/hudi/common/fs/HoodieWrapperFileSystem.java](https://codecov.io/gh/apache/hudi/pull/1686/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL2ZzL0hvb2RpZVdyYXBwZXJGaWxlU3lzdGVtLmphdmE=) | `22.69% <0.00%> (+0.70%)` | `29.00% <0.00%> (+1.00%)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/hudi/pull/1686?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/hudi/pull/1686?src=pr&el=footer). Last update [7fb1251...6e66206](https://codecov.io/gh/apache/hudi/pull/1686?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



[GitHub] [hudi] codecov-commenter edited a comment on pull request #1686: [HUDI-709]Add unit test for UtilsCommand

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1686:
URL: https://github.com/apache/hudi/pull/1686#issuecomment-636298521


   # [Codecov](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=h1) Report
   > Merging [#1686](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=desc) into [master](https://codecov.io/gh/apache/hudi/commit/ede6c9bda4dba8a9981252bd05f0725ff1024b95&el=desc) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/hudi/pull/1686/graphs/tree.svg?width=650&height=150&src=pr&token=VTTXabwbs2)](https://codecov.io/gh/apache/hudi/pull/1686?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff            @@
   ##             master    #1686   +/-   ##
   =========================================
     Coverage     18.14%   18.14%           
     Complexity      859      859           
   =========================================
     Files           352      352           
     Lines         15411    15411           
     Branches       1525     1525           
   =========================================
     Hits           2797     2797           
     Misses        12256    12256           
     Partials        358      358           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/hudi/pull/1686?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/hudi/pull/1686?src=pr&el=footer). Last update [ede6c9b...8984336](https://codecov.io/gh/apache/hudi/pull/1686?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



[GitHub] [hudi] xushiyan commented on pull request #1686: [HUDI-709]Add unit test for UtilsCommand

Posted by GitBox <gi...@apache.org>.
xushiyan commented on pull request #1686:
URL: https://github.com/apache/hudi/pull/1686#issuecomment-636243939


   Please note that in #1689 some package path were changed. Either PR merged later would need to make sure import statements work. Thanks.
   
   ![Screen Shot 2020-05-29 at 5 12 30 PM](https://user-images.githubusercontent.com/2701446/83314514-a2cf0580-a1cf-11ea-8f6d-24b94c0d7072.png)
   
   


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