-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-23078] add tests for Spark Thrift Server on Kubernetes #38
base: master
Are you sure you want to change the base?
Changes from 9 commits
0e7a4ed
b43d137
66b1771
befc2cc
0236305
95b6b55
528b064
72d79e4
0b5f09e
4c8fe2f
36dee22
cef7f5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ import java.io.File | |
import java.nio.file.{Path, Paths} | ||
import java.util.UUID | ||
import java.util.regex.Pattern | ||
import java.sql.DriverManager | ||
import org.apache.hive.jdbc.HiveDriver | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be an empty line separating java imports and the rest, and the order of imports should be java, scala, other third-party, and finally spark. So |
||
|
||
import scala.collection.JavaConverters._ | ||
import com.google.common.io.PatternFilenameFilter | ||
|
@@ -121,6 +123,10 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit | |
runSparkPiAndVerifyCompletion(appArgs = Array("5")) | ||
} | ||
|
||
test("Run Spark Thrift Server") { | ||
runThriftServerAndVerifyQuery() | ||
} | ||
|
||
test("Run SparkPi with custom labels, annotations, and environment variables.") { | ||
sparkAppConf | ||
.set("spark.kubernetes.driver.label.label1", "label1-value") | ||
|
@@ -239,6 +245,43 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit | |
appLocator) | ||
} | ||
|
||
private def runThriftServerAndVerifyQuery( | ||
driverPodChecker: Pod => Unit = doBasicDriverPodCheck, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indention for function parameters is wrong. Should be four spaces. |
||
appArgs: Array[String] = Array.empty[String], | ||
appLocator: String = appLocator): Unit = { | ||
val appArguments = SparkAppArguments( | ||
mainAppResource = "", | ||
mainClass = "org.apache.spark.sql.hive.thriftserver.HiveThriftServer2", | ||
appArgs = appArgs) | ||
SparkAppLauncher.launch(appArguments, sparkAppConf, TIMEOUT.value.toSeconds.toInt, sparkHomeDir) | ||
val driverPod = kubernetesTestComponents.kubernetesClient | ||
.pods | ||
.withLabel("spark-app-locator", appLocator) | ||
.withLabel("spark-role", "driver") | ||
.list() | ||
.getItems | ||
.get(0) | ||
driverPodChecker(driverPod) | ||
val driverPodResource = kubernetesTestComponents.kubernetesClient | ||
.pods | ||
.withName(driverPod.getMetadata.getName) | ||
|
||
Eventually.eventually(TIMEOUT, INTERVAL) { | ||
val localPort = driverPodResource.portForward(10000).getLocalPort | ||
val jdbcUri = s"jdbc:hive2://localhost:$localPort/" | ||
val connection = DriverManager.getConnection(jdbcUri, "user", "pass") | ||
val statement = connection.createStatement() | ||
try { | ||
val resultSet = statement.executeQuery("select 42") | ||
resultSet.next() | ||
assert(resultSet.getInt(1) == 42) | ||
} finally { | ||
statement.close() | ||
connection.close() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. I got this from https://github.com/apache/spark/blob/master/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/JdbcConnectionUriSuite.scala#L66, worth fixing? |
||
} | ||
} | ||
} | ||
|
||
private def runSparkApplicationAndVerifyCompletion( | ||
appResource: String, | ||
mainClass: String, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to depend on
hadoop-common
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without it I get
java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration
. In general, I believe Hive JDBC requires some Hadoop dependencies, as discussed in eg https://issues.apache.org/jira/browse/HIVE-15110. Not sure if it's only configuration. Do you have a cleaner solution?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for the info.