Repository: spark
Updated Branches:
  refs/heads/master 752e90f15 -> 2c8851343


[SPARK-3806][SQL] Minor fix for CliSuite

To fix two issues in CliSuite
1 CliSuite throw IndexOutOfBoundsException:
Exception in thread "Thread-6" java.lang.IndexOutOfBoundsException: 6
        at 
scala.collection.mutable.ResizableArray$class.apply(ResizableArray.scala:43)
        at scala.collection.mutable.ArrayBuffer.apply(ArrayBuffer.scala:47)
        at 
org.apache.spark.sql.hive.thriftserver.CliSuite.org$apache$spark$sql$hive$thriftserver$CliSuite$$captureOutput$1(CliSuite.scala:67)
        at 
org.apache.spark.sql.hive.thriftserver.CliSuite$$anonfun$4.apply(CliSuite.scala:78)
        at 
org.apache.spark.sql.hive.thriftserver.CliSuite$$anonfun$4.apply(CliSuite.scala:78)
        at scala.sys.process.ProcessLogger$$anon$1.out(ProcessLogger.scala:96)
        at 
scala.sys.process.BasicIO$$anonfun$processOutFully$1.apply(BasicIO.scala:135)
        at 
scala.sys.process.BasicIO$$anonfun$processOutFully$1.apply(BasicIO.scala:135)
        at scala.sys.process.BasicIO$.readFully$1(BasicIO.scala:175)
        at scala.sys.process.BasicIO$.processLinesFully(BasicIO.scala:179)
        at 
scala.sys.process.BasicIO$$anonfun$processFully$1.apply(BasicIO.scala:164)
        at 
scala.sys.process.BasicIO$$anonfun$processFully$1.apply(BasicIO.scala:162)
        at 
scala.sys.process.ProcessBuilderImpl$Simple$$anonfun$3.apply$mcV$sp(ProcessBuilderImpl.scala:73)
        at scala.sys.process.ProcessImpl$Spawn$$anon$1.run(ProcessImpl.scala:22)

Actually, it is the Mutil-Threads lead to this problem.

2 Using ```line.startsWith``` instead ```line.contains``` to assert expected 
answer. This is a tiny bug in CliSuite, for test case "Simple commands", there 
is a expected answers "5", if we use ```contains``` that means output like 
"14/10/06 11:```5```4:36 INFO CliDriver: Time taken: 1.078 seconds" or 
"14/10/06 11:54:36 INFO StatsReportListener:      0%      ```5```%        10%   
  25%     50%     75%     90%     95%     100%" will make the assert true.

Author: scwf <[email protected]>

Closes #2666 from scwf/clisuite and squashes the following commits:

11430db [scwf] fix-clisuite


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/2c885134
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2c885134
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2c885134

Branch: refs/heads/master
Commit: 2c8851343a2e4d1d5b3a2b959eaa651a92982a72
Parents: 752e90f
Author: scwf <[email protected]>
Authored: Thu Oct 9 13:22:36 2014 -0700
Committer: Michael Armbrust <[email protected]>
Committed: Thu Oct 9 13:22:41 2014 -0700

----------------------------------------------------------------------
 .../org/apache/spark/sql/hive/thriftserver/CliSuite.scala    | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/2c885134/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
 
b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
index 3475c2c..d68dd09 100644
--- 
a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
+++ 
b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
@@ -62,9 +62,11 @@ class CliSuite extends FunSuite with BeforeAndAfterAll with 
Logging {
 
     def captureOutput(source: String)(line: String) {
       buffer += s"$source> $line"
-      if (line.contains(expectedAnswers(next.get()))) {
-        if (next.incrementAndGet() == expectedAnswers.size) {
-          foundAllExpectedAnswers.trySuccess(())
+      if (next.get() < expectedAnswers.size) {
+        if (line.startsWith(expectedAnswers(next.get()))) {
+          if (next.incrementAndGet() == expectedAnswers.size) {
+            foundAllExpectedAnswers.trySuccess(())
+          }
         }
       }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to