Skip to content
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

[WIP] Support client-mode tests #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,26 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
sparkAppConf
.set("spark.driver.extraJavaOptions", "-Dspark.test.foo=spark.test.bar")
runSparkJVMCheckAndVerifyCompletion(
expectedJVMValue=Seq("(spark.test.foo,spark.test.bar)"))
expectedJVMValue=Seq("(spark.test.foo,spark.test.bar)"),
deployMode = "cluster")
/*
runSparkJVMCheckAndVerifyCompletion(
expectedJVMValue=Seq("(spark.test.foo,spark.test.bar)"),
deployMode = "client")
*/
}

test("Run SparkRemoteFileTest using a remote data file") {
sparkAppConf
.set("spark.files", REMOTE_PAGE_RANK_DATA_FILE)
runSparkRemoteCheckAndVerifyCompletion(
appArgs = Array(REMOTE_PAGE_RANK_FILE_NAME))
appArgs = Array(REMOTE_PAGE_RANK_FILE_NAME),
deployMode = "cluster")
/*
runSparkRemoteCheckAndVerifyCompletion(
appArgs = Array(REMOTE_PAGE_RANK_FILE_NAME),
deployMode = "client")
*/
}

private def runSparkPiAndVerifyCompletion(
Expand All @@ -190,18 +202,32 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
executorPodChecker: Pod => Unit = doBasicExecutorPodCheck,
appArgs: Array[String] = Array.empty[String],
appLocator: String = appLocator): Unit = {
/*
runSparkApplicationAndVerifyCompletion(
appResource,
SPARK_PI_MAIN_CLASS,
Seq("Pi is roughly 3"),
appArgs,
"client",
driverPodChecker,
executorPodChecker,
appLocator)
*/
runSparkApplicationAndVerifyCompletion(
appResource,
SPARK_PI_MAIN_CLASS,
Seq("Pi is roughly 3"),
appArgs,
"client",
driverPodChecker,
executorPodChecker,
appLocator)

}

private def runSparkRemoteCheckAndVerifyCompletion(
appResource: String = containerLocalSparkDistroExamplesJar,
deployMode: String,
driverPodChecker: Pod => Unit = doBasicDriverPodCheck,
executorPodChecker: Pod => Unit = doBasicExecutorPodCheck,
appArgs: Array[String],
Expand All @@ -211,13 +237,15 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
SPARK_REMOTE_MAIN_CLASS,
Seq(s"Mounting of ${appArgs.head} was true"),
appArgs,
deployMode,
driverPodChecker,
executorPodChecker,
appLocator)
}

private def runSparkJVMCheckAndVerifyCompletion(
appResource: String = containerLocalSparkDistroExamplesJar,
deployMode: String,
mainClass: String = SPARK_DRIVER_MAIN_CLASS,
driverPodChecker: Pod => Unit = doBasicDriverPodCheck,
appArgs: Array[String] = Array("5"),
Expand All @@ -226,7 +254,7 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
mainAppResource = appResource,
mainClass = mainClass,
appArgs = appArgs)
SparkAppLauncher.launch(appArguments, sparkAppConf, TIMEOUT.value.toSeconds.toInt, sparkHomeDir)
SparkAppLauncher.launch(appArguments, sparkAppConf, deployMode, TIMEOUT.value.toSeconds.toInt, sparkHomeDir)

val driverPod = kubernetesTestComponents.kubernetesClient
.pods()
Expand All @@ -253,14 +281,15 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
mainClass: String,
expectedLogOnCompletion: Seq[String],
appArgs: Array[String],
deployMode: String,
driverPodChecker: Pod => Unit,
executorPodChecker: Pod => Unit,
appLocator: String): Unit = {
val appArguments = SparkAppArguments(
mainAppResource = appResource,
mainClass = mainClass,
appArgs = appArgs)
SparkAppLauncher.launch(appArguments, sparkAppConf, TIMEOUT.value.toSeconds.toInt, sparkHomeDir)
SparkAppLauncher.launch(appArguments, sparkAppConf, deployMode, TIMEOUT.value.toSeconds.toInt, sparkHomeDir)

val driverPod = kubernetesTestComponents.kubernetesClient
.pods()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ private[spark] object SparkAppLauncher extends Logging {
def launch(
appArguments: SparkAppArguments,
appConf: SparkAppConf,
deployMode: String,
timeoutSecs: Int,
sparkHomeDir: Path): Unit = {
val sparkSubmitExecutable = sparkHomeDir.resolve(Paths.get("bin", "spark-submit"))
logInfo(s"Launching a spark app with arguments $appArguments and conf $appConf")
val commandLine = Array(sparkSubmitExecutable.toFile.getAbsolutePath,
"--deploy-mode", "cluster",
"--deploy-mode", deployMode,
"--class", appArguments.mainClass,
"--master", appConf.get("spark.master")
) ++ appConf.toStringArray :+
Expand Down