use of org.apache.zeppelin.notebook.AuthorizationService in project zeppelin by apache.
the class ClusterEventTest method init.
@BeforeClass
public static void init() throws Exception {
ZeppelinConfiguration zconf = genZeppelinConf();
ZeppelinServerMock.startUp("ClusterEventTest", zconf);
notebook = TestUtils.getInstance(Notebook.class);
authorizationService = TestUtils.getInstance(AuthorizationService.class);
schedulerService = new QuartzSchedulerService(zconf, notebook);
schedulerService.waitForFinishInit();
notebookServer = spy(NotebookServer.getInstance());
notebookService = new NotebookService(notebook, authorizationService, zconf, schedulerService);
ConfigurationService configurationService = new ConfigurationService(notebook.getConf());
when(notebookServer.getNotebookService()).thenReturn(notebookService);
when(notebookServer.getConfigurationService()).thenReturn(configurationService);
startOtherZeppelinClusterNode(zconf);
// wait zeppelin cluster startup
Thread.sleep(10000);
// mock cluster manager client
clusterClient = ClusterManagerClient.getInstance(zconf);
clusterClient.start(metaKey);
// Waiting for cluster startup
int wait = 0;
while (wait++ < 100) {
if (clusterIsStartup() && clusterClient.raftInitialized()) {
LOGGER.info("wait {}(ms) found cluster leader", wait * 500);
break;
}
try {
Thread.sleep(500);
} catch (InterruptedException e) {
LOGGER.error(e.getMessage(), e);
}
}
Thread.sleep(3000);
assertEquals(true, clusterIsStartup());
getClusterServerMeta();
}
use of org.apache.zeppelin.notebook.AuthorizationService in project zeppelin by apache.
the class NotebookRepoSyncTest method setUp.
@Before
public void setUp() throws Exception {
System.setProperty("zeppelin.isTest", "true");
ZEPPELIN_HOME = Files.createTempDir();
new File(ZEPPELIN_HOME, "conf").mkdirs();
String mainNotePath = ZEPPELIN_HOME.getAbsolutePath() + "/notebook";
String secNotePath = ZEPPELIN_HOME.getAbsolutePath() + "/notebook_secondary";
mainNotebookDir = new File(mainNotePath);
secNotebookDir = new File(secNotePath);
mainNotebookDir.mkdirs();
secNotebookDir.mkdirs();
System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), ZEPPELIN_HOME.getAbsolutePath());
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), mainNotebookDir.getAbsolutePath());
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), "org.apache.zeppelin.notebook.repo.VFSNotebookRepo,org.apache.zeppelin.notebook.repo.mock.VFSNotebookRepoMock");
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_ONE_WAY_SYNC.getVarName(), "false");
System.setProperty(ConfVars.ZEPPELIN_CONFIG_FS_DIR.getVarName(), ZEPPELIN_HOME.getAbsolutePath() + "/conf");
System.setProperty(ConfVars.ZEPPELIN_PLUGINS_DIR.getVarName(), new File("../../../plugins").getAbsolutePath());
LOG.info("main Note dir : " + mainNotePath);
LOG.info("secondary note dir : " + secNotePath);
conf = ZeppelinConfiguration.create();
ConfigStorage.reset();
interpreterSettingManager = new InterpreterSettingManager(conf, mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
factory = new InterpreterFactory(interpreterSettingManager);
notebookRepoSync = new NotebookRepoSync(conf);
noteManager = new NoteManager(notebookRepoSync, conf);
authorizationService = new AuthorizationService(noteManager, conf);
credentials = new Credentials(conf);
notebook = new Notebook(conf, authorizationService, notebookRepoSync, noteManager, factory, interpreterSettingManager, credentials, null);
anonymous = new AuthenticationInfo("anonymous");
}
use of org.apache.zeppelin.notebook.AuthorizationService in project zeppelin by apache.
the class AbstractInterpreterTest method setUp.
@Before
public void setUp() throws Exception {
// copy the resources files to a temp folder
zeppelinHome = new File("..");
LOGGER.info("ZEPPELIN_HOME: " + zeppelinHome.getAbsolutePath());
interpreterDir = new File(zeppelinHome, "interpreter_" + getClass().getSimpleName());
confDir = new File(zeppelinHome, "conf_" + getClass().getSimpleName());
notebookDir = new File(zeppelinHome, "notebook_" + getClass().getSimpleName());
FileUtils.deleteDirectory(notebookDir);
interpreterDir.mkdirs();
confDir.mkdirs();
notebookDir.mkdirs();
FileUtils.copyDirectory(new File("src/test/resources/interpreter"), interpreterDir);
FileUtils.copyDirectory(new File("src/test/resources/conf"), confDir);
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), zeppelinHome.getAbsolutePath());
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(), confDir.getAbsolutePath());
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_DIR.getVarName(), interpreterDir.getAbsolutePath());
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_GROUP_DEFAULT.getVarName(), "test");
conf = ZeppelinConfiguration.create();
NotebookRepo notebookRepo = new InMemoryNotebookRepo();
NoteManager noteManager = new NoteManager(notebookRepo, conf);
AuthorizationService authorizationService = new AuthorizationService(noteManager, conf);
interpreterSettingManager = new InterpreterSettingManager(conf, mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
interpreterFactory = new InterpreterFactory(interpreterSettingManager);
Credentials credentials = new Credentials(conf);
notebook = new Notebook(conf, authorizationService, notebookRepo, noteManager, interpreterFactory, interpreterSettingManager, credentials);
interpreterSettingManager.setNotebook(notebook);
}
use of org.apache.zeppelin.notebook.AuthorizationService in project zeppelin by apache.
the class ZeppelinServer method setupClusterManagerServer.
private static void setupClusterManagerServer(ServiceLocator serviceLocator) {
if (conf.isClusterMode()) {
LOG.info("Cluster mode is enabled, starting ClusterManagerServer");
ClusterManagerServer clusterManagerServer = ClusterManagerServer.getInstance(conf);
NotebookServer notebookServer = serviceLocator.getService(NotebookServer.class);
clusterManagerServer.addClusterEventListeners(ClusterManagerServer.CLUSTER_NOTE_EVENT_TOPIC, notebookServer);
AuthorizationService authorizationService = serviceLocator.getService(AuthorizationService.class);
clusterManagerServer.addClusterEventListeners(ClusterManagerServer.CLUSTER_AUTH_EVENT_TOPIC, authorizationService);
InterpreterSettingManager interpreterSettingManager = serviceLocator.getService(InterpreterSettingManager.class);
clusterManagerServer.addClusterEventListeners(ClusterManagerServer.CLUSTER_INTP_SETTING_EVENT_TOPIC, interpreterSettingManager);
// This allows the ClusterInterpreterLauncher to listen for cluster events.
try {
InterpreterSettingManager intpSettingManager = sharedServiceLocator.getService(InterpreterSettingManager.class);
RecoveryStorage recoveryStorage = ReflectionUtils.createClazzInstance(conf.getRecoveryStorageClass(), new Class[] { ZeppelinConfiguration.class, InterpreterSettingManager.class }, new Object[] { conf, intpSettingManager });
recoveryStorage.init();
PluginManager.get().loadInterpreterLauncher(InterpreterSetting.CLUSTER_INTERPRETER_LAUNCHER_NAME, recoveryStorage);
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
clusterManagerServer.start();
} else {
LOG.info("Cluster mode is disabled");
}
}
use of org.apache.zeppelin.notebook.AuthorizationService in project zeppelin by apache.
the class NotebookServiceTest method setUp.
@Before
public void setUp() throws Exception {
notebookDir = Files.createTempDirectory("notebookDir").toAbsolutePath().toFile();
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
ZeppelinConfiguration zeppelinConfiguration = ZeppelinConfiguration.create();
NotebookRepo notebookRepo = new VFSNotebookRepo();
notebookRepo.init(zeppelinConfiguration);
InterpreterSettingManager mockInterpreterSettingManager = mock(InterpreterSettingManager.class);
InterpreterFactory mockInterpreterFactory = mock(InterpreterFactory.class);
Interpreter mockInterpreter = mock(Interpreter.class);
when(mockInterpreterFactory.getInterpreter(any(), any())).thenReturn(mockInterpreter);
when(mockInterpreter.interpret(eq("invalid_code"), any())).thenReturn(new InterpreterResult(Code.ERROR, "failed"));
when(mockInterpreter.interpret(eq("1+1"), any())).thenReturn(new InterpreterResult(Code.SUCCESS, "succeed"));
doCallRealMethod().when(mockInterpreter).getScheduler();
when(mockInterpreter.getFormType()).thenReturn(FormType.NATIVE);
ManagedInterpreterGroup mockInterpreterGroup = mock(ManagedInterpreterGroup.class);
when(mockInterpreter.getInterpreterGroup()).thenReturn(mockInterpreterGroup);
InterpreterSetting mockInterpreterSetting = mock(InterpreterSetting.class);
when(mockInterpreterSetting.isUserAuthorized(any())).thenReturn(true);
when(mockInterpreterGroup.getInterpreterSetting()).thenReturn(mockInterpreterSetting);
when(mockInterpreterSetting.getStatus()).thenReturn(InterpreterSetting.Status.READY);
Credentials credentials = new Credentials();
NoteManager noteManager = new NoteManager(notebookRepo, zeppelinConfiguration);
AuthorizationService authorizationService = new AuthorizationService(noteManager, zeppelinConfiguration);
notebook = new Notebook(zeppelinConfiguration, authorizationService, notebookRepo, noteManager, mockInterpreterFactory, mockInterpreterSettingManager, credentials, null);
searchService = new LuceneSearch(zeppelinConfiguration, notebook);
QuartzSchedulerService schedulerService = new QuartzSchedulerService(zeppelinConfiguration, notebook);
schedulerService.waitForFinishInit();
notebookService = new NotebookService(notebook, authorizationService, zeppelinConfiguration, schedulerService);
String interpreterName = "test";
when(mockInterpreterSetting.getName()).thenReturn(interpreterName);
when(mockInterpreterSettingManager.getDefaultInterpreterSetting()).thenReturn(mockInterpreterSetting);
}
Aggregations