use of org.apache.zeppelin.interpreter.InterpreterOption in project zeppelin by apache.
the class VFSNotebookRepoTest method setUp.
@Before
public void setUp() throws Exception {
String zpath = System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis();
mainZepDir = new File(zpath);
mainZepDir.mkdirs();
new File(mainZepDir, "conf").mkdirs();
String mainNotePath = zpath + "/notebook";
mainNotebookDir = new File(mainNotePath);
mainNotebookDir.mkdirs();
System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), mainZepDir.getAbsolutePath());
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), mainNotebookDir.getAbsolutePath());
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), "org.apache.zeppelin.notebook.repo.VFSNotebookRepo");
conf = ZeppelinConfiguration.create();
this.schedulerFactory = new SchedulerFactory();
this.schedulerFactory = new SchedulerFactory();
depResolver = new DependencyResolver(mainZepDir.getAbsolutePath() + "/local-repo");
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, new HashMap<String, Object>()));
interpreterSettingManager.add("mock1", interpreterInfos, new ArrayList<Dependency>(), new InterpreterOption(), Maps.<String, InterpreterProperty>newHashMap(), "mock1", null);
interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(), new Properties());
SearchService search = mock(SearchService.class);
notebookRepo = new VFSNotebookRepo(conf);
notebookAuthorization = NotebookAuthorization.init(conf);
notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, interpreterSettingManager, this, search, notebookAuthorization, null);
}
use of org.apache.zeppelin.interpreter.InterpreterOption in project zeppelin by apache.
the class StandardInterpreterLauncher method launchDirectly.
@Override
public InterpreterClient launchDirectly(InterpreterLaunchContext context) throws IOException {
LOGGER.info("Launching new interpreter process of {}", context.getInterpreterSettingGroup());
this.properties = context.getProperties();
InterpreterOption option = context.getOption();
InterpreterRunner runner = context.getRunner();
String groupName = context.getInterpreterSettingGroup();
String name = context.getInterpreterSettingName();
int connectTimeout = getConnectTimeout();
int connectionPoolSize = getConnectPoolSize();
if (option.isExistingProcess()) {
return new RemoteInterpreterRunningProcess(context.getInterpreterSettingName(), context.getInterpreterGroupId(), connectTimeout, connectionPoolSize, context.getIntpEventServerHost(), context.getIntpEventServerPort(), option.getHost(), option.getPort(), false);
} else {
// create new remote process
String localRepoPath = zConf.getInterpreterLocalRepoPath() + File.separator + context.getInterpreterSettingId();
return new ExecRemoteInterpreterProcess(context.getIntpEventServerPort(), context.getIntpEventServerHost(), zConf.getInterpreterPortRange(), zConf.getInterpreterDir() + "/" + groupName, localRepoPath, buildEnvFromProperties(context), connectTimeout, connectionPoolSize, name, context.getInterpreterGroupId(), option.isUserImpersonate(), runner != null ? runner.getPath() : zConf.getInterpreterRemoteRunnerPath());
}
}
use of org.apache.zeppelin.interpreter.InterpreterOption in project zeppelin by apache.
the class ParagraphTest method returnUnchangedResultsWithDifferentUser.
@Ignore
public void returnUnchangedResultsWithDifferentUser() throws Throwable {
Note mockNote = mock(Note.class);
when(mockNote.getCredentials()).thenReturn(mock(Credentials.class));
Paragraph spyParagraph = spy(new Paragraph("para_1", mockNote, null));
Interpreter mockInterpreter = mock(Interpreter.class);
spyParagraph.setInterpreter(mockInterpreter);
doReturn(mockInterpreter).when(spyParagraph).getBindedInterpreter();
ManagedInterpreterGroup mockInterpreterGroup = mock(ManagedInterpreterGroup.class);
when(mockInterpreter.getInterpreterGroup()).thenReturn(mockInterpreterGroup);
when(mockInterpreterGroup.getId()).thenReturn("mock_id_1");
when(mockInterpreterGroup.getAngularObjectRegistry()).thenReturn(mock(AngularObjectRegistry.class));
when(mockInterpreterGroup.getResourcePool()).thenReturn(mock(ResourcePool.class));
List<InterpreterSetting> spyInterpreterSettingList = spy(new ArrayList<>());
InterpreterSetting mockInterpreterSetting = mock(InterpreterSetting.class);
when(mockInterpreterGroup.getInterpreterSetting()).thenReturn(mockInterpreterSetting);
InterpreterOption mockInterpreterOption = mock(InterpreterOption.class);
when(mockInterpreterSetting.getOption()).thenReturn(mockInterpreterOption);
when(mockInterpreterOption.permissionIsSet()).thenReturn(false);
when(mockInterpreterSetting.getStatus()).thenReturn(Status.READY);
when(mockInterpreterSetting.getId()).thenReturn("mock_id_1");
when(mockInterpreterSetting.getOrCreateInterpreterGroup(anyString(), anyString())).thenReturn(mockInterpreterGroup);
when(mockInterpreterSetting.isUserAuthorized(any(List.class))).thenReturn(true);
spyInterpreterSettingList.add(mockInterpreterSetting);
when(mockNote.getId()).thenReturn("any_id");
when(mockInterpreter.getFormType()).thenReturn(FormType.NONE);
ParagraphJobListener mockJobListener = mock(ParagraphJobListener.class);
doReturn(mockJobListener).when(spyParagraph).getListener();
InterpreterResult mockInterpreterResult = mock(InterpreterResult.class);
when(mockInterpreter.interpret(anyString(), Mockito.<InterpreterContext>any())).thenReturn(mockInterpreterResult);
when(mockInterpreterResult.code()).thenReturn(Code.SUCCESS);
// Actual test
List<InterpreterResultMessage> result1 = new ArrayList<>();
result1.add(new InterpreterResultMessage(Type.TEXT, "result1"));
when(mockInterpreterResult.message()).thenReturn(result1);
AuthenticationInfo user1 = new AuthenticationInfo("user1");
spyParagraph.setAuthenticationInfo(user1);
spyParagraph.jobRun();
Paragraph p1 = spyParagraph.getUserParagraph(user1.getUser());
mockInterpreterResult = mock(InterpreterResult.class);
when(mockInterpreter.interpret(anyString(), Mockito.<InterpreterContext>any())).thenReturn(mockInterpreterResult);
when(mockInterpreterResult.code()).thenReturn(Code.SUCCESS);
List<InterpreterResultMessage> result2 = new ArrayList<>();
result2.add(new InterpreterResultMessage(Type.TEXT, "result2"));
when(mockInterpreterResult.message()).thenReturn(result2);
AuthenticationInfo user2 = new AuthenticationInfo("user2");
spyParagraph.setAuthenticationInfo(user2);
spyParagraph.jobRun();
Paragraph p2 = spyParagraph.getUserParagraph(user2.getUser());
assertNotEquals(p1.getReturn().toString(), p2.getReturn().toString());
assertEquals(p1, spyParagraph.getUserParagraph(user1.getUser()));
}
use of org.apache.zeppelin.interpreter.InterpreterOption in project zeppelin by apache.
the class K8sStandardInterpreterLauncherTest method testK8sLauncher.
@Test
public void testK8sLauncher() throws IOException {
// given
ZeppelinConfiguration zConf = ZeppelinConfiguration.create();
K8sStandardInterpreterLauncher launcher = new K8sStandardInterpreterLauncher(zConf, null);
Properties properties = new Properties();
properties.setProperty("ENV_1", "VALUE_1");
properties.setProperty("property_1", "value_1");
InterpreterOption option = new InterpreterOption();
option.setUserImpersonate(true);
InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "user1", "intpGroupId", "groupId", "sh", "name", 0, "host");
// when
InterpreterClient client = launcher.launch(context);
// then
assertTrue(client instanceof K8sRemoteInterpreterProcess);
}
use of org.apache.zeppelin.interpreter.InterpreterOption in project zeppelin by apache.
the class ClusterInterpreterLauncherTest method testCreateIntpProcessDockerMode.
@Test
public void testCreateIntpProcessDockerMode() throws IOException {
zconf.setRunMode(ZeppelinConfiguration.RUN_MODE.DOCKER);
ClusterInterpreterLauncher launcher = new ClusterInterpreterLauncher(zconf, null);
Properties properties = new Properties();
properties.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "1000");
InterpreterOption option = new InterpreterOption();
option.setUserImpersonate(true);
InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "user1", "intpGroupId3", "groupId3", "groupName", "name", 0, "host");
InterpreterClient client = launcher.launch(context);
assertTrue(client instanceof DockerInterpreterProcess);
}
Aggregations