You are viewing a plain text version of this content. The canonical link for it is here.
Posted to submarine-dev@hadoop.apache.org by GitBox <gi...@apache.org> on 2019/10/17 08:32:14 UTC

[GitHub] [hadoop-submarine] liuxunorg commented on a change in pull request #52: [SUBMARINE-247].Add test cases for Python Interpreter

liuxunorg commented on a change in pull request #52: [SUBMARINE-247].Add test cases for Python Interpreter
URL: https://github.com/apache/hadoop-submarine/pull/52#discussion_r335873567
 
 

 ##########
 File path: submarine-workbench/interpreter/python-interpreter/src/test/java/org/apache/submarine/interpreter/PythonInterpreterTest.java
 ##########
 @@ -24,35 +24,99 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.assertEquals;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
-import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 public class PythonInterpreterTest {
   private static final Logger LOG = LoggerFactory.getLogger(PythonInterpreterTest.class);
 
-  private static PythonInterpreter pythonInterpreter = null;
+  private static PythonInterpreter testPythonInterpreter1 = null;
+
+  private static PythonInterpreter testPythonInterpreter2 = null;
 
   @BeforeClass
   public static void setUp() {
-    pythonInterpreter = new PythonInterpreter();
-    pythonInterpreter.open();
+    testPythonInterpreter1 = new PythonInterpreter();
+    testPythonInterpreter2 = new PythonInterpreter();
+    testPythonInterpreter1.open();
+    testPythonInterpreter2.open();
   }
 
   @AfterClass
-  public static void tearDown() throws Exception {
-    if (null != pythonInterpreter) {
-      pythonInterpreter.close();
+  public static void tearDown()  {
+    if (null != testPythonInterpreter1) {
+      testPythonInterpreter1.close();
+    }
+    if (null != testPythonInterpreter2) {
+      testPythonInterpreter2.close();
     }
   }
 
+
   @Test
-  public void calcOnePlusOne() throws IOException {
+  public void calcOnePlusOne() {
     String code = "1+1";
-    InterpreterResult result = pythonInterpreter.interpret(code);
+    InterpreterResult result = testPythonInterpreter1.interpret(code);
     LOG.info("result = {}", result);
 
     assertEquals(result.code(), InterpreterResult.Code.SUCCESS);
     assertEquals(result.message().get(0).getData(), "2\n"); // 1 + 1 = 2 + '\n'
   }
+
+  private class infinityPythonJobforCancel implements Runnable {
+    @Override
+    public void run() {
+      String code = "import time\nwhile True:\n  time.sleep(1)";
 
 Review comment:
   Why is `time.sleep(1)`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services