zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jongy...@apache.org
Subject incubator-zeppelin git commit: ZEPPELIN-458 Fix testAbortParagraphStatusOnInterpreterRestart
Date Fri, 27 Nov 2015 06:50:40 GMT
Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master 74b1f0c97 -> 1285f4fbd


ZEPPELIN-458 Fix testAbortParagraphStatusOnInterpreterRestart

- Changed how to check some paragraph is aborted
- See the https://issues.apache.org/jira/browse/ZEPPELIN-458 for more details

Author: Jongyoul Lee <jongyoul@gmail.com>

Closes #468 from jongyoul/ZEPPELIN-458 and squashes the following commits:

d41e53d [Jongyoul Lee] ZEPPELIN-458 Fix testAbortParagraphStatusOnInterpreterRestart - Changed
how to check some paragraph is aborted


Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/1285f4fb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/1285f4fb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/1285f4fb

Branch: refs/heads/master
Commit: 1285f4fbd8fa21b256ffa7e927ac0792829cd2ee
Parents: 74b1f0c
Author: Jongyoul Lee <jongyoul@gmail.com>
Authored: Tue Nov 24 17:06:49 2015 +0900
Committer: Jongyoul Lee <jongyoul@apache.org>
Committed: Fri Nov 27 15:50:05 2015 +0900

----------------------------------------------------------------------
 .../apache/zeppelin/notebook/NotebookTest.java  | 65 +++++++++-----------
 1 file changed, 29 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1285f4fb/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
index 8ae0970..ee35773 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -48,8 +49,11 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.quartz.SchedulerException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class NotebookTest implements JobListenerFactory{
+  private static final Logger logger = LoggerFactory.getLogger(NotebookTest.class);
 
   private File tmpDir;
   private ZeppelinConfiguration conf;
@@ -228,7 +232,7 @@ public class NotebookTest implements JobListenerFactory{
     note.setConfig(config);
     notebook.refreshCron(note.id());
     Thread.sleep(1*1000);
-    
+
     // remove cron scheduler.
     config.put("cron", null);
     note.setConfig(config);
@@ -319,46 +323,35 @@ public class NotebookTest implements JobListenerFactory{
     Note note = notebook.createNote();
     note.getNoteReplLoader().setInterpreters(factory.getDefaultInterpreterSettingList());
 
-    Paragraph p1 = note.addParagraph();
-    p1.setText("p1");
-    Paragraph p2 = note.addParagraph();
-    p2.setText("p2");
-    Paragraph p3 = note.addParagraph();
-    p3.setText("p3");
-    Paragraph p4 = note.addParagraph();
-    p4.setText("p4");
-
-    /* all jobs are ready to run */
-    assertEquals(Job.Status.READY, p1.getStatus());
-    assertEquals(Job.Status.READY, p2.getStatus());
-    assertEquals(Job.Status.READY, p3.getStatus());
-    assertEquals(Job.Status.READY, p4.getStatus());
-
-	/* run all */
-    note.runAll();
+    ArrayList<Paragraph> paragraphs = new ArrayList<>();
+    for (int i = 0; i < 100; i++) {
+      Paragraph tmp = note.addParagraph();
+      tmp.setText("p" + tmp.getId());
+      paragraphs.add(tmp);
+    }
 
-    /* all are pending in the beginning (first one possibly started)*/
-    assertTrue(p1.getStatus() == Job.Status.PENDING || p1.getStatus() == Job.Status.RUNNING);
-    assertEquals(Job.Status.PENDING, p2.getStatus());
-    assertEquals(Job.Status.PENDING, p3.getStatus());
-    assertEquals(Job.Status.PENDING, p4.getStatus());
+    for (Paragraph p : paragraphs) {
+      assertEquals(Job.Status.READY, p.getStatus());
+    }
 
-    /* wait till first job is terminated and second starts running */
-    while(p1.isTerminated() == false || (p2.getStatus() == Job.Status.PENDING)) Thread.yield();
+    note.runAll();
 
-    assertEquals(Job.Status.FINISHED, p1.getStatus());
-    assertEquals(Job.Status.RUNNING, p2.getStatus());
-    assertEquals(Job.Status.PENDING, p3.getStatus());
-    assertEquals(Job.Status.PENDING, p4.getStatus());
+    while (paragraphs.get(0).getStatus() != Status.FINISHED) Thread.yield();
 
-    /* restart interpreter */
     factory.restart(note.getNoteReplLoader().getInterpreterSettings().get(0).id());
 
-    /* pending and running jobs have been aborted */
-    assertEquals(Job.Status.FINISHED, p1.getStatus());
-    assertEquals(Job.Status.ABORT, p2.getStatus());
-    assertEquals(Job.Status.ABORT, p3.getStatus());
-    assertEquals(Job.Status.ABORT, p4.getStatus());
+    boolean isAborted = false;
+    for (Paragraph p : paragraphs) {
+      logger.debug(p.getStatus().name());
+      if (isAborted) {
+        assertEquals(Job.Status.ABORT, p.getStatus());
+      }
+      if (p.getStatus() == Status.ABORT) {
+        isAborted = true;
+      }
+    }
+
+    assertTrue(isAborted);
   }
 
   private void delete(File file){
@@ -373,7 +366,7 @@ public class NotebookTest implements JobListenerFactory{
       file.delete();
     }
   }
-  
+
   @Override
   public JobListener getParagraphJobListener(Note note) {
     return new JobListener(){


Mime
View raw message