[ZEPPELIN-2216] added tests

This commit is contained in:
Tinkoff DWH 2017-04-24 12:05:45 +05:00
parent 5a482a0221
commit e4cf72f135

View file

@ -58,7 +58,7 @@ public class RemoteInterpreterTest {
private static final String INTERPRETER_SCRIPT =
System.getProperty("os.name").startsWith("Windows") ?
"../bin/interpreter.cmd" :
"../bin/interpreter.sh";
"bin/interpreter.sh";
private InterpreterGroup intpGroup;
private HashMap<String, String> env;
@ -170,6 +170,79 @@ public class RemoteInterpreterTest {
}
@Test
public void testExecuteIncorrectPrecode() throws TTransportException, IOException {
Properties p = new Properties();
p.put("zeppelin.MockInterpreterA.precode", "fail test");
intpGroup.put("note", new LinkedList<Interpreter>());
RemoteInterpreter intpA = createMockInterpreterA(p);
intpGroup.get("note").add(intpA);
intpA.setInterpreterGroup(intpGroup);
RemoteInterpreterProcess process = intpA.getInterpreterProcess();
intpA.open();
InterpreterResult result = intpA.interpret("1",
new InterpreterContext(
"note",
"id",
null,
"title",
"text",
new AuthenticationInfo(),
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
new LocalResourcePool("pool1"),
new LinkedList<InterpreterContextRunner>(), null));
intpA.close();
assertEquals(Code.ERROR, result.code());
}
@Test
public void testExecuteCorrectPrecode() throws TTransportException, IOException {
Properties p = new Properties();
p.put("zeppelin.MockInterpreterA.precode", "2");
intpGroup.put("note", new LinkedList<Interpreter>());
RemoteInterpreter intpA = createMockInterpreterA(p);
intpGroup.get("note").add(intpA);
intpA.setInterpreterGroup(intpGroup);
RemoteInterpreterProcess process = intpA.getInterpreterProcess();
intpA.open();
InterpreterResult result = intpA.interpret("1",
new InterpreterContext(
"note",
"id",
null,
"title",
"text",
new AuthenticationInfo(),
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
new LocalResourcePool("pool1"),
new LinkedList<InterpreterContextRunner>(), null));
intpA.close();
assertEquals(Code.SUCCESS, result.code());
assertEquals("1", result.message().get(0).getData());
}
@Test
public void testRemoteInterperterErrorStatus() throws TTransportException, IOException {
Properties p = new Properties();