Skip to content

Commit cf46e72

Browse files
lianchengmarmbrus
authored andcommitted
[SPARK-3126][SPARK-3127][SQL] Fixed HiveThriftServer2Suite
This PR fixes two issues: 1. Fixes wrongly quoted command line option in `HiveThriftServer2Suite` that makes test cases hang until timeout. 1. Asks `dev/run-test` to run Spark SQL tests when `bin/spark-sql` and/or `sbin/start-thriftserver.sh` are modified. Author: Cheng Lian <[email protected]> Closes apache#2036 from liancheng/fix-thriftserver-test and squashes the following commits: f38c4eb [Cheng Lian] Fixed the same quotation issue in CliSuite 26b82a0 [Cheng Lian] Run SQL tests when dff contains bin/spark-sql and/or sbin/start-thriftserver.sh a87f83d [Cheng Lian] Extended timeout e5aa31a [Cheng Lian] Fixed metastore JDBC URI quotation
1 parent ceb1983 commit cf46e72

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

dev/run-tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ JAVA_VERSION=$($java_cmd -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*
5555
# Partial solution for SPARK-1455. Only run Hive tests if there are sql changes.
5656
if [ -n "$AMPLAB_JENKINS" ]; then
5757
git fetch origin master:master
58-
diffs=`git diff --name-only master | grep "^sql/"`
58+
diffs=`git diff --name-only master | grep "^\(sql/\)\|\(bin/spark-sql\)\|\(sbin/start-thriftserver.sh\)"`
5959
if [ -n "$diffs" ]; then
6060
echo "Detected changes in SQL. Will run Hive test suite."
6161
_RUN_SQL_TESTS=true

sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CliSuite extends FunSuite with BeforeAndAfterAll with TestUtils {
3232
val commands =
3333
s"""../../bin/spark-sql
3434
| --master local
35-
| --hiveconf ${ConfVars.METASTORECONNECTURLKEY}="$jdbcUrl"
35+
| --hiveconf ${ConfVars.METASTORECONNECTURLKEY}=$jdbcUrl
3636
| --hiveconf ${ConfVars.METASTOREWAREHOUSE}=$WAREHOUSE_PATH
3737
""".stripMargin.split("\\s+")
3838

sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suite.scala

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ class HiveThriftServer2Suite extends FunSuite with BeforeAndAfterAll with TestUt
5151
port
5252
}
5353

54-
// If verbose is true, the test program will print all outputs coming from the Hive Thrift server.
55-
val VERBOSE = Option(System.getenv("SPARK_SQL_TEST_VERBOSE")).getOrElse("false").toBoolean
56-
5754
Class.forName(DRIVER_NAME)
5855

5956
override def beforeAll() { launchServer() }
@@ -68,21 +65,18 @@ class HiveThriftServer2Suite extends FunSuite with BeforeAndAfterAll with TestUt
6865
val command =
6966
s"""../../sbin/start-thriftserver.sh
7067
| --master local
71-
| --hiveconf hive.root.logger=INFO,console
72-
| --hiveconf ${ConfVars.METASTORECONNECTURLKEY}="$jdbcUrl"
68+
| --hiveconf ${ConfVars.METASTORECONNECTURLKEY}=$jdbcUrl
7369
| --hiveconf ${ConfVars.METASTOREWAREHOUSE}=$METASTORE_PATH
7470
| --hiveconf ${ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST}=$HOST
7571
| --hiveconf ${ConfVars.HIVE_SERVER2_THRIFT_PORT}=$PORT
7672
""".stripMargin.split("\\s+")
7773

7874
val pb = new ProcessBuilder(command ++ args: _*)
7975
val environment = pb.environment()
80-
environment.put("HIVE_SERVER2_THRIFT_PORT", PORT.toString)
81-
environment.put("HIVE_SERVER2_THRIFT_BIND_HOST", HOST)
8276
process = pb.start()
8377
inputReader = new BufferedReader(new InputStreamReader(process.getInputStream))
8478
errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream))
85-
waitForOutput(inputReader, "ThriftBinaryCLIService listening on")
79+
waitForOutput(inputReader, "ThriftBinaryCLIService listening on", 300000)
8680

8781
// Spawn a thread to read the output from the forked process.
8882
// Note that this is necessary since in some configurations, log4j could be blocked
@@ -91,12 +85,8 @@ class HiveThriftServer2Suite extends FunSuite with BeforeAndAfterAll with TestUt
9185
while (true) {
9286
val stdout = readFrom(inputReader)
9387
val stderr = readFrom(errorReader)
94-
if (VERBOSE && stdout.length > 0) {
95-
println(stdout)
96-
}
97-
if (VERBOSE && stderr.length > 0) {
98-
println(stderr)
99-
}
88+
print(stdout)
89+
print(stderr)
10090
Thread.sleep(50)
10191
}
10292
}

0 commit comments

Comments
 (0)