Search in sources :

Example 6 with ZeppelinConfiguration

use of org.apache.zeppelin.conf.ZeppelinConfiguration in project zeppelin by apache.

the class NotebookRepoSyncInitializationTest method initOneDummyStorageTest.

@Test
public void initOneDummyStorageTest() throws IOException {
    // set confs
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), invalidStorageClass);
    ZeppelinConfiguration conf = ZeppelinConfiguration.create();
    // create repo
    NotebookRepoSync notebookRepoSync = new NotebookRepoSync(conf);
    // check initialization of one default storage instead of invalid one
    assertEquals(notebookRepoSync.getRepoCount(), 1);
    assertTrue(notebookRepoSync.getRepo(0) instanceof VFSNotebookRepo);
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) Test(org.junit.Test)

Example 7 with ZeppelinConfiguration

use of org.apache.zeppelin.conf.ZeppelinConfiguration in project zeppelin by apache.

the class NotebookTest method testPublicPrivateNewNote.

@Test
public void testPublicPrivateNewNote() throws IOException, SchedulerException {
    HashSet<String> user1 = Sets.newHashSet("user1");
    HashSet<String> user2 = Sets.newHashSet("user2");
    // case of public note
    assertTrue(conf.isNotebokPublic());
    assertTrue(notebookAuthorization.isPublic());
    List<Note> notes1 = notebook.getAllNotes(user1);
    List<Note> notes2 = notebook.getAllNotes(user2);
    assertEquals(notes1.size(), 0);
    assertEquals(notes2.size(), 0);
    // user1 creates note
    Note notePublic = notebook.createNote(new AuthenticationInfo("user1"));
    // both users have note
    notes1 = notebook.getAllNotes(user1);
    notes2 = notebook.getAllNotes(user2);
    assertEquals(notes1.size(), 1);
    assertEquals(notes2.size(), 1);
    assertEquals(notes1.get(0).getId(), notePublic.getId());
    assertEquals(notes2.get(0).getId(), notePublic.getId());
    // user1 is only owner
    assertEquals(notebookAuthorization.getOwners(notePublic.getId()).size(), 1);
    assertEquals(notebookAuthorization.getReaders(notePublic.getId()).size(), 0);
    assertEquals(notebookAuthorization.getWriters(notePublic.getId()).size(), 0);
    // case of private note
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_PUBLIC.getVarName(), "false");
    ZeppelinConfiguration conf2 = ZeppelinConfiguration.create();
    assertFalse(conf2.isNotebokPublic());
    // notebook authorization reads from conf, so no need to re-initilize
    assertFalse(notebookAuthorization.isPublic());
    // check that still 1 note per user
    notes1 = notebook.getAllNotes(user1);
    notes2 = notebook.getAllNotes(user2);
    assertEquals(notes1.size(), 1);
    assertEquals(notes2.size(), 1);
    // create private note
    Note notePrivate = notebook.createNote(new AuthenticationInfo("user1"));
    // only user1 have notePrivate right after creation
    notes1 = notebook.getAllNotes(user1);
    notes2 = notebook.getAllNotes(user2);
    assertEquals(notes1.size(), 2);
    assertEquals(notes2.size(), 1);
    assertEquals(true, notes1.contains(notePrivate));
    // user1 have all rights
    assertEquals(notebookAuthorization.getOwners(notePrivate.getId()).size(), 1);
    assertEquals(notebookAuthorization.getReaders(notePrivate.getId()).size(), 1);
    assertEquals(notebookAuthorization.getWriters(notePrivate.getId()).size(), 1);
    //set back public to true
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_PUBLIC.getVarName(), "true");
    ZeppelinConfiguration.create();
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) Test(org.junit.Test)

Example 8 with ZeppelinConfiguration

use of org.apache.zeppelin.conf.ZeppelinConfiguration in project zeppelin by apache.

