Search in sources :

Example 6 with InterpreterOption

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"));
}
Also used : InterpreterOption(org.apache.zeppelin.interpreter.InterpreterOption) ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) Properties(java.util.Properties) Test(org.junit.Test)

Example 7 with InterpreterOption

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"));
}
Also used : InterpreterOption(org.apache.zeppelin.interpreter.InterpreterOption) ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) Properties(java.util.Properties) Test(org.junit.Test)

Example 8 with InterpreterOption

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);
}
Also used : InterpreterOption(org.apache.zeppelin.interpreter.InterpreterOption) Properties(java.util.Properties) Test(org.junit.Test)

Example 9 with InterpreterOption

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());
}
Also used : HeliumApplicationFactory(org.apache.zeppelin.helium.HeliumApplicationFactory) InterpreterOption(org.apache.zeppelin.interpreter.InterpreterOption) LuceneSearch(org.apache.zeppelin.search.LuceneSearch) InterpreterSettingManager(org.apache.zeppelin.interpreter.InterpreterSettingManager) Helium(org.apache.zeppelin.helium.Helium) File(java.io.File) Credentials(org.apache.zeppelin.user.Credentials) DependencyResolver(org.apache.zeppelin.dep.DependencyResolver) HeliumVisualizationFactory(org.apache.zeppelin.helium.HeliumVisualizationFactory) SchedulerFactory(org.apache.zeppelin.scheduler.SchedulerFactory)

Example 10 with InterpreterOption

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()));
}
Also used : Interpreter(org.apache.zeppelin.interpreter.Interpreter) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) ResourcePool(org.apache.zeppelin.resource.ResourcePool) InterpreterSettingManager(org.apache.zeppelin.interpreter.InterpreterSettingManager) InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) InterpreterOption(org.apache.zeppelin.interpreter.InterpreterOption) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) Credentials(org.apache.zeppelin.user.Credentials) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) Test(org.junit.Test)

Aggregations

InterpreterOption (org.apache.zeppelin.interpreter.InterpreterOption)25 Properties (java.util.Properties)20 Test (org.junit.Test)17 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)12 ExecRemoteInterpreterProcess (org.apache.zeppelin.interpreter.remote.ExecRemoteInterpreterProcess)10 InterpreterSettingManager (org.apache.zeppelin.interpreter.InterpreterSettingManager)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 DependencyResolver (org.apache.zeppelin.dep.DependencyResolver)4 InterpreterFactory (org.apache.zeppelin.interpreter.InterpreterFactory)3 InterpreterInfo (org.apache.zeppelin.interpreter.InterpreterInfo)3 Credentials (org.apache.zeppelin.user.Credentials)3 Before (org.junit.Before)3 Path (java.nio.file.Path)2 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)2 Interpreter (org.apache.zeppelin.interpreter.Interpreter)2 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)2 InterpreterResultMessage (org.apache.zeppelin.interpreter.InterpreterResultMessage)2 InterpreterRunner (org.apache.zeppelin.interpreter.InterpreterRunner)2 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)2