hudi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vinoy...@apache.org
Subject [incubator-hudi] branch master updated: [HUDI-694]Add unit test for SparkEnvCommand (#1401)
Date Mon, 16 Mar 2020 03:52:48 GMT
This is an automated email from the ASF dual-hosted git repository.

vinoyang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new 55e6d34  [HUDI-694]Add unit test for SparkEnvCommand (#1401)
55e6d34 is described below

commit 55e6d348155f63eb128cd208687d02206bad66a5
Author: hongdd <jn_hdd@163.com>
AuthorDate: Mon Mar 16 11:52:40 2020 +0800

    [HUDI-694]Add unit test for SparkEnvCommand (#1401)
    
    * Add test for SparkEnvCommand
---
 .../hudi/cli/AbstractShellIntegrationTest.java     | 46 +++++++++++++++++++
 .../hudi/cli/commands/TestSparkEnvCommand.java     | 53 ++++++++++++++++++++++
 .../test/resources/log4j-surefire-quiet.properties | 23 ++++++++++
 .../src/test/resources/log4j-surefire.properties   | 25 ++++++++++
 4 files changed, 147 insertions(+)

diff --git a/hudi-cli/src/test/java/org/apache/hudi/cli/AbstractShellIntegrationTest.java
b/hudi-cli/src/test/java/org/apache/hudi/cli/AbstractShellIntegrationTest.java
new file mode 100644
index 0000000..6db65a7
--- /dev/null
+++ b/hudi-cli/src/test/java/org/apache/hudi/cli/AbstractShellIntegrationTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.springframework.shell.Bootstrap;
+import org.springframework.shell.core.JLineShellComponent;
+
+/**
+ * Class to start Bootstrap and JLineShellComponent.
+ */
+public abstract class AbstractShellIntegrationTest {
+  private static JLineShellComponent shell;
+
+  @BeforeClass
+  public static void startup() {
+    Bootstrap bootstrap = new Bootstrap();
+    shell = bootstrap.getJLineShellComponent();
+  }
+
+  @AfterClass
+  public static void shutdown() {
+    shell.stop();
+  }
+
+  protected static JLineShellComponent getShell() {
+    return shell;
+  }
+}
diff --git a/hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestSparkEnvCommand.java
b/hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestSparkEnvCommand.java
new file mode 100644
index 0000000..f54fcae
--- /dev/null
+++ b/hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestSparkEnvCommand.java
@@ -0,0 +1,53 @@
+/*
+ * 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.HoodiePrintHelper;
+import org.junit.Test;
+import org.springframework.shell.core.CommandResult;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test Cases for {@link SparkEnvCommand}.
+ */
+public class TestSparkEnvCommand extends AbstractShellIntegrationTest {
+
+  /**
+   * Test Cases for set and get spark env.
+   */
+  @Test
+  public void testSetAndGetSparkEnv() {
+    // First, be empty
+    CommandResult cr = getShell().executeCommand("show envs all");
+    String nullResult = HoodiePrintHelper.print(new String[] {"key", "value"}, new String[0][2]);
+    assertEquals(nullResult, cr.getResult().toString());
+
+    // Set SPARK_HOME
+    cr = getShell().executeCommand("set --conf SPARK_HOME=/usr/etc/spark");
+    assertTrue(cr.isSuccess());
+
+    //Get
+    cr = getShell().executeCommand("show env --key SPARK_HOME");
+    String result = HoodiePrintHelper.print(new String[] {"key", "value"}, new String[][]{new
String[]{"SPARK_HOME", "/usr/etc/spark"}});
+    assertEquals(result, cr.getResult().toString());
+  }
+}
diff --git a/hudi-cli/src/test/resources/log4j-surefire-quiet.properties b/hudi-cli/src/test/resources/log4j-surefire-quiet.properties
new file mode 100644
index 0000000..034183f
--- /dev/null
+++ b/hudi-cli/src/test/resources/log4j-surefire-quiet.properties
@@ -0,0 +1,23 @@
+###
+# 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.
+###
+log4j.rootLogger=WARN, A1
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=[%-5p] %d %c %x - %m%n
diff --git a/hudi-cli/src/test/resources/log4j-surefire.properties b/hudi-cli/src/test/resources/log4j-surefire.properties
new file mode 100644
index 0000000..a59d4eb
--- /dev/null
+++ b/hudi-cli/src/test/resources/log4j-surefire.properties
@@ -0,0 +1,25 @@
+###
+# 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.
+###
+log4j.rootLogger=WARN, A1
+log4j.category.org.apache=INFO
+log4j.category.org.apache.parquet.hadoop=WARN
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n


Mime
View raw message