[HUDI-694]Add unit test for SparkEnvCommand (#1401)
* Add test for SparkEnvCommand
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
23
hudi-cli/src/test/resources/log4j-surefire-quiet.properties
Normal file
23
hudi-cli/src/test/resources/log4j-surefire-quiet.properties
Normal file
@@ -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
|
||||
25
hudi-cli/src/test/resources/log4j-surefire.properties
Normal file
25
hudi-cli/src/test/resources/log4j-surefire.properties
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user