Search in sources :

Example 21 with Dependency

use of org.apache.zeppelin.dep.Dependency in project zeppelin by apache.

the class InterpreterFactoryTest method testInterpreterSettingPropertyClass.

@Test
public void testInterpreterSettingPropertyClass() throws IOException, RepositoryException {
    // check if default interpreter reference's property type is map
    Map<String, InterpreterSetting> interpreterSettingRefs = interpreterSettingManager.getAvailableInterpreterSettings();
    InterpreterSetting intpSetting = interpreterSettingRefs.get("mock1");
    Map<String, InterpreterProperty> intpProperties = (Map<String, InterpreterProperty>) intpSetting.getProperties();
    assertTrue(intpProperties instanceof Map);
    // check if interpreter instance is saved as Properties in conf/interpreter.json file
    Properties properties = new Properties();
    properties.put("key1", "value1");
    properties.put("key2", "value2");
    interpreterSettingManager.createNewSetting("newMock", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), properties);
    String confFilePath = conf.getInterpreterSettingPath();
    byte[] encoded = Files.readAllBytes(Paths.get(confFilePath));
    String json = new String(encoded, "UTF-8");
    Gson gson = new Gson();
    InterpreterInfoSaving infoSaving = gson.fromJson(json, InterpreterInfoSaving.class);
    Map<String, InterpreterSetting> interpreterSettings = infoSaving.interpreterSettings;
    for (String key : interpreterSettings.keySet()) {
        InterpreterSetting setting = interpreterSettings.get(key);
        if (setting.getName().equals("newMock")) {
            assertEquals(setting.getProperties().toString(), properties.toString());
        }
    }
}
Also used : Gson(com.google.gson.Gson) Dependency(org.apache.zeppelin.dep.Dependency) Properties(java.util.Properties) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 22 with Dependency

use of org.apache.zeppelin.dep.Dependency in project zeppelin by apache.

the class InterpreterFactoryTest method testSaveLoad.

@Test
public void testSaveLoad() throws IOException, RepositoryException {
    // interpreter settings
    int numInterpreters = interpreterSettingManager.get().size();
    // check if file saved
    assertTrue(new File(conf.getInterpreterSettingPath()).exists());
    interpreterSettingManager.createNewSetting("new-mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new Properties());
    assertEquals(numInterpreters + 1, interpreterSettingManager.get().size());
    interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
    /*
     Current situation, if InterpreterSettinfRef doesn't have the key of InterpreterSetting, it would be ignored.
     Thus even though interpreter.json have several interpreterSetting in that file, it would be ignored and would not be initialized from loadFromFile.
     In this case, only "mock11" would be referenced from file under interpreter/mock, and "mock11" group would be initialized.
     */
    // TODO(jl): Decide how to handle the know referenced interpreterSetting.
    assertEquals(1, interpreterSettingManager.get().size());
}
Also used : Dependency(org.apache.zeppelin.dep.Dependency) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

Dependency (org.apache.zeppelin.dep.Dependency)22 Properties (java.util.Properties)17 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)8 RemoteInterpreter (org.apache.zeppelin.interpreter.remote.RemoteInterpreter)6 File (java.io.File)5 DependencyResolver (org.apache.zeppelin.dep.DependencyResolver)4 SchedulerFactory (org.apache.zeppelin.scheduler.SchedulerFactory)4 SearchService (org.apache.zeppelin.search.SearchService)4 Before (org.junit.Before)4 VFSNotebookRepo (org.apache.zeppelin.notebook.repo.VFSNotebookRepo)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 Map (java.util.Map)2 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)2 Notebook (org.apache.zeppelin.notebook.Notebook)2 Credentials (org.apache.zeppelin.user.Credentials)2 RepositoryException (org.sonatype.aether.RepositoryException)2