Repository: zeppelin
Updated Branches:
  refs/heads/master 99c21c4ed -> 236bf3ad6


[ZEPPELIN-1857] Fix flaky test: 
NotebookTest.testAbortParagraphStatusOnInterpreterRestart()

### What is this PR for?
This PR fixes flaky test 
NotebookTest.testAbortParagraphStatusOnInterpreterRestart()

### What type of PR is it?
Hot Fix

### Todos
* [x] - re implement NotebookTest.testAbortParagraphStatusOnInterpreterRestart()

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1857

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Lee moon soo <m...@apache.org>

Closes #1923 from Leemoonsoo/ZEPPELIN-1857 and squashes the following commits:

5d60e5b [Lee moon soo] Fix 
NotebookTest.testAbortParagraphStatusOnInterpreterRestart()


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

Branch: refs/heads/master
Commit: 236bf3ad6f8300e61321f64bccc8a7540e02e59f
Parents: 99c21c4
Author: Lee moon soo <m...@apache.org>
Authored: Fri Jan 20 15:01:32 2017 -0800
Committer: Lee moon soo <m...@apache.org>
Committed: Fri Jan 20 17:53:15 2017 -0800

----------------------------------------------------------------------
 .../apache/zeppelin/notebook/NotebookTest.java  | 39 +++++++++-----------
 1 file changed, 18 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/236bf3ad/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 0725037..82d280e 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
@@ -736,35 +736,32 @@ public class NotebookTest implements JobListenerFactory{
     Note note = notebook.createNote(anonymous);
     factory.setInterpreters(anonymous.getUser(), note.getId(), 
factory.getDefaultInterpreterSettingList());
 
-    ArrayList<Paragraph> paragraphs = new ArrayList<>();
-    for (int i = 0; i < 100; i++) {
-      Paragraph tmp = note.addParagraph(AuthenticationInfo.ANONYMOUS);
-      tmp.setText("p" + tmp.getId());
-      paragraphs.add(tmp);
-    }
+    // create three paragraphs
+    Paragraph p1 = note.addParagraph(anonymous);
+    p1.setText("sleep 1000");
+    Paragraph p2 = note.addParagraph(anonymous);
+    p2.setText("sleep 1000");
+    Paragraph p3 = note.addParagraph(anonymous);
+    p3.setText("sleep 1000");
 
-    for (Paragraph p : paragraphs) {
-      assertEquals(Job.Status.READY, p.getStatus());
-    }
 
     note.runAll();
 
-    while (paragraphs.get(0).getStatus() != Status.FINISHED) Thread.yield();
+    // wait until first paragraph finishes and second paragraph starts
+    while (p1.getStatus() != Status.FINISHED || p2.getStatus() != 
Status.RUNNING) Thread.yield();
 
+    assertEquals(Status.FINISHED, p1.getStatus());
+    assertEquals(Status.RUNNING, p2.getStatus());
+    assertEquals(Status.PENDING, p3.getStatus());
+
+    // restart interpreter
     
factory.restart(factory.getInterpreterSettings(note.getId()).get(0).getId());
 
-    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;
-      }
-    }
+    // make sure three differnt status aborted well.
+    assertEquals(Status.FINISHED, p1.getStatus());
+    assertEquals(Status.ABORT, p2.getStatus());
+    assertEquals(Status.ABORT, p3.getStatus());
 
-    assertTrue(isAborted);
     notebook.removeNote(note.getId(), anonymous);
   }
 

Reply via email to