mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
change Back-end test cases and member type (perNote, perUser)
This commit is contained in:
parent
8586e1f2a4
commit
787a366b25
5 changed files with 59 additions and 15 deletions
|
|
@ -298,6 +298,7 @@ public class RemoteInterpreter extends Interpreter {
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("st:\n{}", st);
|
||||
}
|
||||
|
||||
FormType form = getFormType();
|
||||
RemoteInterpreterProcess interpreterProcess = getInterpreterProcess();
|
||||
Client client = null;
|
||||
|
|
|
|||
|
|
@ -23,12 +23,16 @@ import java.util.List;
|
|||
*
|
||||
*/
|
||||
public class InterpreterOption {
|
||||
public final transient String SHARED = "shared";
|
||||
public final transient String SCOPED = "scoped";
|
||||
public final transient String ISOLATED = "isolated";
|
||||
|
||||
boolean remote;
|
||||
String host = null;
|
||||
int port = -1;
|
||||
|
||||
boolean perNote;
|
||||
boolean perUser;
|
||||
String perNote;
|
||||
String perUser;
|
||||
|
||||
boolean session;
|
||||
boolean process;
|
||||
|
|
@ -37,19 +41,46 @@ public class InterpreterOption {
|
|||
boolean setPermission;
|
||||
List<String> users;
|
||||
|
||||
public boolean isPerNote() {
|
||||
return perNote;
|
||||
public boolean isGlobally() {
|
||||
if (perNote != null && perNote.equals(SHARED)
|
||||
&& perUser != null && perUser.equals(SHARED)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPerNote(boolean perNote) {
|
||||
public boolean isPerNote() {
|
||||
if (isGlobally() == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (perNote != null && !perNote.equals("")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPerNote(String perNote) {
|
||||
this.perNote = perNote;
|
||||
}
|
||||
|
||||
public boolean isPerUser() {
|
||||
return perUser;
|
||||
if (isGlobally() == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPerNote() == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (perUser != null && !perUser.equals("")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPerUser(boolean perUser) {
|
||||
public void setPerUser(String perUser) {
|
||||
this.perUser = perUser;
|
||||
}
|
||||
|
||||
|
|
@ -82,10 +113,14 @@ public class InterpreterOption {
|
|||
}
|
||||
|
||||
public InterpreterOption() {
|
||||
this.perNote = null;
|
||||
this.perUser = null;
|
||||
remote = false;
|
||||
}
|
||||
|
||||
public InterpreterOption(boolean remote) {
|
||||
this.perNote = null;
|
||||
this.perUser = null;
|
||||
this.remote = remote;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ public class InterpreterFactoryTest {
|
|||
|
||||
InterpreterOption perUserInterpreterOption = new InterpreterOption(true);
|
||||
perUserInterpreterOption.setSession(true);
|
||||
perUserInterpreterOption.setPerUser(true);
|
||||
perUserInterpreterOption.setPerUser(perUserInterpreterOption.ISOLATED);
|
||||
final InterpreterSetting setting1 = factory.createNewSetting("test-group1", "group1", new ArrayList<Dependency>(), perUserInterpreterOption, new Properties());
|
||||
|
||||
factory.setInterpreters("user1", "note", new ArrayList<String>() {{
|
||||
|
|
|
|||
|
|
@ -95,13 +95,16 @@ public class NoteInterpreterLoaderTest {
|
|||
|
||||
@Test
|
||||
public void testNoteSession() throws IOException {
|
||||
InterpreterOption dumyInterpreterOption = new InterpreterOption();
|
||||
factory.setInterpreters("user", "noteA", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setSession(true);
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setPerNote(true);
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setPerNote(dumyInterpreterOption.SCOPED);
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setPerUser("");
|
||||
|
||||
factory.setInterpreters("user", "noteB", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("noteB").get(0).getOption().setSession(true);
|
||||
factory.getInterpreterSettings("noteB").get(0).getOption().setPerNote(true);
|
||||
factory.getInterpreterSettings("noteB").get(0).getOption().setPerNote(dumyInterpreterOption.SCOPED);
|
||||
factory.getInterpreterSettings("noteB").get(0).getOption().setPerUser("");
|
||||
|
||||
// interpreters are not created before accessing it
|
||||
assertNull(factory.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get(":noteA"));
|
||||
|
|
@ -130,13 +133,16 @@ public class NoteInterpreterLoaderTest {
|
|||
|
||||
@Test
|
||||
public void testNotePerInterpreterProcess() throws IOException {
|
||||
InterpreterOption dumyInterpreterOption = new InterpreterOption();
|
||||
factory.setInterpreters("user", "noteA", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setProcess(true);
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setPerNote(true);
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setPerNote(dumyInterpreterOption.SCOPED);
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setPerUser("");
|
||||
|
||||
factory.setInterpreters("user", "noteB", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("noteB").get(0).getOption().setProcess(true);
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setPerNote(true);
|
||||
factory.getInterpreterSettings("noteB").get(0).getOption().setPerNote(dumyInterpreterOption.SCOPED);
|
||||
factory.getInterpreterSettings("noteB").get(0).getOption().setPerUser("");
|
||||
|
||||
// interpreters are not created before accessing it
|
||||
assertNull(factory.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get(":noteA"));
|
||||
|
|
|
|||
|
|
@ -696,10 +696,11 @@ public class NotebookTest implements JobListenerFactory{
|
|||
p1.setText("getId");
|
||||
p1.setAuthenticationInfo(anonymous);
|
||||
|
||||
// restart interpreter with per note session enabled
|
||||
// restart interpreter with per user session enabled
|
||||
for (InterpreterSetting setting : factory.getInterpreterSettings(note1.getId())) {
|
||||
setting.getOption().setSession(true);
|
||||
setting.getOption().setPerUser(true);
|
||||
setting.getOption().setPerNote(setting.getOption().SCOPED);
|
||||
setting.getOption().setPerUser("");
|
||||
notebook.getInterpreterFactory().restart(setting.getId());
|
||||
}
|
||||
|
||||
|
|
@ -748,7 +749,8 @@ public class NotebookTest implements JobListenerFactory{
|
|||
// restart interpreter with per note session enabled
|
||||
for (InterpreterSetting setting : notebook.getInterpreterFactory().getInterpreterSettings(note1.getId())) {
|
||||
setting.getOption().setSession(true);
|
||||
setting.getOption().setPerNote(true);
|
||||
setting.getOption().setPerNote(setting.getOption().SCOPED);
|
||||
setting.getOption().setPerUser(setting.getOption().SCOPED);
|
||||
notebook.getInterpreterFactory().restart(setting.getId());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue