use of org.apache.zeppelin.notebook.Notebook in project zeppelin by apache.
the class NotebookRepoSyncTest method testCheckpointOneStorage.
@Test
public void testCheckpointOneStorage() throws IOException, SchedulerException {
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), "org.apache.zeppelin.notebook.repo.GitNotebookRepo");
ZeppelinConfiguration vConf = ZeppelinConfiguration.create();
NotebookRepoSync vRepoSync = new NotebookRepoSync(vConf);
Notebook vNotebookSync = new Notebook(vConf, mock(AuthorizationService.class), vRepoSync, new NoteManager(vRepoSync, conf), factory, interpreterSettingManager, credentials, null);
// one git versioned storage initialized
assertEquals(1, vRepoSync.getRepoCount());
assertTrue(vRepoSync.getRepo(0) instanceof GitNotebookRepo);
GitNotebookRepo gitRepo = (GitNotebookRepo) vRepoSync.getRepo(0);
// no notes
assertEquals(0, vRepoSync.list(anonymous).size());
// create note
String noteIdTmp = vNotebookSync.createNote("/test", "test", anonymous);
System.out.println(noteIdTmp);
Note note = vNotebookSync.processNote(noteIdTmp, noteTmp -> {
return noteTmp;
});
assertEquals(1, vRepoSync.list(anonymous).size());
System.out.println(note);
NoteInfo noteInfo = vRepoSync.list(anonymous).values().iterator().next();
String noteId = noteInfo.getId();
String notePath = noteInfo.getPath();
// first checkpoint
vRepoSync.checkpoint(noteId, notePath, "checkpoint message", anonymous);
int vCount = gitRepo.revisionHistory(noteId, notePath, anonymous).size();
assertEquals(1, vCount);
note.setInterpreterFactory(mock(InterpreterFactory.class));
Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
Map<String, Object> config = p.getConfig();
config.put("enabled", true);
p.setConfig(config);
p.setText("%md checkpoint test");
// save and checkpoint again
vRepoSync.save(note, anonymous);
vRepoSync.checkpoint(noteId, notePath, "checkpoint message 2", anonymous);
assertEquals(vCount + 1, gitRepo.revisionHistory(noteId, notePath, anonymous).size());
notebookRepoSync.remove(note.getId(), note.getPath(), anonymous);
}
use of org.apache.zeppelin.notebook.Notebook 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.Notebook in project zeppelin by apache.
the class LuceneSearchTest method startUp.
@Before
public void startUp() throws IOException {
indexDir = Files.createTempDirectory("lucene").toFile();
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_SEARCH_INDEX_PATH.getVarName(), indexDir.getAbsolutePath());
ZeppelinConfiguration conf = ZeppelinConfiguration.create();
noteManager = new NoteManager(new InMemoryNotebookRepo(), conf);
interpreterSettingManager = mock(InterpreterSettingManager.class);
InterpreterSetting defaultInterpreterSetting = mock(InterpreterSetting.class);
when(defaultInterpreterSetting.getName()).thenReturn("test");
when(interpreterSettingManager.getDefaultInterpreterSetting()).thenReturn(defaultInterpreterSetting);
notebook = new Notebook(conf, mock(AuthorizationService.class), mock(NotebookRepo.class), noteManager, mock(InterpreterFactory.class), interpreterSettingManager, mock(Credentials.class), null);
noteSearchService = new LuceneSearch(ZeppelinConfiguration.create(), notebook);
}
use of org.apache.zeppelin.notebook.Notebook 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.Notebook in project zeppelin by apache.
the class ZeppelinClientIntegrationTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HELIUM_REGISTRY.getVarName(), "helium");
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_ALLOWED_ORIGINS.getVarName(), "*");
AbstractTestRestApi.startUp(ZeppelinClientIntegrationTest.class.getSimpleName());
notebook = TestUtils.getInstance(Notebook.class);
clientConfig = new ClientConfig("http://localhost:8080");
zeppelinClient = new ZeppelinClient(clientConfig);
}
Aggregations