mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
bring back test
This commit is contained in:
parent
d43f03da9e
commit
bc2b4f6e66
1 changed files with 43 additions and 0 deletions
|
|
@ -286,6 +286,49 @@ public class IPythonInterpreterTest extends BasePythonInterpreterTest {
|
|||
context.out.toInterpreterResultMessage().get(1).getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIpython_shouldNotHang_whenCallingAutoCompleteAndInterpretConcurrently()
|
||||
throws InterpreterException,
|
||||
InterruptedException, TimeoutException, ExecutionException {
|
||||
tearDown();
|
||||
Properties properties = initIntpProperties();
|
||||
startInterpreter(properties);
|
||||
final String code = "import time\n"
|
||||
+ "print(1)\n"
|
||||
+ "time.sleep(10)\n"
|
||||
+ "print(2)";
|
||||
final String base = "time.";
|
||||
|
||||
// The goal of this test is to ensure that concurrent interpret and complete
|
||||
// will not make execute hang forever.
|
||||
ExecutorService pool = Executors.newFixedThreadPool(2);
|
||||
FutureTask<InterpreterResult> interpretFuture =
|
||||
new FutureTask(new Callable() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return interpreter.interpret(code, getInterpreterContext());
|
||||
}
|
||||
});
|
||||
FutureTask<List<InterpreterCompletion>> completionFuture =
|
||||
new FutureTask(new Callable() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return interpreter.completion(base, base.length(), null);
|
||||
}
|
||||
});
|
||||
|
||||
pool.execute(interpretFuture);
|
||||
// we sleep to ensure that the paragraph is running
|
||||
Thread.sleep(3000);
|
||||
pool.execute(completionFuture);
|
||||
|
||||
// We ensure that running and auto completion are not hanging.
|
||||
InterpreterResult res = interpretFuture.get(20000, TimeUnit.MILLISECONDS);
|
||||
List<InterpreterCompletion> autoRes = completionFuture.get(1000, TimeUnit.MILLISECONDS);
|
||||
assertTrue(res.code().name().equals("SUCCESS"));
|
||||
assertTrue(autoRes.size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGrpcFrameSize() throws InterpreterException, IOException {
|
||||
tearDown();
|
||||
|
|
|
|||
Loading…
Reference in a new issue