Repository: zeppelin
Updated Branches:
  refs/heads/master 13f8e6cc6 -> 4c8f20ae3


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4c8f20ae/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
index 0c7f4ba..f7988e3 100644
--- 
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
@@ -22,6 +22,7 @@ import org.apache.zeppelin.interpreter.InterpreterOption;
 import org.apache.zeppelin.interpreter.remote.RemoteInterpreterManagedProcess;
 import org.junit.Test;
 
+import java.io.IOException;
 import java.util.Properties;
 
 import static org.junit.Assert.assertEquals;
@@ -30,14 +31,14 @@ import static org.junit.Assert.assertTrue;
 public class ShellScriptLauncherTest {
 
   @Test
-  public void testLauncher() {
+  public void testLauncher() throws IOException {
     ZeppelinConfiguration zConf = new ZeppelinConfiguration();
-    ShellScriptLauncher launcher = new ShellScriptLauncher(zConf);
+    ShellScriptLauncher launcher = new ShellScriptLauncher(zConf, null);
     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", 
"name");
+    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "intpGroupId", "groupId", 
"groupName", "name");
     InterpreterClient client = launcher.launch(context);
     assertTrue( client instanceof RemoteInterpreterManagedProcess);
     RemoteInterpreterManagedProcess interpreterProcess = 
(RemoteInterpreterManagedProcess) client;

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4c8f20ae/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
index b788ebd..3d7e251 100644
--- 
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
@@ -22,6 +22,7 @@ import org.apache.zeppelin.interpreter.InterpreterOption;
 import org.apache.zeppelin.interpreter.remote.RemoteInterpreterManagedProcess;
 import org.junit.Test;
 
+import java.io.IOException;
 import java.util.Properties;
 
 import static org.junit.Assert.assertEquals;
@@ -30,9 +31,9 @@ import static org.junit.Assert.assertTrue;
 public class SparkInterpreterLauncherTest {
 
   @Test
-  public void testLocalMode() {
+  public void testLocalMode() throws IOException {
     ZeppelinConfiguration zConf = new ZeppelinConfiguration();
-    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf);
+    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf, 
null);
     Properties properties = new Properties();
     properties.setProperty("SPARK_HOME", "/user/spark");
     properties.setProperty("property_1", "value_1");
@@ -41,7 +42,7 @@ public class SparkInterpreterLauncherTest {
     properties.setProperty("spark.jars", "jar_1");
 
     InterpreterOption option = new InterpreterOption();
-    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "groupId", "spark", "spark");
+    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "intpGroupId", "groupId", 
"spark", "spark");
     InterpreterClient client = launcher.launch(context);
     assertTrue( client instanceof RemoteInterpreterManagedProcess);
     RemoteInterpreterManagedProcess interpreterProcess = 
(RemoteInterpreterManagedProcess) client;
@@ -55,9 +56,9 @@ public class SparkInterpreterLauncherTest {
   }
 
   @Test
-  public void testYarnClientMode_1() {
+  public void testYarnClientMode_1() throws IOException {
     ZeppelinConfiguration zConf = new ZeppelinConfiguration();
-    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf);
+    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf, 
null);
     Properties properties = new Properties();
     properties.setProperty("SPARK_HOME", "/user/spark");
     properties.setProperty("property_1", "value_1");
@@ -66,7 +67,7 @@ public class SparkInterpreterLauncherTest {
     properties.setProperty("spark.jars", "jar_1");
 
     InterpreterOption option = new InterpreterOption();
-    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "groupId", "spark", "spark");
+    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "intpGroupId", "groupId", 
"spark", "spark");
     InterpreterClient client = launcher.launch(context);
     assertTrue( client instanceof RemoteInterpreterManagedProcess);
     RemoteInterpreterManagedProcess interpreterProcess = 
(RemoteInterpreterManagedProcess) client;
@@ -80,9 +81,9 @@ public class SparkInterpreterLauncherTest {
   }
 
   @Test
-  public void testYarnClientMode_2() {
+  public void testYarnClientMode_2() throws IOException {
     ZeppelinConfiguration zConf = new ZeppelinConfiguration();
-    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf);
+    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf, 
null);
     Properties properties = new Properties();
     properties.setProperty("SPARK_HOME", "/user/spark");
     properties.setProperty("property_1", "value_1");
@@ -92,7 +93,7 @@ public class SparkInterpreterLauncherTest {
     properties.setProperty("spark.jars", "jar_1");
 
     InterpreterOption option = new InterpreterOption();
-    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "groupId", "spark", "spark");
+    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "intpGroupId", "groupId", 
"spark", "spark");
     InterpreterClient client = launcher.launch(context);
     assertTrue( client instanceof RemoteInterpreterManagedProcess);
     RemoteInterpreterManagedProcess interpreterProcess = 
(RemoteInterpreterManagedProcess) client;
@@ -106,9 +107,9 @@ public class SparkInterpreterLauncherTest {
   }
 
   @Test
-  public void testYarnClusterMode_1() {
+  public void testYarnClusterMode_1() throws IOException {
     ZeppelinConfiguration zConf = new ZeppelinConfiguration();
-    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf);
+    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf, 
null);
     Properties properties = new Properties();
     properties.setProperty("SPARK_HOME", "/user/spark");
     properties.setProperty("property_1", "value_1");
@@ -117,7 +118,7 @@ public class SparkInterpreterLauncherTest {
     properties.setProperty("spark.jars", "jar_1");
 
     InterpreterOption option = new InterpreterOption();
-    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "groupId", "spark", "spark");
+    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "intpGroupId", "groupId", 
"spark", "spark");
     InterpreterClient client = launcher.launch(context);
     assertTrue( client instanceof RemoteInterpreterManagedProcess);
     RemoteInterpreterManagedProcess interpreterProcess = 