the class InterpreterFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis());
    tmpDir.mkdirs();
    new File(tmpDir, "conf").mkdirs();
    FileUtils.copyDirectory(new File("src/test/resources/interpreter"), new File(tmpDir, "interpreter"));
    System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), tmpDir.getAbsolutePath());
    System.setProperty(ConfVars.ZEPPELIN_INTERPRETER_GROUP_ORDER.getVarName(), "mock1,mock2,mock11,dev");
    conf = new ZeppelinConfiguration();
    schedulerFactory = new SchedulerFactory();
    depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
    interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
    factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
    context = new InterpreterContext("note", "id", null, "title", "text", null, null, null, null, null, null, null);
    ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>();
    interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, new HashMap<String, Object>()));
    interpreterSettingManager.add("mock1", interpreterInfos, new ArrayList<Dependency>(), new InterpreterOption(), Maps.<String, InterpreterProperty>newHashMap(), "mock1", null);
    Properties intp1Properties = new Properties();
    intp1Properties.put("PROPERTY_1", "VALUE_1");
    intp1Properties.put("property_2", "value_2");
    interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(true), intp1Properties);
    ArrayList<InterpreterInfo> interpreterInfos2 = new ArrayList<>();
    interpreterInfos2.add(new InterpreterInfo(MockInterpreter2.class.getName(), "mock2", true, new HashMap<String, Object>()));
    interpreterSettingManager.add("mock2", interpreterInfos2, new ArrayList<Dependency>(), new InterpreterOption(), Maps.<String, InterpreterProperty>newHashMap(), "mock2", null);
    interpreterSettingManager.createNewSetting("mock2", "mock2", new ArrayList<Dependency>(), new InterpreterOption(), new Properties());
    SearchService search = mock(SearchService.class);
    notebookRepo = new VFSNotebookRepo(conf);
    notebookAuthorization = NotebookAuthorization.init(conf);
    notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, interpreterSettingManager, jobListenerFactory, search, notebookAuthorization, null);
}
Also used : Notebook(org.apache.zeppelin.notebook.Notebook) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Dependency(org.apache.zeppelin.dep.Dependency) Properties(java.util.Properties) SchedulerFactory(org.apache.zeppelin.scheduler.SchedulerFactory) DependencyResolver(org.apache.zeppelin.dep.DependencyResolver) VFSNotebookRepo(org.apache.zeppelin.notebook.repo.VFSNotebookRepo) ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) SearchService(org.apache.zeppelin.search.SearchService) Before(org.junit.Before)

Example 9 with ZeppelinConfiguration

use of org.apache.zeppelin.conf.ZeppelinConfiguration 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, vRepoSync, schedulerFactory, factory, interpreterSettingManager, this, search, notebookAuthorization, credentials);
    // one git versioned storage initialized
    assertThat(vRepoSync.getRepoCount()).isEqualTo(1);
    assertThat(vRepoSync.getRepo(0)).isInstanceOf(GitNotebookRepo.class);
    GitNotebookRepo gitRepo = (GitNotebookRepo) vRepoSync.getRepo(0);
    // no notes
    assertThat(vRepoSync.list(anonymous).size()).isEqualTo(0);
    // create note
    Note note = vNotebookSync.createNote(anonymous);
    assertThat(vRepoSync.list(anonymous).size()).isEqualTo(1);
    String noteId = vRepoSync.list(anonymous).get(0).getId();
    // first checkpoint
    vRepoSync.checkpoint(noteId, "checkpoint message", anonymous);
    int vCount = gitRepo.revisionHistory(noteId, anonymous).size();
    assertThat(vCount).isEqualTo(1);
    Paragraph p = note.addParagraph(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, "checkpoint message 2", anonymous);
    assertThat(gitRepo.revisionHistory(noteId, anonymous).size()).isEqualTo(vCount + 1);
    notebookRepoSync.remove(note.getId(), anonymous);
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) Test(org.junit.Test)

Example 10 with ZeppelinConfiguration

use of org.apache.zeppelin.conf.ZeppelinConfiguration in project zeppelin by apache.

the class VFSNotebookRepoMock method modifyNotebookDir.

private static ZeppelinConfiguration modifyNotebookDir(ZeppelinConfiguration conf) {
    String secNotebookDir = conf.getNotebookDir() + "_secondary";
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), secNotebookDir);
    ZeppelinConfiguration secConf = ZeppelinConfiguration.create();
    return secConf;
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration)

Aggregations

ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)24 Test (org.junit.Test)10 File (java.io.File)6 IOException (java.io.IOException)4 HashMap (java.util.HashMap)3 Properties (java.util.Properties)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 ZeppelinApi (org.apache.zeppelin.annotation.ZeppelinApi)3 Notebook (org.apache.zeppelin.notebook.Notebook)3 JsonResponse (org.apache.zeppelin.server.JsonResponse)3 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)3 Before (org.junit.Before)3 ArrayList (java.util.ArrayList)2 Dependency (org.apache.zeppelin.dep.Dependency)2 DependencyResolver (org.apache.zeppelin.dep.DependencyResolver)2 InterpreterResultMessage (org.apache.zeppelin.interpreter.InterpreterResultMessage)2 VFSNotebookRepo (org.apache.zeppelin.notebook.repo.VFSNotebookRepo)2 VFSNotebookRepoMock (org.apache.zeppelin.notebook.repo.mock.VFSNotebookRepoMock)2 Message (org.apache.zeppelin.notebook.socket.Message)2