juliuszsompolski commented on a change in pull request #25567: 
[SPARK-28527][SQL][TEST] Re-run all the tests in SQLQueryTestSuite via Thrift 
Server
URL: https://github.com/apache/spark/pull/25567#discussion_r318104551
 
 

 ##########
 File path: 
sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/ThriftServerQueryTestSuite.scala
 ##########
 @@ -0,0 +1,358 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.hive.thriftserver
+
+import java.io.File
+import java.sql.{DriverManager, SQLException, Statement, Timestamp}
+import java.util.Locale
+
+import scala.util.{Random, Try}
+import scala.util.control.NonFatal
+
+import org.apache.hadoop.hive.conf.HiveConf.ConfVars
+import org.apache.hive.service.cli.HiveSQLException
+
+import org.apache.spark.sql.{AnalysisException, SQLQueryTestSuite}
+import org.apache.spark.sql.catalyst.util.fileToString
+import org.apache.spark.sql.execution.HiveResult
+import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.types._
+
+/**
+ * Re-run all the tests in SQLQueryTestSuite via Thrift Server.
+ * Note that this TestSuite does not support maven.
+ *
+ * TODO:
+ *   1. Support UDF testing.
+ *   2. Support DESC command.
+ *   3. Support SHOW command.
+ */
+class ThriftServerQueryTestSuite extends SQLQueryTestSuite {
+
+  private var hiveServer2: HiveThriftServer2 = _
+
+  override def beforeEach(): Unit = {
+    // Chooses a random port between 10000 and 19999
+    var listeningPort = 10000 + Random.nextInt(10000)
+
+    // Retries up to 3 times with different port numbers if the server fails 
to start
+    (1 to 3).foldLeft(Try(startThriftServer(listeningPort, 0))) { case 
(started, attempt) =>
+      started.orElse {
+        listeningPort += 1
+        Try(startThriftServer(listeningPort, attempt))
 
 Review comment:
   @wangyum 
   I think this is the cause of flakiness.
   
   This goes down to 
https://github.com/apache/spark/blob/master/sql/hive-thriftserver/v1.2.1/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java#L178,
 which starts the service in an asynchronous background thread. It can race and 
try to connect in the test before the server actually gets initialized.
   Moving it to `beforeAll()` and adding a few seconds sleep should help.
   Or we could transplant the whole way from `HiveThriftServer2Test` that 
starts uses the start-thriftserver.sh script and monitors it's log until its 
started. Would it be possible to make `HiveThriftServer2Test` a trait that can 
be mixed in here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to