(RemoteInterpreterManagedProcess) client;
@@ -132,9 +133,9 @@ public class SparkInterpreterLauncherTest {
   }
 
   @Test
-  public void testYarnClusterMode_2() {
+  public void testYarnClusterMode_2() throws IOException {
     ZeppelinConfiguration zConf = new ZeppelinConfiguration();
-    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf);
+    SparkInterpreterLauncher launcher = new SparkInterpreterLauncher(zConf, 
null);
     Properties properties = new Properties();
     properties.setProperty("SPARK_HOME", "/user/spark");
     properties.setProperty("property_1", "value_1");
@@ -144,7 +145,7 @@ public class SparkInterpreterLauncherTest {
     properties.setProperty("spark.jars", "jar_1");
 
     InterpreterOption option = new InterpreterOption();
-    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "groupId", "spark", "spark");
+    InterpreterLaunchContext context = new 
InterpreterLaunchContext(properties, option, null, "intpGroupId", "groupId", 
"spark", "spark");
     InterpreterClient client = launcher.launch(context);
     assertTrue( client instanceof RemoteInterpreterManagedProcess);
     RemoteInterpreterManagedProcess interpreterProcess = 
(RemoteInterpreterManagedProcess) client;

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4c8f20ae/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/recovery/FileSystemRecoveryStorageTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/recovery/FileSystemRecoveryStorageTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/recovery/FileSystemRecoveryStorageTest.java
new file mode 100644
index 0000000..cf1899c
--- /dev/null
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/recovery/FileSystemRecoveryStorageTest.java
@@ -0,0 +1,92 @@
+package org.apache.zeppelin.interpreter.recovery;
+
+import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.apache.zeppelin.display.GUI;
+import org.apache.zeppelin.interpreter.AbstractInterpreterTest;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterContextRunner;
+import org.apache.zeppelin.interpreter.InterpreterException;
+import org.apache.zeppelin.interpreter.InterpreterOption;
+import org.apache.zeppelin.interpreter.InterpreterSetting;
+import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
+import org.apache.zeppelin.user.AuthenticationInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import static org.junit.Assert.assertEquals;
+
+public class FileSystemRecoveryStorageTest extends AbstractInterpreterTest {
+
+  private File recoveryDir = null;
+
+  @Before
+  public void setUp() throws Exception {
+    
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_STORAGE_CLASS.getVarName(),
+        FileSystemRecoveryStorage.class.getName());
+    recoveryDir = Files.createTempDir();
+    
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_DIR.getVarName(),
 recoveryDir.getAbsolutePath());
+    super.setUp();
+  }
+
+  @Override
+  public void tearDown() throws Exception {
+    super.tearDown();
+    FileUtils.deleteDirectory(recoveryDir);
+  }
+
+  @Test
+  public void testSingleInterpreterProcess() throws InterpreterException, 
IOException {
+    InterpreterSetting interpreterSetting = 
interpreterSettingManager.getByName("test");
+    interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED);
+
+    Interpreter interpreter1 = 
interpreterSetting.getDefaultInterpreter("user1", "note1");
+    RemoteInterpreter remoteInterpreter1 = (RemoteInterpreter) interpreter1;
+    InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
+        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(),
+        new GUI(), null, null, new ArrayList<InterpreterContextRunner>(), 
null);
+    remoteInterpreter1.interpret("hello", context1);
+
+    assertEquals(1, 
interpreterSettingManager.getRecoveryStorage().restore().size());
+
+    interpreterSetting.close();
+    assertEquals(0, 
interpreterSettingManager.getRecoveryStorage().restore().size());
+  }
+
+  @Test
+  public void testMultipleInterpreterProcess() throws InterpreterException, 
IOException {
+    InterpreterSetting interpreterSetting = 
interpreterSettingManager.getByName("test");
+    interpreterSetting.getOption().setPerUser(InterpreterOption.ISOLATED);
+
+    Interpreter interpreter1 = 
interpreterSetting.getDefaultInterpreter("user1", "note1");
+    RemoteInterpreter remoteInterpreter1 = (RemoteInterpreter) interpreter1;
+    InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
+        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(),
+        new GUI(), null, null, new ArrayList<InterpreterContextRunner>(), 
null);
+    remoteInterpreter1.interpret("hello", context1);
+    assertEquals(1, 
interpreterSettingManager.getRecoveryStorage().restore().size());
+
+    Interpreter interpreter2 = 
interpreterSetting.getDefaultInterpreter("user2", "note2");
+    RemoteInterpreter remoteInterpreter2 = (RemoteInterpreter) interpreter2;
+    InterpreterContext context2 = new InterpreterContext("noteId", 
"paragraphId", "repl",
+        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(),
+        new GUI(), null, null, new ArrayList<InterpreterContextRunner>(), 
null);
+    remoteInterpreter2.interpret("hello", context2);
+
+    assertEquals(2, 
interpreterSettingManager.getRecoveryStorage().restore().size());
+
+    interpreterSettingManager.restart(interpreterSetting.getId(), "note1", 
"user1");
+    assertEquals(1, 
interpreterSettingManager.getRecoveryStorage().restore().size());
+
+    interpreterSetting.close();
+    assertEquals(0, 
interpreterSettingManager.getRecoveryStorage().restore().size());
+  }
+
+}

Reply via email to