Repository: zeppelin Updated Branches: refs/heads/master ed8755d3f -> 9812e26bc
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java index e7a04f3..cf1713f 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java @@ -41,7 +41,7 @@ public class EchoInterpreter extends Interpreter { @Override public InterpreterResult interpret(String st, InterpreterContext context) { - if (Boolean.parseBoolean(property.getProperty("zeppelin.interpreter.echo.fail", "false"))) { + if (Boolean.parseBoolean(getProperty("zeppelin.interpreter.echo.fail", "false"))) { return new InterpreterResult(InterpreterResult.Code.ERROR); } else { return new InterpreterResult(InterpreterResult.Code.SUCCESS, st); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java index f3137d9..abbaa35 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java @@ -52,10 +52,10 @@ public class InterpreterFactoryTest extends AbstractInterpreterTest { assertEquals(DoubleEchoInterpreter.class.getName(), remoteInterpreter.getClassName()); } - @Test(expected = InterpreterException.class) + @Test public void testUnknownRepl1() throws IOException { interpreterSettingManager.setInterpreterBinding("user1", "note1", interpreterSettingManager.getSettingIds()); - interpreterFactory.getInterpreter("user1", "note1", "test.unknown_repl"); + assertNull(interpreterFactory.getInterpreter("user1", "note1", "test.unknown_repl")); } @Test http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java index 0bcdb6f..605476f 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java @@ -96,7 +96,7 @@ public class InterpreterSettingManagerTest extends AbstractInterpreterTest { } @Test - public void testCreateUpdateRemoveSetting() throws IOException { + public void testCreateUpdateRemoveSetting() throws IOException, InterpreterException { // create new interpreter setting InterpreterOption option = new InterpreterOption(); option.setPerNote("scoped"); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java index 9deafcf..7a904c6 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java @@ -46,7 +46,7 @@ public class SleepInterpreter extends Interpreter { @Override public Scheduler getScheduler() { - if (Boolean.parseBoolean(property.getProperty("zeppelin.SleepInterpreter.parallel", "false"))) { + if (Boolean.parseBoolean(getProperty("zeppelin.SleepInterpreter.parallel", "false"))) { return SchedulerFactory.singleton().createOrGetParallelScheduler( "Parallel-" + SleepInterpreter.class.getName(), 10); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkInterpreterModeTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkInterpreterModeTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkInterpreterModeTest.java index 24a9aee..930a26d 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkInterpreterModeTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkInterpreterModeTest.java @@ -44,7 +44,7 @@ public class SparkInterpreterModeTest { } } - private void testInterpreterBasics() throws IOException { + private void testInterpreterBasics() throws IOException, InterpreterException { // test SparkInterpreter interpreterSettingManager.setInterpreterBinding("user1", "note1", interpreterSettingManager.getInterpreterSettingIds()); Interpreter sparkInterpreter = interpreterFactory.getInterpreter("user1", "note1", "spark.spark"); @@ -75,7 +75,7 @@ public class SparkInterpreterModeTest { } @Test - public void testLocalMode() throws IOException, YarnException { + public void testLocalMode() throws IOException, YarnException, InterpreterException { InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark"); sparkInterpreterSetting.setProperty("master", "local[*]"); sparkInterpreterSetting.setProperty("SPARK_HOME", System.getenv("SPARK_HOME")); @@ -94,7 +94,7 @@ public class SparkInterpreterModeTest { } @Test - public void testYarnClientMode() throws IOException, YarnException, InterruptedException { + public void testYarnClientMode() throws IOException, YarnException, InterruptedException, InterpreterException { InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark"); sparkInterpreterSetting.setProperty("master", "yarn-client"); sparkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath()); @@ -116,7 +116,7 @@ public class SparkInterpreterModeTest { } @Test - public void testYarnClusterMode() throws IOException, YarnException, InterruptedException { + public void testYarnClusterMode() throws IOException, YarnException, InterruptedException, InterpreterException { InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark"); sparkInterpreterSetting.setProperty("master", "yarn-cluster"); sparkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath()); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/launcher/ShellScriptLauncherTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/launcher/ShellScriptLauncherTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/launcher/ShellScriptLauncherTest.java new file mode 100644 index 0000000..9708ee7 --- /dev/null +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/launcher/ShellScriptLauncherTest.java @@ -0,0 +1,54 @@ +/* + * 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.zeppelin.interpreter.launcher; + +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.interpreter.InterpreterContext; +import org.apache.zeppelin.interpreter.InterpreterOption; +import org.apache.zeppelin.interpreter.remote.RemoteInterpreterManagedProcess; +import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcess; +import org.junit.Test; + +import java.util.Properties; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class ShellScriptLauncherTest { + + @Test + public void testLauncher() { + ZeppelinConfiguration zConf = new ZeppelinConfiguration(); + ShellScriptLauncher launcher = new ShellScriptLauncher(zConf); + Properties properties = new Properties(); + properties.setProperty("ENV_1", "VALUE_1"); + properties.setProperty("property_1", "value_1"); + InterpreterOption option = new InterpreterOption(); + InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "groupId", "groupName"); + InterpreterClient client = launcher.launch(context); + assertTrue( client instanceof RemoteInterpreterManagedProcess); + RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client; + assertEquals("groupName", interpreterProcess.getInterpreterGroupName()); + assertEquals(".//interpreter/groupName", interpreterProcess.getInterpreterDir()); + assertEquals(".//local-repo/groupId", interpreterProcess.getLocalRepoDir()); + assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner()); + assertEquals(1, interpreterProcess.getEnv().size()); + assertEquals("VALUE_1", interpreterProcess.getEnv().get("ENV_1")); + } + +} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncherTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncherTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncherTest.java new file mode 100644 index 0000000..45e009f --- /dev/null +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncherTest.java @@ -0,0 +1,160 @@ +/* + * 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.zeppelin.interpreter.launcher; + +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.interpreter.InterpreterOption; +import org.apache.zeppelin.interpreter.remote.RemoteInterpreterManagedProcess; +import org.junit.Test; + +import java.util.Properties; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class SparkInterpreterLauncherTest { + + @Test + public void testLocalMode() { + ZeppelinConfiguration zConf = new ZeppelinConfiguration(); + SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf); + Properties properties = new Properties(); + properties.setProperty("SPARK_HOME", "/user/spark"); + properties.setProperty("property_1", "value_1"); + properties.setProperty("master", "local[*]"); + properties.setProperty("spark.files", "file_1"); + properties.setProperty("spark.jars", "jar_1"); + + InterpreterOption option = new InterpreterOption(); + InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "groupId", "spark"); + InterpreterClient client = launcher.launch(context); + assertTrue( client instanceof RemoteInterpreterManagedProcess); + RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client; + assertEquals("spark", interpreterProcess.getInterpreterGroupName()); + assertEquals(".//interpreter/spark", interpreterProcess.getInterpreterDir()); + assertEquals(".//local-repo/groupId", interpreterProcess.getLocalRepoDir()); + assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner()); + assertEquals(2, interpreterProcess.getEnv().size()); + assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME")); + assertEquals(" --master local[*] --conf spark.files='file_1' --conf spark.jars='jar_1'", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF")); + } + + @Test + public void testYarnClientMode_1() { + ZeppelinConfiguration zConf = new ZeppelinConfiguration(); + SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf); + Properties properties = new Properties(); + properties.setProperty("SPARK_HOME", "/user/spark"); + properties.setProperty("property_1", "value_1"); + properties.setProperty("master", "yarn-client"); + properties.setProperty("spark.files", "file_1"); + properties.setProperty("spark.jars", "jar_1"); + + InterpreterOption option = new InterpreterOption(); + InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "groupId", "spark"); + InterpreterClient client = launcher.launch(context); + assertTrue( client instanceof RemoteInterpreterManagedProcess); + RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client; + assertEquals("spark", interpreterProcess.getInterpreterGroupName()); + assertEquals(".//interpreter/spark", interpreterProcess.getInterpreterDir()); + assertEquals(".//local-repo/groupId", interpreterProcess.getLocalRepoDir()); + assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner()); + assertEquals(2, interpreterProcess.getEnv().size()); + assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME")); + assertEquals(" --master yarn-client --conf spark.files='file_1' --conf spark.jars='jar_1' --conf spark.yarn.isPython=true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF")); + } + + @Test + public void testYarnClientMode_2() { + ZeppelinConfiguration zConf = new ZeppelinConfiguration(); + SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf); + Properties properties = new Properties(); + properties.setProperty("SPARK_HOME", "/user/spark"); + properties.setProperty("property_1", "value_1"); + properties.setProperty("master", "yarn"); + properties.setProperty("spark.submit.deployMode", "client"); + properties.setProperty("spark.files", "file_1"); + properties.setProperty("spark.jars", "jar_1"); + + InterpreterOption option = new InterpreterOption(); + InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "groupId", "spark"); + InterpreterClient client = launcher.launch(context); + assertTrue( client instanceof RemoteInterpreterManagedProcess); + RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client; + assertEquals("spark", interpreterProcess.getInterpreterGroupName()); + assertEquals(".//interpreter/spark", interpreterProcess.getInterpreterDir()); + assertEquals(".//local-repo/groupId", interpreterProcess.getLocalRepoDir()); + assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner()); + assertEquals(2, interpreterProcess.getEnv().size()); + assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME")); + assertEquals(" --master yarn --conf spark.files='file_1' --conf spark.jars='jar_1' --conf spark.submit.deployMode='client' --conf spark.yarn.isPython=true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF")); + } + + @Test + public void testYarnClusterMode_1() { + ZeppelinConfiguration zConf = new ZeppelinConfiguration(); + SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf); + Properties properties = new Properties(); + properties.setProperty("SPARK_HOME", "/user/spark"); + properties.setProperty("property_1", "value_1"); + properties.setProperty("master", "yarn-cluster"); + properties.setProperty("spark.files", "file_1"); + properties.setProperty("spark.jars", "jar_1"); + + InterpreterOption option = new InterpreterOption(); + InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "groupId", "spark"); + InterpreterClient client = launcher.launch(context); + assertTrue( client instanceof RemoteInterpreterManagedProcess); + RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client; + assertEquals("spark", interpreterProcess.getInterpreterGroupName()); + assertEquals(".//interpreter/spark", interpreterProcess.getInterpreterDir()); + assertEquals(".//local-repo/groupId", interpreterProcess.getLocalRepoDir()); + assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner()); + assertEquals(3, interpreterProcess.getEnv().size()); + assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME")); + assertEquals("true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_YARN_CLUSTER")); + assertEquals(" --master yarn-cluster --files .//conf/log4j_yarn_cluster.properties --conf spark.files='file_1' --conf spark.jars='jar_1' --conf spark.yarn.isPython=true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF")); + } + + @Test + public void testYarnClusterMode_2() { + ZeppelinConfiguration zConf = new ZeppelinConfiguration(); + SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf); + Properties properties = new Properties(); + properties.setProperty("SPARK_HOME", "/user/spark"); + properties.setProperty("property_1", "value_1"); + properties.setProperty("master", "yarn"); + properties.setProperty("spark.submit.deployMode", "cluster"); + properties.setProperty("spark.files", "file_1"); + properties.setProperty("spark.jars", "jar_1"); + + InterpreterOption option = new InterpreterOption(); + InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "groupId", "spark"); + InterpreterClient client = launcher.launch(context); + assertTrue( client instanceof RemoteInterpreterManagedProcess); + RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client; + assertEquals("spark", interpreterProcess.getInterpreterGroupName()); + assertEquals(".//interpreter/spark", interpreterProcess.getInterpreterDir()); + assertEquals(".//local-repo/groupId", interpreterProcess.getLocalRepoDir()); + assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner()); + assertEquals(3, interpreterProcess.getEnv().size()); + assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME")); + assertEquals("true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_YARN_CLUSTER")); + assertEquals(" --master yarn --files .//conf/log4j_yarn_cluster.properties --conf spark.files='file_1' --conf spark.jars='jar_1' --conf spark.submit.deployMode='cluster' --conf spark.yarn.isPython=true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF")); + } +} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java index 37b262c..54814c4 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java @@ -100,7 +100,7 @@ public class RemoteAngularObjectTest implements AngularObjectRegistryListener { } @Test - public void testAngularObjectInterpreterSideCRUD() throws InterruptedException { + public void testAngularObjectInterpreterSideCRUD() throws InterruptedException, InterpreterException { InterpreterResult ret = intp.interpret("get", context); Thread.sleep(500); // waitFor eventpoller pool event String[] result = ret.message().get(0).getData().split(" "); @@ -133,7 +133,7 @@ public class RemoteAngularObjectTest implements AngularObjectRegistryListener { } @Test - public void testAngularObjectRemovalOnZeppelinServerSide() throws InterruptedException { + public void testAngularObjectRemovalOnZeppelinServerSide() throws InterruptedException, InterpreterException { // test if angularobject removal from server side propagate to interpreter process's registry. // will happen when notebook is removed. @@ -158,7 +158,7 @@ public class RemoteAngularObjectTest implements AngularObjectRegistryListener { } @Test - public void testAngularObjectAddOnZeppelinServerSide() throws InterruptedException { + public void testAngularObjectAddOnZeppelinServerSide() throws InterruptedException, InterpreterException { // test if angularobject add from server side propagate to interpreter process's registry. // will happen when zeppelin server loads notebook and restore the object into registry http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java index c5203a9..f52803d 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java @@ -82,7 +82,7 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce } @Test - public void testInterpreterResultOnly() { + public void testInterpreterResultOnly() throws InterpreterException { RemoteInterpreter intp = (RemoteInterpreter) interpreterSetting.getDefaultInterpreter("user1", "note1"); InterpreterResult ret = intp.interpret("SUCCESS::staticresult", createInterpreterContext()); assertEquals(InterpreterResult.Code.SUCCESS, ret.code()); @@ -98,7 +98,7 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce } @Test - public void testInterpreterOutputStreamOnly() { + public void testInterpreterOutputStreamOnly() throws InterpreterException { RemoteInterpreter intp = (RemoteInterpreter) interpreterSetting.getDefaultInterpreter("user1", "note1"); InterpreterResult ret = intp.interpret("SUCCESS:streamresult:", createInterpreterContext()); assertEquals(InterpreterResult.Code.SUCCESS, ret.code()); @@ -110,7 +110,7 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce } @Test - public void testInterpreterResultOutputStreamMixed() { + public void testInterpreterResultOutputStreamMixed() throws InterpreterException { RemoteInterpreter intp = (RemoteInterpreter) interpreterSetting.getDefaultInterpreter("user1", "note1"); InterpreterResult ret = intp.interpret("SUCCESS:stream:static", createInterpreterContext()); assertEquals(InterpreterResult.Code.SUCCESS, ret.code()); @@ -119,7 +119,7 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce } @Test - public void testOutputType() { + public void testOutputType() throws InterpreterException { RemoteInterpreter intp = (RemoteInterpreter) interpreterSetting.getDefaultInterpreter("user1", "note1"); InterpreterResult ret = intp.interpret("SUCCESS:%html hello:", createInterpreterContext()); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java index c201eda..74bde89 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java @@ -81,7 +81,7 @@ public class RemoteInterpreterTest { } @Test - public void testSharedMode() { + public void testSharedMode() throws InterpreterException, IOException { interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED); Interpreter interpreter1 = interpreterSetting.getDefaultInterpreter("user1", "note1"); @@ -124,7 +124,7 @@ public class RemoteInterpreterTest { } @Test - public void testScopedMode() { + public void testScopedMode() throws InterpreterException, IOException { interpreterSetting.getOption().setPerUser(InterpreterOption.SCOPED); Interpreter interpreter1 = interpreterSetting.getDefaultInterpreter("user1", "note1"); @@ -170,7 +170,7 @@ public class RemoteInterpreterTest { } @Test - public void testIsolatedMode() { + public void testIsolatedMode() throws InterpreterException, IOException { interpreterSetting.getOption().setPerUser(InterpreterOption.ISOLATED); Interpreter interpreter1 = interpreterSetting.getDefaultInterpreter("user1", "note1"); @@ -217,7 +217,7 @@ public class RemoteInterpreterTest { } @Test - public void testExecuteIncorrectPrecode() throws TTransportException, IOException { + public void testExecuteIncorrectPrecode() throws TTransportException, IOException, InterpreterException { interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED); interpreterSetting.setProperty("zeppelin.SleepInterpreter.precode", "fail test"); Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", "note1", "sleep"); @@ -228,7 +228,7 @@ public class RemoteInterpreterTest { } @Test - public void testExecuteCorrectPrecode() throws TTransportException, IOException { + public void testExecuteCorrectPrecode() throws TTransportException, IOException, InterpreterException { interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED); interpreterSetting.setProperty("zeppelin.SleepInterpreter.precode", "1"); Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", "note1", "sleep"); @@ -239,7 +239,7 @@ public class RemoteInterpreterTest { } @Test - public void testRemoteInterperterErrorStatus() throws TTransportException, IOException { + public void testRemoteInterperterErrorStatus() throws TTransportException, IOException, InterpreterException { interpreterSetting.setProperty("zeppelin.interpreter.echo.fail", "true"); interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED); @@ -254,7 +254,7 @@ public class RemoteInterpreterTest { } @Test - public void testFIFOScheduler() throws InterruptedException { + public void testFIFOScheduler() throws InterruptedException, InterpreterException { interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED); // by default SleepInterpreter would use FIFOScheduler @@ -268,13 +268,23 @@ public class RemoteInterpreterTest { Thread thread1 = new Thread() { @Override public void run() { - assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code()); + try { + assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code()); + } catch (InterpreterException e) { + e.printStackTrace(); + fail(); + } } }; Thread thread2 = new Thread() { @Override public void run() { - assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code()); + try { + assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code()); + } catch (InterpreterException e) { + e.printStackTrace(); + fail(); + } } }; long start = System.currentTimeMillis(); @@ -287,7 +297,7 @@ public class RemoteInterpreterTest { } @Test - public void testParallelScheduler() throws InterruptedException { + public void testParallelScheduler() throws InterruptedException, InterpreterException { interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED); interpreterSetting.setProperty("zeppelin.SleepInterpreter.parallel", "true"); @@ -302,13 +312,23 @@ public class RemoteInterpreterTest { Thread thread1 = new Thread() { @Override public void run() { - assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code()); + try { + assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code()); + } catch (InterpreterException e) { + e.printStackTrace(); + fail(); + } } }; Thread thread2 = new Thread() { @Override public void run() { - assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code()); + try { + assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code()); + } catch (InterpreterException e) { + e.printStackTrace(); + fail(); + } } }; long start = System.currentTimeMillis(); @@ -376,7 +396,7 @@ public class RemoteInterpreterTest { } @Test - public void testEnvironmentAndProperty() { + public void testEnvironmentAndProperty() throws InterpreterException { interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED); interpreterSetting.setProperty("ENV_1", "VALUE_1"); interpreterSetting.setProperty("property_1", "value_1"); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java index 5a3e57c..dbd2df7 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java @@ -51,8 +51,9 @@ public class MockInterpreterA extends Interpreter { } @Override - public InterpreterResult interpret(String st, InterpreterContext context) { - if (property.containsKey("progress")) { + public InterpreterResult interpret(String st, InterpreterContext context) + throws InterpreterException { + if (getProperties().containsKey("progress")) { context.setProgress(Integer.parseInt(getProperty("progress"))); } try { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java index 1890cbc..7a5321a 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java @@ -52,7 +52,8 @@ public class MockInterpreterOutputStream extends Interpreter { } @Override - public InterpreterResult interpret(String st, InterpreterContext context) { + public InterpreterResult interpret(String st, InterpreterContext context) + throws InterpreterException { String[] ret = st.split(":"); try { if (ret[1] != null) { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java index bc185a0..a1621e8 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java @@ -23,8 +23,6 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; import org.apache.zeppelin.display.AngularObjectRegistry; import org.apache.zeppelin.interpreter.AbstractInterpreterTest; -import org.apache.zeppelin.interpreter.ClassloaderInterpreter; -import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.InterpreterException; import org.apache.zeppelin.interpreter.InterpreterFactory; import org.apache.zeppelin.interpreter.InterpreterGroup; @@ -32,9 +30,6 @@ import org.apache.zeppelin.interpreter.InterpreterOption; import org.apache.zeppelin.interpreter.InterpreterResult; import org.apache.zeppelin.interpreter.InterpreterResultMessage; import org.apache.zeppelin.interpreter.InterpreterSetting; -import org.apache.zeppelin.interpreter.LazyOpenInterpreter; -import org.apache.zeppelin.interpreter.mock.MockInterpreter1; -import org.apache.zeppelin.interpreter.mock.MockInterpreter2; import org.apache.zeppelin.interpreter.remote.RemoteInterpreter; import org.apache.zeppelin.notebook.repo.NotebookRepo; import org.apache.zeppelin.notebook.repo.VFSNotebookRepo; @@ -667,7 +662,7 @@ public class NotebookTest extends AbstractInterpreterTest implements JobListener @Test public void testAngularObjectRemovalOnInterpreterRestart() throws InterruptedException, - IOException { + IOException, InterpreterException { // create a note and a paragraph Note note = notebook.createNote(anonymous); interpreterSettingManager.setInterpreterBinding(anonymous.getUser(), note.getId(), interpreterSettingManager.getInterpreterSettingIds()); @@ -795,7 +790,7 @@ public class NotebookTest extends AbstractInterpreterTest implements JobListener @Test public void testAbortParagraphStatusOnInterpreterRestart() throws InterruptedException, - IOException { + IOException, InterpreterException { Note note = notebook.createNote(anonymous); interpreterSettingManager.setInterpreterBinding(anonymous.getUser(), note.getId(), interpreterSettingManager.getInterpreterSettingIds()); @@ -829,7 +824,7 @@ public class NotebookTest extends AbstractInterpreterTest implements JobListener } @Test - public void testPerSessionInterpreterCloseOnNoteRemoval() throws IOException { + public void testPerSessionInterpreterCloseOnNoteRemoval() throws IOException, InterpreterException { // create a notes Note note1 = notebook.createNote(anonymous); Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS); @@ -861,7 +856,7 @@ public class NotebookTest extends AbstractInterpreterTest implements JobListener } @Test - public void testPerSessionInterpreter() throws IOException { + public void testPerSessionInterpreter() throws IOException, InterpreterException { // create two notes Note note1 = notebook.createNote(anonymous); Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS); @@ -905,7 +900,7 @@ public class NotebookTest extends AbstractInterpreterTest implements JobListener @Test - public void testPerNoteSessionInterpreter() throws IOException { + public void testPerNoteSessionInterpreter() throws IOException, InterpreterException { // create two notes Note note1 = notebook.createNote(anonymous); Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS); @@ -964,7 +959,7 @@ public class NotebookTest extends AbstractInterpreterTest implements JobListener } @Test - public void testPerSessionInterpreterCloseOnUnbindInterpreterSetting() throws IOException { + public void testPerSessionInterpreterCloseOnUnbindInterpreterSetting() throws IOException, InterpreterException { // create a notes Note note1 = notebook.createNote(anonymous); Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java index 469d5b5..c7ccd46 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java @@ -79,7 +79,7 @@ public class DistributedResourcePoolTest extends AbstractInterpreterTest { } @Test - public void testRemoteDistributedResourcePool() { + public void testRemoteDistributedResourcePool() throws InterpreterException { Gson gson = new Gson(); InterpreterResult ret; intp1.interpret("put key1 value1", context); @@ -162,7 +162,7 @@ public class DistributedResourcePoolTest extends AbstractInterpreterTest { } @Test - public void testResourcePoolUtils() { + public void testResourcePoolUtils() throws InterpreterException { Gson gson = new Gson(); InterpreterResult ret; @@ -201,7 +201,7 @@ public class DistributedResourcePoolTest extends AbstractInterpreterTest { } @Test - public void testResourceInvokeMethod() { + public void testResourceInvokeMethod() throws InterpreterException { Gson gson = new Gson(); InterpreterResult ret; intp1.interpret("put key1 hey", context); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9812e26b/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java index e8e2183..e43a39d 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java @@ -20,6 +20,7 @@ package org.apache.zeppelin.scheduler; import org.apache.zeppelin.display.GUI; import org.apache.zeppelin.interpreter.InterpreterContext; import org.apache.zeppelin.interpreter.InterpreterContextRunner; +import org.apache.zeppelin.interpreter.InterpreterException; import org.apache.zeppelin.interpreter.InterpreterInfo; import org.apache.zeppelin.interpreter.InterpreterOption; import org.apache.zeppelin.interpreter.InterpreterResult; @@ -209,7 +210,11 @@ public class RemoteSchedulerTest implements RemoteInterpreterProcessListener { @Override protected boolean jobAbort() { if (isRunning()) { - intpA.cancel(context); + try { + intpA.cancel(context); + } catch (InterpreterException e) { + e.printStackTrace(); + } } return true; } @@ -259,7 +264,11 @@ public class RemoteSchedulerTest implements RemoteInterpreterProcessListener { @Override protected boolean jobAbort() { if (isRunning()) { - intpA.cancel(context); + try { + intpA.cancel(context); + } catch (InterpreterException e) { + e.printStackTrace(); + } } return true; }