use of org.apache.zeppelin.notebook.repo.NotebookRepo in project zeppelin by apache.
the class NotebookTest method testRevisionSupported.
@Test
public void testRevisionSupported() throws IOException {
NotebookRepo notebookRepo;
Notebook notebook;
notebookRepo = new DummyNotebookRepo();
notebook = new Notebook(conf, mock(AuthorizationService.class), notebookRepo, new NoteManager(notebookRepo, conf), interpreterFactory, interpreterSettingManager, credentials, null);
assertFalse("Revision is not supported in DummyNotebookRepo", notebook.isRevisionSupported());
notebookRepo = new DummyNotebookRepoWithVersionControl();
notebook = new Notebook(conf, mock(AuthorizationService.class), notebookRepo, new NoteManager(notebookRepo, conf), interpreterFactory, interpreterSettingManager, credentials, null);
assertTrue("Revision is supported in DummyNotebookRepoWithVersionControl", notebook.isRevisionSupported());
}
use of org.apache.zeppelin.notebook.repo.NotebookRepo 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.repo.NotebookRepo in project zeppelin by apache.
the class PluginManager method loadNotebookRepo.
public NotebookRepo loadNotebookRepo(String notebookRepoClassName) throws IOException {
LOGGER.info("Loading NotebookRepo Plugin: {}", notebookRepoClassName);
if (builtinNotebookRepoClassNames.contains(notebookRepoClassName) || Boolean.parseBoolean(System.getProperty("zeppelin.isTest", "false"))) {
try {
return (NotebookRepo) (Class.forName(notebookRepoClassName).newInstance());
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new IOException("Fail to instantiate notebookrepo from classpath directly:" + notebookRepoClassName, e);
}
}
String simpleClassName = notebookRepoClassName.substring(notebookRepoClassName.lastIndexOf(".") + 1);
URLClassLoader pluginClassLoader = getPluginClassLoader(pluginsDir, "NotebookRepo", simpleClassName);
if (pluginClassLoader == null) {
return null;
}
NotebookRepo notebookRepo = null;
try {
notebookRepo = (NotebookRepo) (Class.forName(notebookRepoClassName, true, pluginClassLoader)).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new IOException("Fail to instantiate notebookrepo " + notebookRepoClassName + " from plugin classpath:" + pluginsDir, e);
}
return notebookRepo;
}
use of org.apache.zeppelin.notebook.repo.NotebookRepo 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);
}
use of org.apache.zeppelin.notebook.repo.NotebookRepo in project zeppelin by apache.
the class PluginManagerTest method testLoadGitNotebookRepo.
@Test
public void testLoadGitNotebookRepo() throws IOException {
NotebookRepo notebookRepo = PluginManager.get().loadNotebookRepo("org.apache.zeppelin.notebook.repo.GitNotebookRepo");
assertTrue(notebookRepo instanceof GitNotebookRepo);
}
Aggregations