Search in sources :

Example 16 with ZeppelinConfiguration

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

the class NotebookRepoSyncInitializationTest method initEmptyStorageTest.

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

Example 17 with ZeppelinConfiguration

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

the class NotebookRepoSyncInitializationTest method initUnsupportedNumberStoragesTest.

@Test
public void initUnsupportedNumberStoragesTest() throws IOException {
    // initialize folders for each storage, currently for 2 only
    String zpath = System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis();
    File mainZepDir = new File(zpath);
    mainZepDir.mkdirs();
    new File(mainZepDir, "conf").mkdirs();
    String mainNotePath = zpath + "/notebook";
    String secNotePath = mainNotePath + "_secondary";
    File mainNotebookDir = new File(mainNotePath);
    File secNotebookDir = new File(secNotePath);
    mainNotebookDir.mkdirs();
    secNotebookDir.mkdirs();
    // set confs
    System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), mainZepDir.getAbsolutePath());
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), mainNotebookDir.getAbsolutePath());
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), unsupportedStorageConf);
    ZeppelinConfiguration conf = ZeppelinConfiguration.create();
    // create repo
    NotebookRepoSync notebookRepoSync = new NotebookRepoSync(conf);
    // check that first two storages initialized instead of three 
    assertEquals(notebookRepoSync.getRepoCount(), 2);
    assertTrue(notebookRepoSync.getRepo(0) instanceof VFSNotebookRepo);
    assertTrue(notebookRepoSync.getRepo(1) instanceof VFSNotebookRepoMock);
}
Also used : VFSNotebookRepoMock(org.apache.zeppelin.notebook.repo.mock.VFSNotebookRepoMock) ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) File(java.io.File) Test(org.junit.Test)

Example 18 with ZeppelinConfiguration

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

the class NotebookRepoSyncInitializationTest method validInitOneStorageTest.

@Test
public void validInitOneStorageTest() throws IOException {
    // no need to initialize folder due to one storage
    // set confs
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), validOneStorageConf);
    ZeppelinConfiguration conf = ZeppelinConfiguration.create();
    // create repo
    NotebookRepoSync notebookRepoSync = new NotebookRepoSync(conf);
    // check proper initialization of one storage
    assertEquals(notebookRepoSync.getRepoCount(), 1);
    assertTrue(notebookRepoSync.getRepo(0) instanceof VFSNotebookRepo);
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) Test(org.junit.Test)

Example 19 with ZeppelinConfiguration

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

the class NotebookRepoSyncInitializationTest method invalidInitTwoStorageTest.

@Test
public void invalidInitTwoStorageTest() throws IOException {
    // set confs
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), invalidTwoStorageConf);
    ZeppelinConfiguration conf = ZeppelinConfiguration.create();
    // create repo
    NotebookRepoSync notebookRepoSync = new NotebookRepoSync(conf);
    // check that second didn't initialize
    LOG.info(" " + notebookRepoSync.getRepoCount());
    assertEquals(notebookRepoSync.getRepoCount(), 1);
    assertTrue(notebookRepoSync.getRepo(0) instanceof VFSNotebookRepo);
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) Test(org.junit.Test)

Example 20 with ZeppelinConfiguration

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

the class ConfigurationsRestApi method getAll.

@GET
@Path("all")
@ZeppelinApi
public Response getAll() {
    ZeppelinConfiguration conf = notebook.getConf();
    Map<String, String> configurations = conf.dumpConfigurations(conf, new ZeppelinConfiguration.ConfigurationKeyPredicate() {

        @Override
        public boolean apply(String key) {
            return !key.contains("password") && !key.equals(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING.getVarName());
        }
    });
    return new JsonResponse(Status.OK, "", configurations).build();
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) JsonResponse(org.apache.zeppelin.server.JsonResponse) Path(javax.ws.rs.Path) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) GET(javax.ws.rs.GET)

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