You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sr...@apache.org on 2019/01/03 16:26:58 UTC

[spark] branch branch-2.4 updated: [SPARK-26501][CORE][TEST] Fix unexpected overriden of exitFn in SparkSubmitSuite

This is an automated email from the ASF dual-hosted git repository.

srowen pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new bd6e570  [SPARK-26501][CORE][TEST] Fix unexpected overriden of exitFn in SparkSubmitSuite
bd6e570 is described below

commit bd6e5701cebf52542bc7e2321565f6207f3929e2
Author: Liupengcheng <li...@xiaomi.com>
AuthorDate: Thu Jan 3 10:26:14 2019 -0600

    [SPARK-26501][CORE][TEST] Fix unexpected overriden of exitFn in SparkSubmitSuite
    
    ## What changes were proposed in this pull request?
    
    The overriden of SparkSubmit's exitFn at some previous tests in SparkSubmitSuite may cause the following tests pass even they failed when they were run separately. This PR is to fix this problem.
    
    ## How was this patch tested?
    
    unittest
    
    Closes #23404 from liupc/Fix-SparkSubmitSuite-exitFn.
    
    Authored-by: Liupengcheng <li...@xiaomi.com>
    Signed-off-by: Sean Owen <se...@databricks.com>
    (cherry picked from commit 88b074f3f06ddd236d63e8bf31edebe1d3e94fe4)
    Signed-off-by: Sean Owen <se...@databricks.com>
---
 .../org/apache/spark/deploy/SparkSubmitSuite.scala | 40 ++++++++++++----------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala b/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala
index c093789..887a88f 100644
--- a/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala
+++ b/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala
@@ -72,27 +72,31 @@ trait TestPrematureExit {
     mainObject.printStream = printStream
 
     @volatile var exitedCleanly = false
+    val original = mainObject.exitFn
     mainObject.exitFn = (_) => exitedCleanly = true
-
-    @volatile var exception: Exception = null
-    val thread = new Thread {
-      override def run() = try {
-        mainObject.main(input)
-      } catch {
-        // Capture the exception to check whether the exception contains searchString or not
-        case e: Exception => exception = e
+    try {
+      @volatile var exception: Exception = null
+      val thread = new Thread {
+        override def run() = try {
+          mainObject.main(input)
+        } catch {
+          // Capture the exception to check whether the exception contains searchString or not
+          case e: Exception => exception = e
+        }
       }
-    }
-    thread.start()
-    thread.join()
-    if (exitedCleanly) {
-      val joined = printStream.lineBuffer.mkString("\n")
-      assert(joined.contains(searchString))
-    } else {
-      assert(exception != null)
-      if (!exception.getMessage.contains(searchString)) {
-        throw exception
+      thread.start()
+      thread.join()
+      if (exitedCleanly) {
+        val joined = printStream.lineBuffer.mkString("\n")
+        assert(joined.contains(searchString))
+      } else {
+        assert(exception != null)
+        if (!exception.getMessage.contains(searchString)) {
+          throw exception
+        }
       }
+    } finally {
+      mainObject.exitFn = original
     }
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org