Search in sources :

Example 11 with ZeppelinConfiguration

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

the class ZeppelinHubRepoTest method setUp.

@Before
public void setUp() throws Exception {
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, testAddr);
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_TOKEN, token);
    ZeppelinConfiguration conf = new ZeppelinConfiguration();
    repo = new ZeppelinHubRepo(conf);
    repo.setZeppelinhubRestApiHandler(getMockedZeppelinHandler());
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) Before(org.junit.Before)

Example 12 with ZeppelinConfiguration

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

the class ZeppelinHubRepoTest method testGetZeppelinHubWsEndpoint.

@Test
public void testGetZeppelinHubWsEndpoint() {
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, testAddr);
    ZeppelinConfiguration config = new ZeppelinConfiguration();
    ZeppelinHubRepo repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinhubWebsocketUri(config)).isEqualTo("ws://zeppelinhub.ltd:80/async");
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "https://zeppelinhub.ltd");
    config = new ZeppelinConfiguration();
    repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinhubWebsocketUri(config)).isEqualTo("wss://zeppelinhub.ltd:443/async");
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "yolow");
    config = new ZeppelinConfiguration();
    repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinhubWebsocketUri(config)).isEqualTo("wss://www.zeppelinhub.com:443/async");
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "http://zeppelinhub.ltd:4242");
    config = new ZeppelinConfiguration();
    repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinhubWebsocketUri(config)).isEqualTo("ws://zeppelinhub.ltd:4242/async");
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "https://www.zeppelinhub.com");
    config = new ZeppelinConfiguration();
    repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinhubWebsocketUri(config)).isEqualTo("wss://www.zeppelinhub.com:443/async");
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "http://www.zeppelinhub.com");
    config = new ZeppelinConfiguration();
    repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinhubWebsocketUri(config)).isEqualTo("ws://www.zeppelinhub.com:80/async");
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "https://www.zeppelinhub.com:4242");
    config = new ZeppelinConfiguration();
    repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinhubWebsocketUri(config)).isEqualTo("wss://www.zeppelinhub.com:4242/async");
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) Test(org.junit.Test)

Example 13 with ZeppelinConfiguration

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

the class ZeppelinHubRepoTest method testGetZeppelinhubUrl.

@Test
public void testGetZeppelinhubUrl() {
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, testAddr);
    ZeppelinConfiguration config = new ZeppelinConfiguration();
    ZeppelinHubRepo repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinHubUrl(config)).isEqualTo("http://zeppelinhub.ltd");
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "yolow");
    config = new ZeppelinConfiguration();
    repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinHubUrl(config)).isEqualTo("https://www.zeppelinhub.com");
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "http://zeppelinhub.ltd:4242");
    config = new ZeppelinConfiguration();
    repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinHubUrl(config)).isEqualTo("http://zeppelinhub.ltd:4242");
    System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "http://zeppelinhub.ltd:0");
    config = new ZeppelinConfiguration();
    repository = new ZeppelinHubRepo(config);
    assertThat(repository.getZeppelinHubUrl(config)).isEqualTo("http://zeppelinhub.ltd");
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) Test(org.junit.Test)

Example 14 with ZeppelinConfiguration

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

the class HeliumApplicationFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZepelinLTest_" + System.currentTimeMillis());
    tmpDir.mkdirs();
    File confDir = new File(tmpDir, "conf");
    confDir.mkdirs();
    notebookDir = new File(tmpDir + "/notebook");
    notebookDir.mkdirs();
    File home = // zeppelin/zeppelin-zengine/target/test-classes/note
    new File(getClass().getClassLoader().getResource("note").getFile()).getParentFile().getParentFile().getParentFile().getParentFile();
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), home.getAbsolutePath());
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(), tmpDir.getAbsolutePath() + "/conf");
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
    conf = new ZeppelinConfiguration();
    this.schedulerFactory = new SchedulerFactory();
    heliumAppFactory = new HeliumApplicationFactory();
    depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
    interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
    factory = new InterpreterFactory(conf, null, null, heliumAppFactory, depResolver, false, interpreterSettingManager);
    HashMap<String, String> env = new HashMap<>();
    env.put("ZEPPELIN_CLASSPATH", new File("./target/test-classes").getAbsolutePath());
    factory.setEnv(env);
    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);
    interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(true), new Properties());
    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 = NotebookAuthorization.init(conf);
    notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, interpreterSettingManager, this, search, notebookAuthorization, new Credentials(false, null));
    heliumAppFactory.setNotebook(notebook);
    notebook.addNotebookEventListener(heliumAppFactory);
    anonymous = new AuthenticationInfo("anonymous");
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Dependency(org.apache.zeppelin.dep.Dependency) Properties(java.util.Properties) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) 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) File(java.io.File) Credentials(org.apache.zeppelin.user.Credentials) Before(org.junit.Before)

Example 15 with ZeppelinConfiguration

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

the class NotebookRepoSyncInitializationTest method validInitTwoStorageTest.

@Test
public void validInitTwoStorageTest() throws IOException {
    // initialize folders for each storage
    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(), validTwoStorageConf);
    ZeppelinConfiguration conf = ZeppelinConfiguration.create();
    // create repo
    NotebookRepoSync notebookRepoSync = new NotebookRepoSync(conf);
    // check that both initialized
    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)

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