use of org.apache.zeppelin.interpreter.InterpreterOption in project zeppelin by apache.
the class K8sStandardInterpreterLauncherTest method testK8sLauncherWithSparkAndUserImpersonate.
@Test
public void testK8sLauncherWithSparkAndUserImpersonate() 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");
properties.setProperty("SERVICE_DOMAIN", "example.com");
properties.setProperty("zeppelin.interpreter.connect.timeout", "60");
InterpreterOption option = new InterpreterOption();
option.setUserImpersonate(true);
InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, // username
"user1", // interpretergroupId
"spark-user1", // interpreterSettingId
"dummy", // interpreterSettingGroup
"spark", // interpreterSettingName
"spark", 0, "host");
// when
InterpreterClient client = launcher.launch(context);
// then
assertTrue(client instanceof K8sRemoteInterpreterProcess);
K8sRemoteInterpreterProcess process = (K8sRemoteInterpreterProcess) client;
assertTrue(process.isSpark());
assertTrue(process.buildSparkSubmitOptions(context.getUserName()).contains("--proxy-user user1"));
}
use of org.apache.zeppelin.interpreter.InterpreterOption in project zeppelin by apache.
the class K8sStandardInterpreterLauncherTest method testK8sLauncherWithSparkAndWithoutUserImpersonate.
@Test
public void testK8sLauncherWithSparkAndWithoutUserImpersonate() 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");
properties.setProperty("SERVICE_DOMAIN", "example.com");
properties.setProperty("zeppelin.interpreter.connect.timeout", "60");
InterpreterOption option = new InterpreterOption();
option.setUserImpersonate(false);
InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, // username
"user1", // interpretergroupId
"spark-user1", // interpreterSettingId
"dummy", // interpreterSettingGroup
"spark", // interpreterSettingName
"spark", 0, "host");
// when
InterpreterClient client = launcher.launch(context);
// then
assertTrue(client instanceof K8sRemoteInterpreterProcess);
K8sRemoteInterpreterProcess process = (K8sRemoteInterpreterProcess) client;
assertTrue(process.isSpark());
assertFalse(process.buildSparkSubmitOptions(context.getUserName()).contains("--proxy-user user1"));
}
use of org.apache.zeppelin.interpreter.InterpreterOption in project zeppelin by apache.
the class ClusterInterpreterLauncherTest method testCreateIntpProcessLocalMode.
@Test
public void testCreateIntpProcessLocalMode() throws IOException {
zconf.setRunMode(ZeppelinConfiguration.RUN_MODE.LOCAL);
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", "intpGroupId4", "groupId4", "groupName", "name", 0, "host");
InterpreterClient client = launcher.launch(context);
assertTrue(client instanceof ClusterInterpreterProcess);
}
use of org.apache.zeppelin.interpreter.InterpreterOption in project SSM by Intel-bigdata.
the class SmartZeppelinServer method init.
private void init() throws Exception {
this.depResolver = new DependencyResolver(zconf.getString(ConfVars.ZEPPELIN_INTERPRETER_LOCALREPO));
InterpreterOutput.limit = zconf.getInt(ConfVars.ZEPPELIN_INTERPRETER_OUTPUT_LIMIT);
HeliumApplicationFactory heliumApplicationFactory = new HeliumApplicationFactory();
HeliumVisualizationFactory heliumVisualizationFactory;
if (isBinaryPackage(zconf)) {
/* In binary package, zeppelin-web/src/app/visualization and zeppelin-web/src/app/tabledata
* are copied to lib/node_modules/zeppelin-vis, lib/node_modules/zeppelin-tabledata directory.
* Check zeppelin/zeppelin-distribution/src/assemble/distribution.xml to see how they're
* packaged into binary package.
*/
heliumVisualizationFactory = new HeliumVisualizationFactory(zconf, new File(zconf.getRelativeDir(ConfVars.ZEPPELIN_DEP_LOCALREPO)), new File(zconf.getRelativeDir("lib/node_modules/zeppelin-tabledata")), new File(zconf.getRelativeDir("lib/node_modules/zeppelin-vis")));
} else {
heliumVisualizationFactory = new HeliumVisualizationFactory(zconf, new File(zconf.getRelativeDir(ConfVars.ZEPPELIN_DEP_LOCALREPO)), // new File(zconf.getRelativeDir("zeppelin-web/src/app/visualization")));
new File(zconf.getRelativeDir("smart-zeppelin/zeppelin-web/src/app/tabledata")), new File(zconf.getRelativeDir("smart-zeppelin/zeppelin-web/src/app/visualization")));
}
this.helium = new Helium(zconf.getHeliumConfPath(), zconf.getHeliumDefaultLocalRegistryPath(), heliumVisualizationFactory, heliumApplicationFactory);
// create visualization bundle
try {
heliumVisualizationFactory.bundle(helium.getVisualizationPackagesToBundle());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
this.schedulerFactory = new SchedulerFactory();
this.interpreterSettingManager = new InterpreterSettingManager(zconf, depResolver, new InterpreterOption(true));
this.noteSearchService = new LuceneSearch();
this.notebookAuthorization = NotebookAuthorization.init(zconf);
this.credentials = new Credentials(zconf.credentialsPersist(), zconf.getCredentialsPath());
}
use of org.apache.zeppelin.interpreter.InterpreterOption in project SSM by Intel-bigdata.
the class ParagraphTest method returnUnchangedResultsWithDifferentUser.
@Test
public void returnUnchangedResultsWithDifferentUser() throws Throwable {
InterpreterSettingManager mockInterpreterSettingManager = mock(InterpreterSettingManager.class);
Note mockNote = mock(Note.class);
when(mockNote.getCredentials()).thenReturn(mock(Credentials.class));
Paragraph spyParagraph = spy(new Paragraph("para_1", mockNote, null, null, mockInterpreterSettingManager));
doReturn("spy").when(spyParagraph).getRequiredReplName();
Interpreter mockInterpreter = mock(Interpreter.class);
doReturn(mockInterpreter).when(spyParagraph).getRepl(anyString());
InterpreterGroup mockInterpreterGroup = mock(InterpreterGroup.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(Lists.<InterpreterSetting>newArrayList());
InterpreterSetting mockInterpreterSetting = mock(InterpreterSetting.class);
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.getInterpreterGroup(anyString(), anyString())).thenReturn(mockInterpreterGroup);
spyInterpreterSettingList.add(mockInterpreterSetting);
when(mockNote.getId()).thenReturn("any_id");
when(mockInterpreterSettingManager.getInterpreterSettings(anyString())).thenReturn(spyInterpreterSettingList);
doReturn("spy script body").when(spyParagraph).getScriptBody();
when(mockInterpreter.getFormType()).thenReturn(FormType.NONE);
ParagraphJobListener mockJobListener = mock(ParagraphJobListener.class);
doReturn(mockJobListener).when(spyParagraph).getListener();
doNothing().when(mockJobListener).onOutputUpdateAll(Mockito.<Paragraph>any(), Mockito.anyList());
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 = Lists.newArrayList();
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());
List<InterpreterResultMessage> result2 = Lists.newArrayList();
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()));
}
Aggregations